Clarify comments about KT-36625 that it is pending design decision.
This commit is contained in:
committed by
Dmitry Petrov
parent
ba606147c9
commit
89cf32eccc
+4
-4
@@ -114,10 +114,10 @@ private class JvmStringConcatenationLowering(val context: JvmBackendContext) : F
|
|||||||
override fun visitStringConcatenation(expression: IrStringConcatenation): IrExpression {
|
override fun visitStringConcatenation(expression: IrStringConcatenation): IrExpression {
|
||||||
expression.transformChildrenVoid(this)
|
expression.transformChildrenVoid(this)
|
||||||
return context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset).run {
|
return context.createJvmIrBuilder(currentScope!!.scope.scopeOwnerSymbol, expression.startOffset, expression.endOffset).run {
|
||||||
// When `String.plus(Any?)` is invoked with receiver of platform type String or String with enhanced nullability, this SHOULD
|
// When `String.plus(Any?)` is invoked with receiver of platform type String or String with enhanced nullability, this could
|
||||||
// fail a nullability check (NullPointerException) on the receiver. However, the non-IR backend has a bug (KT-36625) where this
|
// fail a nullability check (NullPointerException) on the receiver. However, the non-IR backend currently does NOT insert this
|
||||||
// check is not inserted (see KT-36625). To maintain bug compatibility with the non-IR backend, we remove IMPLICIT_NOTNULL casts
|
// check (see KT-36625, pending language design decision). To maintain compatibility with the non-IR backend, we remove
|
||||||
// (which generate the nullability checks in JvmArgumentNullabilityAssertionsLowering) from all arguments.
|
// IMPLICIT_NOTNULL casts from all arguments (nullability checks are generated in JvmArgumentNullabilityAssertionsLowering).
|
||||||
|
|
||||||
fun IrExpression.unwrapImplicitNotNull() =
|
fun IrExpression.unwrapImplicitNotNull() =
|
||||||
if (this is IrTypeOperatorCall && operator == IrTypeOperator.IMPLICIT_NOTNULL)
|
if (this is IrTypeOperatorCall && operator == IrTypeOperator.IMPLICIT_NOTNULL)
|
||||||
|
|||||||
@@ -36,13 +36,14 @@ public class J {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILE: main.kt
|
// FILE: stringFromJavaPlus.kt
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
fun box(): String {
|
fun box(): String {
|
||||||
val n = 123
|
val n = 123
|
||||||
|
|
||||||
// Due to KT-36625, certain concatenation calls below (marked with a comment) SHOULD fail a nullability check but do not.
|
// Null check behavior in string concatenation might change depending on language design decision for KT-36625.
|
||||||
|
// Cases below that could be affected by KT-36625 are marked with a comment.
|
||||||
|
|
||||||
assertEquals("null", "${J.platformStringIsNull()}")
|
assertEquals("null", "${J.platformStringIsNull()}")
|
||||||
assertEquals("nullBAR", J.platformStringIsNull() + "BAR") // KT-36625
|
assertEquals("nullBAR", J.platformStringIsNull() + "BAR") // KT-36625
|
||||||
|
|||||||
Reference in New Issue
Block a user