|
1 | 1 | package com.github.codeql |
2 | 2 |
|
3 | 3 | import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext |
| 4 | +import org.jetbrains.kotlin.builtins.StandardNames |
4 | 5 | import org.jetbrains.kotlin.ir.declarations.IrClass |
| 6 | +import org.jetbrains.kotlin.ir.declarations.IrPackageFragment |
5 | 7 | import org.jetbrains.kotlin.ir.types.IrSimpleType |
6 | | -import org.jetbrains.kotlin.ir.types.IdSignatureValues |
7 | | -import org.jetbrains.kotlin.ir.util.IdSignature |
| 8 | +import org.jetbrains.kotlin.ir.types.classOrNull |
8 | 9 | import org.jetbrains.kotlin.name.FqName |
9 | 10 |
|
10 | 11 | class PrimitiveTypeMapping(val logger: Logger, val pluginContext: IrPluginContext) { |
11 | | - fun getPrimitiveInfo(s: IrSimpleType) = mapping[s.classifier.signature] |
| 12 | + fun getPrimitiveInfo(s: IrSimpleType) = |
| 13 | + s.classOrNull?.let { |
| 14 | + if ((it.owner.parent as? IrPackageFragment)?.fqName == StandardNames.BUILT_INS_PACKAGE_FQ_NAME) |
| 15 | + mapping[it.owner.name] |
| 16 | + else |
| 17 | + null |
| 18 | + } |
12 | 19 |
|
13 | 20 | data class PrimitiveTypeInfo( |
14 | 21 | val primitiveName: String?, |
@@ -60,25 +67,25 @@ class PrimitiveTypeMapping(val logger: Logger, val pluginContext: IrPluginContex |
60 | 67 | val javaLangVoid = findClass("java.lang.Void", kotlinNothing) |
61 | 68 |
|
62 | 69 | mapOf( |
63 | | - IdSignatureValues._byte to PrimitiveTypeInfo("byte", true, javaLangByte, "kotlin", "Byte"), |
64 | | - IdSignatureValues._short to PrimitiveTypeInfo("short", true, javaLangShort, "kotlin", "Short"), |
65 | | - IdSignatureValues._int to PrimitiveTypeInfo("int", true, javaLangInteger, "kotlin", "Int"), |
66 | | - IdSignatureValues._long to PrimitiveTypeInfo("long", true, javaLangLong, "kotlin", "Long"), |
| 70 | + StandardNames.FqNames._byte.shortName() to PrimitiveTypeInfo("byte", true, javaLangByte, "kotlin", "Byte"), |
| 71 | + StandardNames.FqNames._short.shortName() to PrimitiveTypeInfo("short", true, javaLangShort, "kotlin", "Short"), |
| 72 | + StandardNames.FqNames._int.shortName() to PrimitiveTypeInfo("int", true, javaLangInteger, "kotlin", "Int"), |
| 73 | + StandardNames.FqNames._long.shortName() to PrimitiveTypeInfo("long", true, javaLangLong, "kotlin", "Long"), |
67 | 74 |
|
68 | | - IdSignatureValues.uByte to PrimitiveTypeInfo("byte", true, kotlinUByte, "kotlin", "UByte"), |
69 | | - IdSignatureValues.uShort to PrimitiveTypeInfo("short", true, kotlinUShort, "kotlin", "UShort"), |
70 | | - IdSignatureValues.uInt to PrimitiveTypeInfo("int", true, kotlinUInt, "kotlin", "UInt"), |
71 | | - IdSignatureValues.uLong to PrimitiveTypeInfo("long", true, kotlinULong, "kotlin", "ULong"), |
| 75 | + StandardNames.FqNames.uByteFqName.shortName() to PrimitiveTypeInfo("byte", true, kotlinUByte, "kotlin", "UByte"), |
| 76 | + StandardNames.FqNames.uShortFqName.shortName() to PrimitiveTypeInfo("short", true, kotlinUShort, "kotlin", "UShort"), |
| 77 | + StandardNames.FqNames.uIntFqName.shortName() to PrimitiveTypeInfo("int", true, kotlinUInt, "kotlin", "UInt"), |
| 78 | + StandardNames.FqNames.uLongFqName.shortName() to PrimitiveTypeInfo("long", true, kotlinULong, "kotlin", "ULong"), |
72 | 79 |
|
73 | | - IdSignatureValues._double to PrimitiveTypeInfo("double", true, javaLangDouble, "kotlin", "Double"), |
74 | | - IdSignatureValues._float to PrimitiveTypeInfo("float", true, javaLangFloat, "kotlin", "Float"), |
| 80 | + StandardNames.FqNames._double.shortName() to PrimitiveTypeInfo("double", true, javaLangDouble, "kotlin", "Double"), |
| 81 | + StandardNames.FqNames._float.shortName() to PrimitiveTypeInfo("float", true, javaLangFloat, "kotlin", "Float"), |
75 | 82 |
|
76 | | - IdSignatureValues._boolean to PrimitiveTypeInfo("boolean", true, javaLangBoolean, "kotlin", "Boolean"), |
| 83 | + StandardNames.FqNames._boolean.shortName() to PrimitiveTypeInfo("boolean", true, javaLangBoolean, "kotlin", "Boolean"), |
77 | 84 |
|
78 | | - IdSignatureValues._char to PrimitiveTypeInfo("char", true, javaLangCharacter, "kotlin", "Char"), |
| 85 | + StandardNames.FqNames._char.shortName() to PrimitiveTypeInfo("char", true, javaLangCharacter, "kotlin", "Char"), |
79 | 86 |
|
80 | | - IdSignatureValues.unit to PrimitiveTypeInfo("void", false, kotlinUnit, "kotlin", "Unit"), |
81 | | - IdSignatureValues.nothing to PrimitiveTypeInfo(null, true, javaLangVoid, "kotlin", "Nothing"), |
| 87 | + StandardNames.FqNames.unit.shortName() to PrimitiveTypeInfo("void", false, kotlinUnit, "kotlin", "Unit"), |
| 88 | + StandardNames.FqNames.nothing.shortName() to PrimitiveTypeInfo(null, true, javaLangVoid, "kotlin", "Nothing"), |
82 | 89 | ) |
83 | 90 | }() |
84 | 91 | } |
0 commit comments