PSI2IR: Generate IMPLICIT_NOTNULL casts for platform type values

This commit is contained in:
Dmitry Petrov
2019-11-22 14:15:08 +03:00
parent dabf6376db
commit 20fb519f1a
25 changed files with 264 additions and 49 deletions
@@ -861,6 +861,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/expressions/equality.kt");
}
@TestMetadata("equals.kt")
public void testEquals() throws Exception {
runTest("compiler/testData/ir/irText/expressions/equals.kt");
}
@TestMetadata("extFunInvokeAsFun.kt")
public void testExtFunInvokeAsFun() throws Exception {
runTest("compiler/testData/ir/irText/expressions/extFunInvokeAsFun.kt");
@@ -946,6 +951,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt");
}
@TestMetadata("implicitNotNullInDestructuringAssignment.kt")
public void testImplicitNotNullInDestructuringAssignment() throws Exception {
runTest("compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt");
}
@TestMetadata("in.kt")
public void testIn() throws Exception {
runTest("compiler/testData/ir/irText/expressions/in.kt");
@@ -1670,6 +1680,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt");
}
@TestMetadata("implicitNotNullOnPlatformType.kt")
public void testImplicitNotNullOnPlatformType() throws Exception {
runTest("compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt");
}
@TestMetadata("intersectionType1_NI.kt")
public void testIntersectionType1_NI() throws Exception {
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
import org.jetbrains.kotlin.ir.util.TypeTranslator
import org.jetbrains.kotlin.ir.util.coerceToUnitIfNeeded
import org.jetbrains.kotlin.ir.util.render
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
import org.jetbrains.kotlin.psi2ir.containsNull
import org.jetbrains.kotlin.psi2ir.generators.GeneratorContext
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.ir.types.impl
import org.jetbrains.kotlin.ir.expressions.IrCall
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.types.KotlinType
@@ -59,18 +59,18 @@ class TypeTranslator(
?: symbolTable.referenceTypeParameter(typeParameterDescriptor)
fun translateType(kotlinType: KotlinType): IrType =
translateType(kotlinType, Variance.INVARIANT).type
translateType(kotlinType, kotlinType, Variance.INVARIANT).type
private fun translateType(kotlinType: KotlinType, variance: Variance): IrTypeProjection {
private fun translateType(kotlinType: KotlinType, approximatedKotlinType: KotlinType, variance: Variance): IrTypeProjection {
val approximatedType = LegacyTypeApproximation().approximate(kotlinType)
when {
approximatedType.isError ->
return IrErrorTypeImpl(approximatedType, translateTypeAnnotations(approximatedType.annotations), variance)
return IrErrorTypeImpl(approximatedKotlinType, translateTypeAnnotations(approximatedType.annotations), variance)
approximatedType.isDynamic() ->
return IrDynamicTypeImpl(approximatedType, translateTypeAnnotations(approximatedType.annotations), variance)
return IrDynamicTypeImpl(approximatedKotlinType, translateTypeAnnotations(approximatedType.annotations), variance)
approximatedType.isFlexible() ->
return translateType(approximatedType.upperIfFlexible(), variance)
return translateType(approximatedType.upperIfFlexible(), approximatedType, variance)
}
val ktTypeConstructor = approximatedType.constructor
@@ -78,7 +78,7 @@ class TypeTranslator(
?: throw AssertionError("No descriptor for type $approximatedType")
return IrSimpleTypeBuilder().apply {
this.kotlinType = kotlinType
this.kotlinType = approximatedKotlinType
hasQuestionMark = approximatedType.isMarkedNullable
this.variance = variance
this.abbreviation = approximatedType.getAbbreviation()?.toIrTypeAbbreviation()
@@ -154,6 +154,6 @@ class TypeTranslator(
if (it.isStarProjection)
IrStarProjectionImpl
else
translateType(it.type, it.projectionKind)
translateType(it.type, it.type, it.projectionKind)
}
}
+4 -2
View File
@@ -34,7 +34,8 @@ FILE fqName:<root> fileName:/coercionToUnit.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_VAR 'val tmp_0: java.io.PrintStream? [val] declared in <root>.test3' type=java.io.PrintStream? origin=null
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_VAR 'val tmp_0: java.io.PrintStream? [val] declared in <root>.test3' type=java.io.PrintStream? origin=null
p0: CONST String type=kotlin.String value="Hello,"
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
BLOCK type=kotlin.Unit? origin=SAFE_CALL
@@ -49,5 +50,6 @@ FILE fqName:<root> fileName:/coercionToUnit.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_VAR 'val tmp_1: java.io.PrintStream? [val] declared in <root>.test3' type=java.io.PrintStream? origin=null
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_VAR 'val tmp_1: java.io.PrintStream? [val] declared in <root>.test3' type=java.io.PrintStream? origin=null
p0: CONST String type=kotlin.String value="world!"
+29
View File
@@ -0,0 +1,29 @@
FILE fqName:<root> fileName:/equals.kt
FUN name:testEqeq visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean
VALUE_PARAMETER name:a index:0 type:kotlin.Int
VALUE_PARAMETER name:b index:1 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testEqeq (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in <root>'
CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'a: kotlin.Int declared in <root>.testEqeq' type=kotlin.Int origin=null
arg1: GET_VAR 'b: kotlin.Int declared in <root>.testEqeq' type=kotlin.Int origin=null
FUN name:testEquals visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean
VALUE_PARAMETER name:a index:0 type:kotlin.Int
VALUE_PARAMETER name:b index:1 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testEquals (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any' type=kotlin.Boolean origin=null
$this: GET_VAR 'a: kotlin.Int declared in <root>.testEquals' type=kotlin.Int origin=null
other: GET_VAR 'b: kotlin.Int declared in <root>.testEquals' type=kotlin.Int origin=null
FUN name:testJEqeqNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testJEqeqNull (): kotlin.Boolean declared in <root>'
CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY
arg1: CONST Null type=kotlin.Nothing? value=null
FUN name:testJEqualsNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testJEqualsNull (): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any' type=kotlin.Boolean origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY
other: CONST Null type=kotlin.Nothing? value=null
+12
View File
@@ -0,0 +1,12 @@
// FILE: equals.kt
fun testEqeq(a: Int, b: Int) = a == b
fun testEquals(a: Int, b: Int) = a.equals(b)
fun testJEqeqNull() = J.INT_NULL == null
fun testJEqualsNull() = J.INT_NULL.equals(null)
// FILE: J.java
public class J {
public static Integer INT_NULL = null;
}
+30
View File
@@ -0,0 +1,30 @@
FILE fqName:<root> fileName:/equals.kt
FUN name:testEqeq visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean
VALUE_PARAMETER name:a index:0 type:kotlin.Int
VALUE_PARAMETER name:b index:1 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testEqeq (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in <root>'
CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'a: kotlin.Int declared in <root>.testEqeq' type=kotlin.Int origin=null
arg1: GET_VAR 'b: kotlin.Int declared in <root>.testEqeq' type=kotlin.Int origin=null
FUN name:testEquals visibility:public modality:FINAL <> (a:kotlin.Int, b:kotlin.Int) returnType:kotlin.Boolean
VALUE_PARAMETER name:a index:0 type:kotlin.Int
VALUE_PARAMETER name:b index:1 type:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testEquals (a: kotlin.Int, b: kotlin.Int): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override] declared in kotlin.Int' type=kotlin.Boolean origin=null
$this: GET_VAR 'a: kotlin.Int declared in <root>.testEquals' type=kotlin.Int origin=null
other: GET_VAR 'b: kotlin.Int declared in <root>.testEquals' type=kotlin.Int origin=null
FUN name:testJEqeqNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testJEqeqNull (): kotlin.Boolean declared in <root>'
CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY
arg1: CONST Null type=kotlin.Nothing? value=null
FUN name:testJEqualsNull visibility:public modality:FINAL <> () returnType:kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testJEqualsNull (): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override] declared in kotlin.Int' type=kotlin.Boolean origin=null
$this: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:INT_NULL type:kotlin.Int? visibility:public [static]' type=kotlin.Int? origin=GET_PROPERTY
other: CONST Null type=kotlin.Nothing? value=null
@@ -2,5 +2,5 @@ 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>'
CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? [operator] declared in java.lang.System' type=kotlin.String? origin=null
CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null
p0: CONST String type=kotlin.String value="test"
@@ -2,5 +2,6 @@ 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>'
CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null
p0: CONST String type=kotlin.String value="test"
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public open fun getProperty (p0: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null
p0: CONST String type=kotlin.String value="test"
@@ -0,0 +1,21 @@
FILE fqName:<root> fileName:/implicitNotNullInDestructuringAssignment.kt
FUN name:component1 visibility:public modality:FINAL <> ($receiver:<root>.J?) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.J?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in <root>'
CONST Int type=kotlin.Int value=1
FUN name:component2 visibility:private modality:FINAL <> ($receiver:<root>.J) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.J
BLOCK_BODY
RETURN type=kotlin.Nothing from='private final fun component2 (): kotlin.Int declared in <root>'
CONST Int type=kotlin.Int value=2
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.J? [val]
CALL 'public open fun j (): <root>.J? declared in <root>.J' type=<root>.J? origin=null
VAR name:a type:kotlin.Int [val]
CALL 'public final fun component1 (): kotlin.Int declared in <root>' type=kotlin.Int origin=null
$receiver: GET_VAR 'val tmp_0: <root>.J? [val] declared in <root>.test' type=<root>.J? origin=null
VAR name:b type:kotlin.Int [val]
CALL 'private final fun component2 (): kotlin.Int declared in <root>' type=kotlin.Int origin=null
$receiver: GET_VAR 'val tmp_0: <root>.J? [val] declared in <root>.test' type=<root>.J? origin=null
@@ -0,0 +1,15 @@
// FILE: implicitNotNullInDestructuringAssignment.kt
// NB extension receiver is nullable
operator fun J?.component1() = 1
private operator fun J.component2() = 2
fun test() {
val (a, b) = J.j()
}
// FILE: J.java
public class J {
public static J j() { return null; }
}
@@ -0,0 +1,23 @@
FILE fqName:<root> fileName:/implicitNotNullInDestructuringAssignment.kt
FUN name:component1 visibility:public modality:FINAL <> ($receiver:<root>.J?) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.J?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Int declared in <root>'
CONST Int type=kotlin.Int value=1
FUN name:component2 visibility:private modality:FINAL <> ($receiver:<root>.J) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.J
BLOCK_BODY
RETURN type=kotlin.Nothing from='private final fun component2 (): kotlin.Int declared in <root>'
CONST Int type=kotlin.Int value=2
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.J? [val]
CALL 'public open fun j (): <root>.J? declared in <root>.J' type=<root>.J? origin=null
VAR name:a type:kotlin.Int [val]
CALL 'public final fun component1 (): kotlin.Int declared in <root>' type=kotlin.Int origin=COMPONENT_N(index=1)
$receiver: GET_VAR 'val tmp_0: <root>.J? [val] declared in <root>.test' type=<root>.J? origin=null
VAR name:b type:kotlin.Int [val]
CALL 'private final fun component2 (): kotlin.Int declared in <root>' type=kotlin.Int origin=COMPONENT_N(index=2)
$receiver: TYPE_OP type=<root>.J origin=IMPLICIT_NOTNULL typeOperand=<root>.J
GET_VAR 'val tmp_0: <root>.J? [val] declared in <root>.test' type=<root>.J? origin=null
@@ -1,14 +1,14 @@
FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
FUN name:testFun visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="testFun"
PROPERTY name:testProp visibility:public modality:FINAL [var]
FUN name:<get-testProp> visibility:public modality:FINAL <> () returnType:kotlin.Any
correspondingProperty: PROPERTY name:testProp visibility:public modality:FINAL [var]
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="testProp/get"
RETURN type=kotlin.Nothing from='public final fun <get-testProp> (): kotlin.Any declared in <root>'
@@ -17,7 +17,7 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
correspondingProperty: PROPERTY name:testProp visibility:public modality:FINAL [var]
VALUE_PARAMETER name:value index:0 type:kotlin.Any
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="testProp/set"
CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any]
@@ -33,7 +33,7 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Int origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="TestClass/test"
CONST Int type=kotlin.Int value=42
@@ -46,12 +46,12 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
receiver: GET_VAR '<this>: <root>.TestClass declared in <root>.TestClass.<get-test>' type=<root>.TestClass origin=null
ANONYMOUS_INITIALIZER isStatic=false
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit [operator] declared in java.io.PrintStream' type=kotlin.Unit origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="TestClass/init"
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
public open fun equals (other: kotlin.Any?): kotlin.Boolean 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]
@@ -2,14 +2,16 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
FUN name:testFun visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="testFun"
PROPERTY name:testProp visibility:public modality:FINAL [var]
FUN name:<get-testProp> visibility:public modality:FINAL <> () returnType:kotlin.Any
correspondingProperty: PROPERTY name:testProp visibility:public modality:FINAL [var]
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="testProp/get"
RETURN type=kotlin.Nothing from='public final fun <get-testProp> (): kotlin.Any declared in <root>'
CONST Int type=kotlin.Int value=42
@@ -18,7 +20,8 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
VALUE_PARAMETER name:value index:0 type:kotlin.Any
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="testProp/set"
CLASS CLASS name:TestClass modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestClass
@@ -34,7 +37,8 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Int origin=null
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="TestClass/test"
CONST Int type=kotlin.Int value=42
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test> visibility:public modality:FINAL <> ($this:<root>.TestClass) returnType:kotlin.Int
@@ -47,7 +51,8 @@ FILE fqName:<root> fileName:/jvmStaticFieldReference.kt
ANONYMOUS_INITIALIZER isStatic=false
BLOCK_BODY
CALL 'public open fun println (p0: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
$this: TYPE_OP type=java.io.PrintStream origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:out type:java.io.PrintStream? visibility:public [final,static]' type=java.io.PrintStream? origin=GET_PROPERTY
p0: CONST String type=kotlin.String value="TestClass/init"
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
@@ -32,5 +32,7 @@ FILE fqName:<root> fileName:/samConstructors.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (a: kotlin.Int?, b: 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: kotlin.Int? declared in <root>.test4.<anonymous>' type=kotlin.Int? origin=null
other: GET_VAR 'b: kotlin.Int? declared in <root>.test4.<anonymous>' type=kotlin.Int? origin=null
$this: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int
GET_VAR 'a: kotlin.Int? declared in <root>.test4.<anonymous>' type=kotlin.Int? origin=null
other: TYPE_OP type=kotlin.Int origin=IMPLICIT_NOTNULL typeOperand=kotlin.Int
GET_VAR 'b: kotlin.Int? declared in <root>.test4.<anonymous>' type=kotlin.Int? origin=null
@@ -106,9 +106,10 @@ FILE fqName:<root> fileName:/samConversionsWithSmartCasts.kt
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
$this: CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.J' type=<root>.J origin=null
r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable?
CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null
<T>: kotlin.Function0<kotlin.Unit>?
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
TYPE_OP type=kotlin.Function0<kotlin.Unit> origin=IMPLICIT_NOTNULL typeOperand=kotlin.Function0<kotlin.Unit>
CALL 'public open fun id <T> (x: T of <root>.J.id?): T of <root>.J.id? declared in <root>.J' type=kotlin.Function0<kotlin.Unit>? origin=null
<T>: kotlin.Function0<kotlin.Unit>?
x: GET_VAR 'a: kotlin.Function0<kotlin.Unit> declared in <root>.test8' type=kotlin.Function0<kotlin.Unit> origin=null
FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in <root>.J' type=kotlin.Unit origin=null
@@ -4,8 +4,9 @@ FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testPlatformEqualsPlatform (): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Double' type=kotlin.Boolean origin=null
$this: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformEqualsPlatform' type=<root>.JavaClass origin=null
$this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformEqualsPlatform' type=<root>.JavaClass origin=null
other: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformEqualsPlatform' type=<root>.JavaClass origin=null
FUN name:testPlatformEqualsKotlin visibility:public modality:FINAL <> ($receiver:<root>.JavaClass) returnType:kotlin.Boolean
@@ -13,8 +14,9 @@ FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testPlatformEqualsKotlin (): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Double' type=kotlin.Boolean origin=null
$this: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformEqualsKotlin' type=<root>.JavaClass origin=null
$this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformEqualsKotlin' type=<root>.JavaClass origin=null
other: CONST Double type=kotlin.Double value=0.0
FUN name:testKotlinEqualsPlatform visibility:public modality:FINAL <> ($receiver:<root>.JavaClass) returnType:kotlin.Boolean
$receiver: VALUE_PARAMETER name:<this> type:<root>.JavaClass
@@ -29,17 +31,20 @@ FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiv
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testPlatformCompareToPlatform (): 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: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToPlatform' type=<root>.JavaClass origin=null
other: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToPlatform' type=<root>.JavaClass origin=null
$this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToPlatform' type=<root>.JavaClass origin=null
other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=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
$receiver: VALUE_PARAMETER name:<this> type:<root>.JavaClass
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun testPlatformCompareToKotlin (): 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: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToKotlin' type=<root>.JavaClass origin=null
$this: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testPlatformCompareToKotlin' type=<root>.JavaClass origin=null
other: CONST Double type=kotlin.Double value=0.0
FUN name:testKotlinCompareToPlatform visibility:public modality:FINAL <> ($receiver:<root>.JavaClass) returnType:kotlin.Int
$receiver: VALUE_PARAMETER name:<this> type:<root>.JavaClass
@@ -47,5 +52,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: CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testKotlinCompareToPlatform' type=<root>.JavaClass origin=null
other: TYPE_OP type=kotlin.Double origin=IMPLICIT_NOTNULL typeOperand=kotlin.Double
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
$this: GET_VAR '<this>: <root>.JavaClass declared in <root>.testKotlinCompareToPlatform' type=<root>.JavaClass origin=null
@@ -0,0 +1,10 @@
FILE fqName:<root> fileName:/implicitNotNullOnPlatformType.kt
FUN name:f visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit
VALUE_PARAMETER name:s index:0 type:kotlin.String
BLOCK_BODY
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: CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null
CALL 'public final fun f (s: kotlin.String): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
s: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY
@@ -0,0 +1,13 @@
// FILE: implicitNotNullOnPlatformType.kt
fun f(s: String) {}
fun test() {
f(J.s())
f(J.STRING)
}
// FILE: J.java
public class J {
public static String STRING = s();
public static String s() { return null; }
}
@@ -0,0 +1,12 @@
FILE fqName:<root> fileName:/implicitNotNullOnPlatformType.kt
FUN name:f visibility:public modality:FINAL <> (s:kotlin.String) returnType:kotlin.Unit
VALUE_PARAMETER name:s index:0 type:kotlin.String
BLOCK_BODY
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=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=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=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:STRING type:kotlin.String? visibility:public [static]' type=kotlin.String? origin=GET_PROPERTY
@@ -28,10 +28,12 @@ FILE fqName:<root> fileName:/nullabilityAssertionOnExtensionReceiver.kt
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: CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null
$receiver: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=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: CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null
$receiver: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
CALL 'public open fun s (): kotlin.String? declared in <root>.J' type=kotlin.String? origin=null
+4 -2
View File
@@ -3,11 +3,13 @@ FILE fqName:<root> fileName:/platformTypeReceiver.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null
$this: GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:BOOL_NULL type:kotlin.Boolean? visibility:public [static]' type=kotlin.Boolean? origin=GET_PROPERTY
$this: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_NOTNULL typeOperand=kotlin.Boolean
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:BOOL_NULL type:kotlin.Boolean? visibility:public [static]' type=kotlin.Boolean? origin=GET_PROPERTY
other: CONST Null type=kotlin.Nothing? value=null
FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Boolean
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Boolean declared in <root>'
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=null
$this: CALL 'public open fun boolNull (): kotlin.Boolean? declared in <root>.J' type=kotlin.Boolean? origin=null
$this: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_NOTNULL typeOperand=kotlin.Boolean
CALL 'public open fun boolNull (): kotlin.Boolean? declared in <root>.J' type=kotlin.Boolean? origin=null
other: CONST Null type=kotlin.Nothing? value=null
@@ -20,5 +20,6 @@ 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>'
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:T of <root>.JCell? visibility:public' type=kotlin.String? origin=GET_PROPERTY
receiver: GET_VAR 'a: kotlin.Any declared in <root>.testGetField' type=kotlin.Any origin=null
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:T of <root>.JCell? visibility:public' type=kotlin.String? origin=GET_PROPERTY
receiver: GET_VAR 'a: kotlin.Any declared in <root>.testGetField' type=kotlin.Any origin=null
@@ -861,6 +861,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/equality.kt");
}
@TestMetadata("equals.kt")
public void testEquals() throws Exception {
runTest("compiler/testData/ir/irText/expressions/equals.kt");
}
@TestMetadata("extFunInvokeAsFun.kt")
public void testExtFunInvokeAsFun() throws Exception {
runTest("compiler/testData/ir/irText/expressions/extFunInvokeAsFun.kt");
@@ -946,6 +951,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/expressions/implicitCastToTypeParameter.kt");
}
@TestMetadata("implicitNotNullInDestructuringAssignment.kt")
public void testImplicitNotNullInDestructuringAssignment() throws Exception {
runTest("compiler/testData/ir/irText/expressions/implicitNotNullInDestructuringAssignment.kt");
}
@TestMetadata("in.kt")
public void testIn() throws Exception {
runTest("compiler/testData/ir/irText/expressions/in.kt");
@@ -1670,6 +1680,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
runTest("compiler/testData/ir/irText/types/genericPropertyReferenceType.kt");
}
@TestMetadata("implicitNotNullOnPlatformType.kt")
public void testImplicitNotNullOnPlatformType() throws Exception {
runTest("compiler/testData/ir/irText/types/implicitNotNullOnPlatformType.kt");
}
@TestMetadata("intersectionType1_NI.kt")
public void testIntersectionType1_NI() throws Exception {
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");