Skip to content

Commit b80bf4a

Browse files
committed
Account for route to IrSimpleType.kotlinType changing as of v1.7.0
1 parent 7889d9c commit b80bf4a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.github.codeql
22

33
import com.github.codeql.utils.*
44
import com.github.codeql.utils.versions.codeQlWithHasQuestionMark
5+
import com.github.codeql.utils.versions.getKotlinType
56
import com.github.codeql.utils.versions.isRawType
67
import com.semmle.extractor.java.OdasaOutput
78
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
@@ -671,7 +672,7 @@ open class KotlinUsesExtractor(
671672
javaClass: IrClass,
672673
kotlinPackageName: String, kotlinClassName: String): TypeResults {
673674
// Note the use of `hasEnhancedNullability` here covers cases like `@NotNull Integer`, which must be extracted as `Integer` not `int`.
674-
val javaResult = if ((context == TypeContext.RETURN || (context == TypeContext.OTHER && otherIsPrimitive)) && !s.isNullable() && s.kotlinType?.hasEnhancedNullability() != true && primitiveName != null) {
675+
val javaResult = if ((context == TypeContext.RETURN || (context == TypeContext.OTHER && otherIsPrimitive)) && !s.isNullable() && getKotlinType(s)?.hasEnhancedNullability() != true && primitiveName != null) {
675676
val label: Label<DbPrimitive> = tw.getLabelFor("@\"type;$primitiveName\"", {
676677
tw.writePrimitives(it, primitiveName)
677678
})
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrSimpleType
4+
import org.jetbrains.kotlin.ir.types.impl.IrTypeBase
5+
6+
fun getKotlinType(s: IrSimpleType) = (s as? IrTypeBase)?.kotlinType
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.github.codeql.utils.versions
2+
3+
import org.jetbrains.kotlin.ir.types.IrSimpleType
4+
5+
fun getKotlinType(s: IrSimpleType) = s.kotlinType

0 commit comments

Comments
 (0)