FIR2IR strip annotations from IrConst type
This commit is contained in:
@@ -261,7 +261,8 @@ fun <T> FirConstExpression<T>.toIrConst(irType: IrType): IrConst<T> {
|
|||||||
} as T ?: value
|
} as T ?: value
|
||||||
IrConstImpl(
|
IrConstImpl(
|
||||||
startOffset, endOffset,
|
startOffset, endOffset,
|
||||||
irType,
|
// Strip all annotations (including special annotations such as @EnhancedNullability) from constant type
|
||||||
|
irType.removeAnnotations(),
|
||||||
kind, value
|
kind, value
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,18 @@ fun IrType.removeAnnotations(predicate: (IrConstructorCall) -> Boolean): IrType
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun IrType.removeAnnotations(): IrType =
|
||||||
|
when (this) {
|
||||||
|
is IrSimpleType ->
|
||||||
|
toBuilder().apply {
|
||||||
|
annotations = emptyList()
|
||||||
|
}.buildSimpleType()
|
||||||
|
is IrDynamicType ->
|
||||||
|
IrDynamicTypeImpl(null, emptyList(), Variance.INVARIANT)
|
||||||
|
else ->
|
||||||
|
this
|
||||||
|
}
|
||||||
|
|
||||||
val IrType.classifierOrFail: IrClassifierSymbol
|
val IrType.classifierOrFail: IrClassifierSymbol
|
||||||
get() = cast<IrSimpleType>().classifier
|
get() = cast<IrSimpleType>().classifier
|
||||||
|
|
||||||
|
|||||||
Vendored
-2
@@ -1,6 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FIR status: AE: Argument 1: expected R, but found I at INVOKEINTERFACE Sam.get
|
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// SAM_CONVERSIONS: INDY
|
// SAM_CONVERSIONS: INDY
|
||||||
|
|
||||||
|
|||||||
-3
@@ -1,9 +1,6 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND: ANDROID
|
// IGNORE_BACKEND: ANDROID
|
||||||
// ^ uses API not implemented on minSdkVersion 19
|
// ^ uses API not implemented on minSdkVersion 19
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FIR status: fir2ir creates an IrConst(value=2, type=@EnhancedNullability Int), which
|
|
||||||
// the backend generates as an int instead of Integer
|
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
// JVM_TARGET: 1.8
|
// JVM_TARGET: 1.8
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FIR status: AnalyzerException: Argument 1: expected R, but found I
|
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
// FILE: J.java
|
// FILE: J.java
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ FILE fqName:<root> fileName:/enhancedNullability.kt
|
|||||||
s: CALL 'public open fun nullString (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
s: CALL 'public open fun nullString (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||||
CALL 'public open fun use (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
CALL 'public open fun use (s: @[EnhancedNullability] kotlin.String): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
s: CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in <root>.J' type=@[EnhancedNullability] kotlin.String origin=null
|
s: CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in <root>.J' type=@[EnhancedNullability] kotlin.String origin=null
|
||||||
|
CALL 'public open fun use (x: @[EnhancedNullability] kotlin.Int): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
|
||||||
|
x: CONST Int type=kotlin.Int value=42
|
||||||
FUN name:testLocalVarUse visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
FUN name:testLocalVarUse visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
VAR name:ns type:@[FlexibleNullability] kotlin.String? [val]
|
VAR name:ns type:@[FlexibleNullability] kotlin.String? [val]
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ val testGlobalValGetter get() = J.notNullString()
|
|||||||
fun testJUse() {
|
fun testJUse() {
|
||||||
J.use(J.nullString())
|
J.use(J.nullString())
|
||||||
J.use(J.notNullString())
|
J.use(J.notNullString())
|
||||||
|
J.use(42)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testLocalVarUse() {
|
fun testLocalVarUse() {
|
||||||
@@ -36,6 +37,7 @@ import org.jetbrains.annotations.*;
|
|||||||
|
|
||||||
public class J {
|
public class J {
|
||||||
public static void use(@NotNull String s) {}
|
public static void use(@NotNull String s) {}
|
||||||
|
public static void use(@NotNull Integer x) {}
|
||||||
public static String nullString() { return null; }
|
public static String nullString() { return null; }
|
||||||
public static @NotNull String notNullString() { return null; }
|
public static @NotNull String notNullString() { return null; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ val testGlobalValGetter: String
|
|||||||
fun testJUse() {
|
fun testJUse() {
|
||||||
use(s = nullString())
|
use(s = nullString())
|
||||||
use(s = notNullString())
|
use(s = notNullString())
|
||||||
|
use(x = 42)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testLocalVarUse() {
|
fun testLocalVarUse() {
|
||||||
@@ -33,3 +34,4 @@ fun testLocalVarUse() {
|
|||||||
val nns: String = notNullString() /*!! String */
|
val nns: String = notNullString() /*!! String */
|
||||||
use(s = nns)
|
use(s = nns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user