FIR2IR strip FlexibleNullability on IMPLICIT_NOTNULL
This commit is contained in:
+4
-1
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.util.classId
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
|
||||
class Fir2IrImplicitCastInserter(
|
||||
@@ -232,7 +233,9 @@ class Fir2IrImplicitCastInserter(
|
||||
// Cast type massage 1. Remove @EnhancedNullability
|
||||
// Cast type massage 2. Convert it to a non-null variant (in case of @FlexibleNullability)
|
||||
val castType = type.removeAnnotations {
|
||||
it.symbol.owner.parentAsClass.classId == CompilerConeAttributes.EnhancedNullability.ANNOTATION_CLASS_ID
|
||||
val classId = it.symbol.owner.parentAsClass.classId
|
||||
classId == StandardClassIds.Annotations.EnhancedNullability ||
|
||||
classId == StandardClassIds.Annotations.FlexibleNullability
|
||||
}.withHasQuestionMark(false)
|
||||
return IrTypeOperatorCallImpl(
|
||||
this.startOffset,
|
||||
|
||||
Generated
+12
@@ -2901,6 +2901,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullCheckOnInterfaceDelegation.kt")
|
||||
public void testNullCheckOnInterfaceDelegation() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullabilityAssertionOnExtensionReceiver.kt")
|
||||
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
|
||||
@@ -2970,6 +2976,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringVsAny.kt")
|
||||
public void testStringVsAny() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringVsT.kt")
|
||||
public void testStringVsT() throws Exception {
|
||||
|
||||
@@ -77,48 +77,48 @@ fun checkAssertions(illegalStateExpected: Boolean) {
|
||||
val check = AssertionChecker(illegalStateExpected)
|
||||
|
||||
// simple call
|
||||
check("foo") { A().foo() }
|
||||
check("A::foo") { A().foo() }
|
||||
|
||||
// simple static call
|
||||
check("staticFoo") { A.staticFoo() }
|
||||
check("A::staticFoo") { A.staticFoo() }
|
||||
|
||||
// supercall
|
||||
check("foo") { Derived().foo() }
|
||||
// super call
|
||||
check("Derived::foo") { Derived().foo() }
|
||||
|
||||
// delegated call
|
||||
check("foo") { Delegated().foo() }
|
||||
check("Delegated::foo") { Delegated().foo() }
|
||||
|
||||
// collection element
|
||||
check("get") { A()[""] }
|
||||
check("A::get") { A()[""] }
|
||||
|
||||
// binary expression
|
||||
check("plus") { A() + A() }
|
||||
check("A::plus") { A() + A() }
|
||||
|
||||
// field
|
||||
check("NULL") { A().NULL }
|
||||
check("A::NULL") { A().NULL }
|
||||
|
||||
// static field
|
||||
check("STATIC_NULL") { A.STATIC_NULL }
|
||||
check("A::STATIC_NULL") { A.STATIC_NULL }
|
||||
|
||||
// postfix expression
|
||||
// TODO:
|
||||
// check("inc") { var a = A().a(); a++ }
|
||||
// check("A::inc") { var a = A().a(); a++ }
|
||||
|
||||
// prefix expression
|
||||
check("inc-b") { var a = A.B.b(); a++ }
|
||||
check("A::inc-b") { var a = A.B.b(); a++ }
|
||||
|
||||
// prefix expression
|
||||
check("inc-c") { var a = A.C.c(); a++ }
|
||||
check("A::inc-c") { var a = A.C.c(); a++ }
|
||||
|
||||
// prefix expression
|
||||
check("inc") { var a = A().a(); ++a }
|
||||
check("A::inc") { var a = A().a(); ++a }
|
||||
|
||||
// prefix expression
|
||||
check("inc-b") { var a = A.B.b(); ++a }
|
||||
check("A::inc-b") { var a = A.B.b(); ++a }
|
||||
|
||||
// prefix expression
|
||||
// TODO:
|
||||
// check("inc-c") { var a = A.C.c(); ++a }
|
||||
// check("A::inc-c") { var a = A.C.c(); ++a }
|
||||
}
|
||||
|
||||
operator fun A.C.inc(): A.C = A.C()
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
FILE fqName:<root> fileName:/implicitCastOnPlatformType.kt
|
||||
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test (): kotlin.String declared in <root>'
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
CALL 'public open fun getProperty (p0: @[FlexibleNullability] kotlin.String?): @[FlexibleNullability] kotlin.String? declared in java.lang.System' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
p0: CONST String type=kotlin.String value="test"
|
||||
@@ -1,3 +0,0 @@
|
||||
fun test(): String {
|
||||
return getProperty(p0 = "test") /*!! @FlexibleNullability String */
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// TARGET_BACKEND: JVM
|
||||
fun test(): String =
|
||||
System.getProperty("test")
|
||||
Vendored
+1
-1
@@ -18,5 +18,5 @@ FILE fqName:<root> fileName:/implicitNotNullInDestructuringAssignment.kt
|
||||
$receiver: GET_VAR 'val tmp_0: @[FlexibleNullability] <root>.J? [val] declared in <root>.test' type=@[FlexibleNullability] <root>.J? origin=null
|
||||
VAR name:b type:kotlin.Int [val]
|
||||
CALL 'private final fun component2 (): kotlin.Int [operator] declared in <root>' type=kotlin.Int origin=COMPONENT_N(index=2)
|
||||
$receiver: TYPE_OP type=@[FlexibleNullability] <root>.J origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] <root>.J
|
||||
$receiver: TYPE_OP type=<root>.J origin=IMPLICIT_NOTNULL typeOperand=<root>.J
|
||||
GET_VAR 'val tmp_0: @[FlexibleNullability] <root>.J? [val] declared in <root>.test' type=@[FlexibleNullability] <root>.J? origin=null
|
||||
|
||||
Vendored
+2
-1
@@ -9,5 +9,6 @@ private operator fun J.component2(): Int {
|
||||
fun test() {
|
||||
val <destruct>: @FlexibleNullability J? = j()
|
||||
val a: Int = <destruct>.component1()
|
||||
val b: Int = <destruct> /*!! @FlexibleNullability J */.component2()
|
||||
val b: Int = <destruct> /*!! J */.component2()
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ FILE fqName:<root> fileName:/nullCheckOnLambdaReturn.kt
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Any declared in <root>.test1'
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
PROPERTY name:test2 visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function0<kotlin.Any> visibility:private [final,static]
|
||||
|
||||
@@ -12,7 +12,7 @@ fun <T : Any?> id(x: T): T {
|
||||
|
||||
fun test1(): Any {
|
||||
return checkAny(fn = local fun <anonymous>(): Any {
|
||||
return foo() /*!! @FlexibleNullability String */
|
||||
return foo() /*!! String */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ FILE fqName:<root> fileName:/genericSamSmartcast.kt
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.A<*>
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.f' type=kotlin.Any origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun f (x: kotlin.Any): kotlin.String declared in <root>'
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun call (block: @[FlexibleNullability] <root>.A.I<@[FlexibleNullability] T of <root>.A?>?): @[FlexibleNullability] kotlin.String? declared in <root>.A' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
$this: TYPE_OP type=<root>.A<*> origin=IMPLICIT_CAST typeOperand=<root>.A<*>
|
||||
GET_VAR 'x: kotlin.Any declared in <root>.f' type=kotlin.Any origin=null
|
||||
|
||||
@@ -3,7 +3,8 @@ fun f(x: Any): String {
|
||||
x is A<*> -> return x /*as A<*> */.call(block = local fun <anonymous>(y: Any?): @FlexibleNullability String? {
|
||||
return "OK"
|
||||
}
|
||||
/*-> @FlexibleNullability I<@FlexibleNullability Any?>? */) /*!! @FlexibleNullability String */
|
||||
/*-> @FlexibleNullability I<@FlexibleNullability Any?>? */) /*!! String */
|
||||
}
|
||||
return "Fail"
|
||||
}
|
||||
|
||||
|
||||
@@ -33,5 +33,5 @@ FILE fqName:<root> fileName:/samConstructors.kt
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (a: @[FlexibleNullability] kotlin.Int?, b: @[FlexibleNullability] kotlin.Int?): kotlin.Int declared in <root>.test4'
|
||||
CALL 'public final fun minus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=MINUS
|
||||
$this: GET_VAR 'a: @[FlexibleNullability] kotlin.Int? declared in <root>.test4.<anonymous>' type=@[FlexibleNullability] kotlin.Int? origin=null
|
||||
other: TYPE_OP type=@[FlexibleNullability] kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.Int
|
||||
other: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int
|
||||
GET_VAR 'b: @[FlexibleNullability] kotlin.Int? declared in <root>.test4.<anonymous>' type=@[FlexibleNullability] kotlin.Int? origin=null
|
||||
|
||||
@@ -18,7 +18,8 @@ fun test3(): Runnable {
|
||||
|
||||
fun test4(): Comparator<@FlexibleNullability Int?> {
|
||||
return local fun <anonymous>(a: @FlexibleNullability Int?, b: @FlexibleNullability Int?): Int {
|
||||
return a.minus(other = b /*!! @FlexibleNullability Int */)
|
||||
return a.minus(other = b /*!! Int */)
|
||||
}
|
||||
/*-> Comparator<@FlexibleNullability Int?> */
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ FILE fqName:<root> fileName:/JCTreeUser.kt
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.JCTree.JCTypeApply
|
||||
GET_VAR 'var tree: <root>.JCTree [var] declared in <root>.Owner.<get-foo>' type=<root>.JCTree origin=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun <get-foo> (): kotlin.String declared in <root>.Owner'
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:clazz type:@[FlexibleNullability] kotlin.String? visibility:public' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
|
||||
receiver: TYPE_OP type=<root>.JCTree.JCTypeApply origin=IMPLICIT_CAST typeOperand=<root>.JCTree.JCTypeApply
|
||||
GET_VAR 'var tree: <root>.JCTree [var] declared in <root>.Owner.<get-foo>' type=<root>.JCTree origin=null
|
||||
|
||||
@@ -13,9 +13,10 @@ class Owner<out T : JCTree> {
|
||||
get(): String {
|
||||
var tree: JCTree = <this>.<get-tree>()
|
||||
when {
|
||||
tree is JCTypeApply -> return tree /*as JCTypeApply */.#clazz /*!! @FlexibleNullability String */
|
||||
tree is JCTypeApply -> return tree /*as JCTypeApply */.#clazz /*!! String */
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.ir.txt
Vendored
+1
-1
@@ -182,7 +182,7 @@ FILE fqName:<root> fileName:/enhancedNullabilityInDestructuringAssignment.kt
|
||||
<T>: kotlin.collections.IndexedValue<@[EnhancedNullability] <root>.P>
|
||||
$receiver: CALL 'public final fun withIndex <T> (): kotlin.collections.Iterable<kotlin.collections.IndexedValue<T of kotlin.collections.CollectionsKt.withIndex>> declared in kotlin.collections.CollectionsKt' type=kotlin.collections.Iterable<kotlin.collections.IndexedValue<@[EnhancedNullability] <root>.P>> origin=null
|
||||
<T>: @[EnhancedNullability] <root>.P
|
||||
$receiver: TYPE_OP type=@[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] <root>.P> origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] <root>.P>
|
||||
$receiver: TYPE_OP type=kotlin.collections.List<@[EnhancedNullability] <root>.P> origin=IMPLICIT_NOTNULL typeOperand=kotlin.collections.List<@[EnhancedNullability] <root>.P>
|
||||
CALL 'public open fun listOfNotNull (): @[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] <root>.P>? declared in <root>.J' type=@[FlexibleNullability] kotlin.collections.List<@[EnhancedNullability] <root>.P>? origin=null
|
||||
VAR name:x type:kotlin.Int [val]
|
||||
CALL 'public final fun component1 (): kotlin.Int [operator] declared in kotlin.collections.IndexedValue' type=kotlin.Int origin=COMPONENT_N(index=1)
|
||||
|
||||
compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.kt.txt
Vendored
+1
-1
@@ -80,7 +80,7 @@ fun test3() {
|
||||
}
|
||||
|
||||
fun test4() {
|
||||
val <destruct>: IndexedValue<@EnhancedNullability P> = listOfNotNull() /*!! @FlexibleNullability List<@EnhancedNullability P> */.withIndex<@EnhancedNullability P>().first<IndexedValue<@EnhancedNullability P>>()
|
||||
val <destruct>: IndexedValue<@EnhancedNullability P> = listOfNotNull() /*!! List<@EnhancedNullability P> */.withIndex<@EnhancedNullability P>().first<IndexedValue<@EnhancedNullability P>>()
|
||||
val x: Int = <destruct>.component1()
|
||||
val y: @EnhancedNullability P = <destruct>.component2() /*!! P */
|
||||
use(x = x, y = y)
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv
|
||||
CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Double' type=kotlin.Int origin=null
|
||||
$this: CALL 'public open fun null0 (): @[FlexibleNullability] kotlin.Double? declared in <root>.JavaClass' type=@[FlexibleNullability] kotlin.Double? origin=null
|
||||
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToPlatform' type=<root>.JavaClass origin=null
|
||||
other: TYPE_OP type=@[FlexibleNullability] kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.Double
|
||||
other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
|
||||
CALL 'public open fun null0 (): @[FlexibleNullability] kotlin.Double? declared in <root>.JavaClass' type=@[FlexibleNullability] kotlin.Double? origin=null
|
||||
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToPlatform' type=<root>.JavaClass origin=null
|
||||
FUN name:testPlatformCompareToKotlin visibility:public modality:FINAL <> ($receiver:<root>.JavaClass) returnType:kotlin.Int
|
||||
@@ -48,6 +48,6 @@ FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv
|
||||
RETURN type=kotlin.Nothing from='public final fun testKotlinCompareToPlatform (): kotlin.Int declared in <root>'
|
||||
CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int [operator] declared in kotlin.Double' type=kotlin.Int origin=null
|
||||
$this: CONST Double type=kotlin.Double value=0.0
|
||||
other: TYPE_OP type=@[FlexibleNullability] kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.Double
|
||||
other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
|
||||
CALL 'public open fun null0 (): @[FlexibleNullability] kotlin.Double? declared in <root>.JavaClass' type=@[FlexibleNullability] kotlin.Double? origin=null
|
||||
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testKotlinCompareToPlatform' type=<root>.JavaClass origin=null
|
||||
|
||||
+3
-2
@@ -11,7 +11,7 @@ fun JavaClass.testKotlinEqualsPlatform(): Boolean {
|
||||
}
|
||||
|
||||
fun JavaClass.testPlatformCompareToPlatform(): Int {
|
||||
return <this>.null0().compareTo(other = <this>.null0() /*!! @FlexibleNullability Double */)
|
||||
return <this>.null0().compareTo(other = <this>.null0() /*!! Double */)
|
||||
}
|
||||
|
||||
fun JavaClass.testPlatformCompareToKotlin(): Int {
|
||||
@@ -19,5 +19,6 @@ fun JavaClass.testPlatformCompareToKotlin(): Int {
|
||||
}
|
||||
|
||||
fun JavaClass.testKotlinCompareToPlatform(): Int {
|
||||
return 0.0.compareTo(other = <this>.null0() /*!! @FlexibleNullability Double */)
|
||||
return 0.0.compareTo(other = <this>.null0() /*!! Double */)
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -65,10 +65,10 @@ FILE fqName:<root> fileName:/implicitNotNullOnPlatformType.kt
|
||||
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
s: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
s: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
s: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
|
||||
FUN name:testContains visibility:public modality:FINAL <> (m:<root>.MySet) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:m index:0 type:<root>.MySet
|
||||
@@ -76,7 +76,7 @@ FILE fqName:<root> fileName:/implicitNotNullOnPlatformType.kt
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in <root>.MySet' type=kotlin.Boolean origin=null
|
||||
$this: GET_VAR 'm: <root>.MySet declared in <root>.testContains' type=<root>.MySet origin=null
|
||||
element: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
element: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun contains (element: kotlin.String): kotlin.Boolean [operator] declared in <root>.MySet' type=kotlin.Boolean origin=null
|
||||
|
||||
+3
-3
@@ -32,11 +32,11 @@ class MySet : Set<String> {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
f(s = s() /*!! @FlexibleNullability String */)
|
||||
f(s = #STRING /*!! @FlexibleNullability String */)
|
||||
f(s = s() /*!! String */)
|
||||
f(s = #STRING /*!! String */)
|
||||
}
|
||||
|
||||
fun testContains(m: MySet) {
|
||||
m.contains(element = #STRING /*!! @FlexibleNullability String */) /*~> Unit */
|
||||
m.contains(element = #STRING /*!! String */) /*~> Unit */
|
||||
m.contains(element = "abc") /*~> Unit */
|
||||
}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
Module: lib
|
||||
Module: main
|
||||
FILE fqName:<root> fileName:/nullCheckOnInterfaceDelegation.kt
|
||||
CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IFoo
|
||||
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[<root>.A; <root>.IFoo]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Derived
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Derived [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[<root>.A; <root>.IFoo]'
|
||||
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.Derived) returnType:@[FlexibleNullability] kotlin.String?
|
||||
overridden:
|
||||
public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.A
|
||||
public abstract fun foo (): kotlin.String declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.Derived'
|
||||
CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.A' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
$this: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.foo' type=<root>.Derived origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Delegated
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Delegated [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]'
|
||||
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Delegated) returnType:kotlin.String
|
||||
overridden:
|
||||
public abstract fun foo (): kotlin.String declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Delegated
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.Delegated'
|
||||
CALL 'public abstract fun foo (): kotlin.String declared in <root>.IFoo' type=kotlin.String origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:<root>.IFoo visibility:local [final]' type=<root>.IFoo origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Delegated declared in <root>.Delegated.foo' type=<root>.Delegated origin=null
|
||||
FIELD DELEGATE name:<$$delegate_0> type:<root>.IFoo visibility:local [final]
|
||||
EXPRESSION_BODY
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Derived' type=<root>.Derived origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:testReturnValue visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testReturnValue (): kotlin.String declared in <root>'
|
||||
CALL 'public open fun foo (): kotlin.String declared in <root>.Delegated' type=kotlin.String origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Delegated' type=<root>.Delegated origin=null
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// MODULE: lib
|
||||
// MODULE: main
|
||||
// FILE: nullCheckOnInterfaceDelegation.kt
|
||||
|
||||
interface IFoo {
|
||||
abstract fun foo(): String
|
||||
|
||||
}
|
||||
|
||||
class Derived : A, IFoo {
|
||||
constructor() /* primary */ {
|
||||
super/*A*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
override fun foo(): @FlexibleNullability String? {
|
||||
return super.foo()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Delegated : IFoo {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
override fun foo(): String {
|
||||
return <this>.#<$$delegate_0>.foo()
|
||||
}
|
||||
|
||||
local /* final field */ val <$$delegate_0>: IFoo = Derived()
|
||||
|
||||
}
|
||||
|
||||
fun testReturnValue(): String {
|
||||
return Delegated().foo()
|
||||
}
|
||||
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
Module: lib
|
||||
Module: main
|
||||
FILE fqName:<root> fileName:/nullCheckOnInterfaceDelegation.kt
|
||||
CLASS INTERFACE name:IFoo modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IFoo
|
||||
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IFoo) returnType:kotlin.String
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IFoo
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[<root>.A; <root>.IFoo]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Derived
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Derived [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.A'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived modality:FINAL visibility:public superTypes:[<root>.A; <root>.IFoo]'
|
||||
FUN name:foo visibility:public modality:OPEN <> ($this:<root>.Derived) returnType:@[FlexibleNullability] kotlin.String?
|
||||
overridden:
|
||||
public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.A
|
||||
public abstract fun foo (): kotlin.String declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Derived
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.Derived'
|
||||
CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.A' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:A modality:OPEN visibility:public superTypes:[kotlin.Any]' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
$this: GET_VAR '<this>: <root>.Derived declared in <root>.Derived.foo' type=<root>.Derived origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.A
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.A
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.A
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Delegated
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Delegated [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegated modality:FINAL visibility:public superTypes:[<root>.IFoo]'
|
||||
FIELD DELEGATE name:$$delegate_0 type:<root>.Derived visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Derived' type=<root>.Derived origin=null
|
||||
FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN <> ($this:<root>.Delegated) returnType:kotlin.String
|
||||
overridden:
|
||||
public abstract fun foo (): kotlin.String declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Delegated
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public open fun foo (): kotlin.String declared in <root>.Delegated'
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun foo (): @[FlexibleNullability] kotlin.String? declared in <root>.Derived' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
$this: GET_FIELD 'FIELD DELEGATE name:$$delegate_0 type:<root>.Derived visibility:private [final]' type=<root>.Derived origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Delegated declared in <root>.Delegated.foo' type=<root>.Delegated origin=null
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String [fake_override] declared in <root>.IFoo
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:testReturnValue visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testReturnValue (): kotlin.String declared in <root>'
|
||||
CALL 'public open fun foo (): kotlin.String declared in <root>.Delegated' type=kotlin.String origin=null
|
||||
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Delegated' type=<root>.Delegated origin=null
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public String foo() { return null; }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: nullCheckOnInterfaceDelegation.kt
|
||||
interface IFoo {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
class Derived : A(), IFoo {
|
||||
override fun foo() = super<A>.foo()
|
||||
}
|
||||
|
||||
class Delegated : IFoo by Derived()
|
||||
|
||||
fun testReturnValue(): String =
|
||||
Delegated().foo()
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// MODULE: lib
|
||||
// MODULE: main
|
||||
// FILE: nullCheckOnInterfaceDelegation.kt
|
||||
|
||||
interface IFoo {
|
||||
abstract fun foo(): String
|
||||
|
||||
}
|
||||
|
||||
class Derived : A, IFoo {
|
||||
constructor() /* primary */ {
|
||||
super/*A*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
override fun foo(): @FlexibleNullability String? {
|
||||
return super.foo()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Delegated : IFoo {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
private /* final field */ val $$delegate_0: Derived = Derived()
|
||||
override fun foo(): String {
|
||||
return <this>.#$$delegate_0.foo() /*!! String */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun testReturnValue(): String {
|
||||
return Delegated().foo()
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
FILE fqName:<root> fileName:/stringVsAny.kt
|
||||
FUN name:useAny visibility:public modality:FINAL <> (fn:kotlin.Function0<kotlin.Any>) returnType:kotlin.Any
|
||||
VALUE_PARAMETER name:fn index:0 type:kotlin.Function0<kotlin.Any>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun useAny (fn: kotlin.Function0<kotlin.Any>): kotlin.Any declared in <root>'
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Any origin=INVOKE
|
||||
$this: GET_VAR 'fn: kotlin.Function0<kotlin.Any> declared in <root>.useAny' type=kotlin.Function0<kotlin.Any> origin=VARIABLE_AS_FUNCTION
|
||||
FUN name:testNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun useAny (fn: kotlin.Function0<kotlin.Any>): kotlin.Any declared in <root>' type=kotlin.Any origin=null
|
||||
fn: FUN_EXPR type=kotlin.Function0<kotlin.Any> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Any declared in <root>.testNullCheck'
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FIR_IDENTICAL
|
||||
// FILE: stringVsAny.kt
|
||||
fun useAny(fn: () -> Any) = fn()
|
||||
|
||||
fun testNullCheck() {
|
||||
useAny { J.string() }
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class J {
|
||||
public static String string() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static @NotNull String notNullString() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun useAny(fn: Function0<Any>): Any {
|
||||
return fn.invoke()
|
||||
}
|
||||
|
||||
fun testNullCheck() {
|
||||
useAny(fn = local fun <anonymous>(): Any {
|
||||
return string() /*!! String */
|
||||
}
|
||||
) /*~> Unit */
|
||||
}
|
||||
|
||||
compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.ir.txt
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
FILE fqName:<root> fileName:/stringVsTConstrained.kt
|
||||
FUN name:useTConstrained visibility:public modality:FINAL <T> (xs:kotlin.Array<T of <root>.useTConstrained>, fn:kotlin.Function0<T of <root>.useTConstrained>) returnType:T of <root>.useTConstrained
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
VALUE_PARAMETER name:xs index:0 type:kotlin.Array<T of <root>.useTConstrained>
|
||||
VALUE_PARAMETER name:fn index:1 type:kotlin.Function0<T of <root>.useTConstrained>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun useTConstrained <T> (xs: kotlin.Array<T of <root>.useTConstrained>, fn: kotlin.Function0<T of <root>.useTConstrained>): T of <root>.useTConstrained declared in <root>'
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of <root>.useTConstrained origin=INVOKE
|
||||
$this: GET_VAR 'fn: kotlin.Function0<T of <root>.useTConstrained> declared in <root>.useTConstrained' type=kotlin.Function0<T of <root>.useTConstrained> origin=VARIABLE_AS_FUNCTION
|
||||
FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array<kotlin.String>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:xs index:0 type:kotlin.Array<kotlin.String>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun useTConstrained <T> (xs: kotlin.Array<T of <root>.useTConstrained>, fn: kotlin.Function0<T of <root>.useTConstrained>): T of <root>.useTConstrained declared in <root>' type=kotlin.String origin=null
|
||||
<T>: kotlin.String
|
||||
xs: GET_VAR 'xs: kotlin.Array<kotlin.String> declared in <root>.testWithNullCheck' type=kotlin.Array<kotlin.String> origin=null
|
||||
fn: FUN_EXPR type=kotlin.Function0<kotlin.String> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.String declared in <root>.testWithNullCheck'
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.kt.txt
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
fun <T : Any?> useTConstrained(xs: Array<T>, fn: Function0<T>): T {
|
||||
return fn.invoke()
|
||||
}
|
||||
|
||||
fun testWithNullCheck(xs: Array<String>) {
|
||||
useTConstrained<String>(xs = xs, fn = local fun <anonymous>(): String {
|
||||
return string() /*!! @FlexibleNullability String */
|
||||
}
|
||||
) /*~> Unit */
|
||||
}
|
||||
Vendored
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: stringVsTConstrained.kt
|
||||
fun <T> useTConstrained(xs: Array<T>, fn: () -> T) = fn()
|
||||
|
||||
Vendored
-39
@@ -1,39 +0,0 @@
|
||||
FILE fqName:<root> fileName:/nullabilityAssertionOnExtensionReceiver.kt
|
||||
FUN name:extension visibility:public modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
|
||||
BLOCK_BODY
|
||||
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.C [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||
FUN name:memberExtension visibility:public modality:FINAL <> ($this:<root>.C, $receiver:kotlin.String) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
|
||||
BLOCK_BODY
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
|
||||
overridden:
|
||||
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
|
||||
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
|
||||
overridden:
|
||||
public open fun hashCode (): kotlin.Int declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
|
||||
overridden:
|
||||
public open fun toString (): kotlin.String declared in kotlin.Any
|
||||
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
|
||||
FUN name:testExt visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun extension (): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
|
||||
$receiver: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
FUN name:testMemberExt visibility:public modality:FINAL <> ($receiver:<root>.C) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun memberExtension (): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR '<this>: <root>.C declared in <root>.testMemberExt' type=<root>.C origin=null
|
||||
$receiver: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
fun String.extension() {
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
fun String.memberExtension() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun testExt() {
|
||||
s() /*!! @FlexibleNullability String */.extension()
|
||||
}
|
||||
|
||||
fun C.testMemberExt() {
|
||||
(<this>, s() /*!! @FlexibleNullability String */).memberExtension()
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: nullabilityAssertionOnExtensionReceiver.kt
|
||||
|
||||
|
||||
+2
-2
@@ -12,10 +12,10 @@ FILE fqName:<root> fileName:/typeParameterWithMixedNullableAndNotNullableBounds.
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun f <T> (x: T of <root>.f): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
<T>: @[FlexibleNullability] kotlin.String?
|
||||
x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun f <T> (x: T of <root>.f): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
<T>: @[FlexibleNullability] kotlin.String?
|
||||
x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
|
||||
|
||||
+3
-2
@@ -3,6 +3,7 @@ fun <T> f(x: T): Int where T : CharSequence?, T : Comparable<T> {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
f<@FlexibleNullability String?>(x = s() /*!! @FlexibleNullability String */) /*~> Unit */
|
||||
f<@FlexibleNullability String?>(x = #STRING /*!! @FlexibleNullability String */) /*~> Unit */
|
||||
f<@FlexibleNullability String?>(x = s() /*!! String */) /*~> Unit */
|
||||
f<@FlexibleNullability String?>(x = #STRING /*!! String */) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -12,10 +12,10 @@ FILE fqName:<root> fileName:/typeParameterWithMultipleNotNullableBounds.kt
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun f <T> (x: T of <root>.f): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
<T>: @[FlexibleNullability] kotlin.String?
|
||||
x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun s (): @[FlexibleNullability] kotlin.String? declared in <root>.J' type=@[FlexibleNullability] kotlin.String? origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun f <T> (x: T of <root>.f): kotlin.Int declared in <root>' type=kotlin.Int origin=null
|
||||
<T>: @[FlexibleNullability] kotlin.String?
|
||||
x: TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
x: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:@[FlexibleNullability] kotlin.String? visibility:public [static]' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
|
||||
|
||||
Vendored
+3
-2
@@ -3,6 +3,7 @@ fun <T> f(x: T): Int where T : CharSequence, T : Comparable<T> {
|
||||
}
|
||||
|
||||
fun test() {
|
||||
f<@FlexibleNullability String?>(x = s() /*!! @FlexibleNullability String */) /*~> Unit */
|
||||
f<@FlexibleNullability String?>(x = #STRING /*!! @FlexibleNullability String */) /*~> Unit */
|
||||
f<@FlexibleNullability String?>(x = s() /*!! String */) /*~> Unit */
|
||||
f<@FlexibleNullability String?>(x = #STRING /*!! String */) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ FILE fqName:<root> fileName:/smartCastOnFieldReceiverOfGenericType.kt
|
||||
TYPE_OP type=<root>.JCell<kotlin.String> origin=CAST typeOperand=<root>.JCell<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testGetField' type=kotlin.Any origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun testGetField (a: kotlin.Any): kotlin.String declared in <root>'
|
||||
TYPE_OP type=@[FlexibleNullability] kotlin.String origin=IMPLICIT_NOTNULL typeOperand=@[FlexibleNullability] kotlin.String
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:@[FlexibleNullability] T of <root>.JCell? visibility:public' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
|
||||
receiver: TYPE_OP type=<root>.JCell<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.JCell<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testGetField' type=kotlin.Any origin=null
|
||||
|
||||
+2
-1
@@ -6,5 +6,6 @@ fun testSetField(a: Any, b: Any) {
|
||||
|
||||
fun testGetField(a: Any): String {
|
||||
a as JCell<String> /*~> Unit */
|
||||
return a /*as JCell<String> */.#value /*!! @FlexibleNullability String */
|
||||
return a /*as JCell<String> */.#value /*!! String */
|
||||
}
|
||||
|
||||
|
||||
Generated
+12
@@ -2901,6 +2901,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/implicitNotNullOnPlatformType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullCheckOnInterfaceDelegation.kt")
|
||||
public void testNullCheckOnInterfaceDelegation() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnInterfaceDelegation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullabilityAssertionOnExtensionReceiver.kt")
|
||||
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
|
||||
@@ -2970,6 +2976,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringVsAny.kt")
|
||||
public void testStringVsAny() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsAny.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("stringVsT.kt")
|
||||
public void testStringVsT() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user