psi2ir: fix nullability assertion generation for platform types
Incorporate PR from Steven Schäfer into IrType-based implicit cast insertion (commit 17b925636e8717e7648c5d7b792c6ab4d18f776d). NB this still uses originalKotlinType to determine if the type was nullability flexible. It is somewhat error-prone and something we want to get rid of. However, it boils down to some design questions related to implicit null checks in Kotlin - e.g., it might be Ok to just treat nullability flexible type `T!` as `T?` in IR, generate null checks for all usages of type `T?` where a non-null type is expected, and later eliminate the null checks that are redundant according to the (quite conservative) criterion in the redundant null check elimination.
This commit is contained in:
+10
@@ -1606,6 +1606,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt")
|
||||
public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionType1_NI.kt")
|
||||
public void testIntersectionType1_NI() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
|
||||
@@ -1640,5 +1645,10 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
public void testLocalVariableOfIntersectionType_NI() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityAssertionOnExtensionReceiver.kt")
|
||||
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+22
-12
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.makeTypeIntersection
|
||||
import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
||||
import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
@@ -37,7 +38,6 @@ import org.jetbrains.kotlin.psi2ir.generators.GeneratorExtensions
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.isDynamic
|
||||
import org.jetbrains.kotlin.types.isNullabilityFlexible
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
|
||||
fun insertImplicitCasts(element: IrElement, context: GeneratorContext) {
|
||||
element.transformChildren(
|
||||
@@ -111,10 +111,12 @@ open class InsertImplicitCasts(
|
||||
val dTypeParameters = getDeclarationSideTypeParameters(declaration)
|
||||
val cTypeParameters = getTypeSideTypeParameters(declaration)
|
||||
val typeArguments = getTypeArguments(expression, dTypeParameters)
|
||||
val dispatchReceiver = declaration.dispatchReceiverParameter
|
||||
val extensionReceiver = declaration.extensionReceiverParameter
|
||||
this.dispatchReceiver = this.dispatchReceiver?.cast(dispatchReceiver?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments))
|
||||
this.extensionReceiver = this.extensionReceiver?.cast(extensionReceiver?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments))
|
||||
dispatchReceiver = dispatchReceiver?.cast(
|
||||
declaration.dispatchReceiverParameter?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments)
|
||||
)
|
||||
extensionReceiver = extensionReceiver?.cast(
|
||||
declaration.extensionReceiverParameter?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +125,12 @@ open class InsertImplicitCasts(
|
||||
val dTypeParameters = getDeclarationSideTypeParameters(declaration)
|
||||
val cTypeParameters = getTypeSideTypeParameters(declaration)
|
||||
val typeArguments = getTypeArguments(this, dTypeParameters)
|
||||
dispatchReceiver = dispatchReceiver?.cast(declaration.dispatchReceiverParameter?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments))
|
||||
extensionReceiver = extensionReceiver?.cast(declaration.extensionReceiverParameter?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments))
|
||||
dispatchReceiver = dispatchReceiver?.cast(
|
||||
declaration.dispatchReceiverParameter?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments)
|
||||
)
|
||||
extensionReceiver = extensionReceiver?.cast(
|
||||
declaration.extensionReceiverParameter?.type?.substitute(dTypeParameters + cTypeParameters, typeArguments)
|
||||
)
|
||||
}
|
||||
|
||||
override fun visitMemberAccess(expression: IrMemberAccessExpression): IrExpression =
|
||||
@@ -314,7 +320,7 @@ open class InsertImplicitCasts(
|
||||
}
|
||||
|
||||
private fun IrExpression.implicitNonNull(valueType: IrType, expectedType: IrType): IrExpression {
|
||||
val notNullValueType = valueType.makeNotNull()
|
||||
val notNullValueType = valueType.getRepresentableUpperBound().makeNotNull()
|
||||
return implicitCast(notNullValueType, IrTypeOperator.IMPLICIT_NOTNULL).cast(expectedType)
|
||||
}
|
||||
|
||||
@@ -352,9 +358,13 @@ open class InsertImplicitCasts(
|
||||
|
||||
private fun IrType.isBuiltInIntegerType(): Boolean =
|
||||
isByte() || isShort() || isInt() || isLong() ||
|
||||
isUByte() ||
|
||||
isUShort() ||
|
||||
isUInt() ||
|
||||
isULong()
|
||||
isUByte() || isUShort() || isUInt() || isULong()
|
||||
|
||||
private fun IrType.getRepresentableUpperBound(): IrType {
|
||||
if (this !is IrSimpleType) return this
|
||||
val classifier = this.classifier as? IrTypeParameterSymbol ?: return this
|
||||
val superTypes = classifier.owner.superTypes
|
||||
return makeTypeIntersection(superTypes)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ class TypeTranslator(
|
||||
typeParametersResolver.resolveScopedTypeParameter(typeParameterDescriptor)
|
||||
?: symbolTable.referenceTypeParameter(typeParameterDescriptor)
|
||||
|
||||
fun translateType(ktType: KotlinType): IrType =
|
||||
translateType(ktType, Variance.INVARIANT).type
|
||||
fun translateType(kotlinType: KotlinType): IrType =
|
||||
translateType(kotlinType, kotlinType, Variance.INVARIANT).type
|
||||
|
||||
private fun translateType(ktType: KotlinType, variance: Variance): IrTypeProjection {
|
||||
val approximatedType = LegacyTypeApproximation().approximate(ktType)
|
||||
private fun translateType(originalKotlinType: KotlinType, kotlinType: KotlinType, variance: Variance): IrTypeProjection {
|
||||
val approximatedType = LegacyTypeApproximation().approximate(kotlinType)
|
||||
|
||||
when {
|
||||
approximatedType.isError ->
|
||||
@@ -69,7 +69,7 @@ class TypeTranslator(
|
||||
approximatedType.isDynamic() ->
|
||||
return IrDynamicTypeImpl(approximatedType, translateTypeAnnotations(approximatedType.annotations), variance)
|
||||
approximatedType.isFlexible() ->
|
||||
return translateType(approximatedType.upperIfFlexible(), variance)
|
||||
return translateType(originalKotlinType, approximatedType.upperIfFlexible(), variance)
|
||||
}
|
||||
|
||||
val ktTypeConstructor = approximatedType.constructor
|
||||
@@ -77,7 +77,7 @@ class TypeTranslator(
|
||||
?: throw AssertionError("No descriptor for type $approximatedType")
|
||||
|
||||
return IrSimpleTypeBuilder().apply {
|
||||
kotlinType = approximatedType
|
||||
this.kotlinType = originalKotlinType
|
||||
hasQuestionMark = approximatedType.isMarkedNullable
|
||||
this.variance = variance
|
||||
when (ktTypeDescriptor) {
|
||||
@@ -140,6 +140,6 @@ class TypeTranslator(
|
||||
if (it.isStarProjection)
|
||||
IrStarProjectionImpl
|
||||
else
|
||||
translateType(it.type, it.projectionKind)
|
||||
translateType(it.type, it.type, it.projectionKind)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ FILE fqName:<root> fileName:/coercionToUnit.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public open fun println (x: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'val tmp0_safe_receiver: 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 tmp0_safe_receiver: java.io.PrintStream? [val] declared in <root>.test3' type=java.io.PrintStream? origin=null
|
||||
x: 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
|
||||
@@ -51,5 +52,6 @@ FILE fqName:<root> fileName:/coercionToUnit.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public open fun println (x: kotlin.String?): kotlin.Unit declared in java.io.PrintStream' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'val tmp1_safe_receiver: 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 tmp1_safe_receiver: java.io.PrintStream? [val] declared in <root>.test3' type=java.io.PrintStream? origin=null
|
||||
x: CONST String type=kotlin.String value="world!"
|
||||
|
||||
@@ -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 (key: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null
|
||||
key: CONST String type=kotlin.String value="test"
|
||||
TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
|
||||
CALL 'public open fun getProperty (key: kotlin.String?): kotlin.String? declared in java.lang.System' type=kotlin.String? origin=null
|
||||
key: CONST String type=kotlin.String value="test"
|
||||
|
||||
@@ -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 (x: 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
|
||||
x: 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 (x: 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
|
||||
x: 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 (x: 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
|
||||
x: 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 (x: 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
|
||||
x: 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 (x: 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
|
||||
x: 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
|
||||
overridden:
|
||||
|
||||
+4
-3
@@ -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
|
||||
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt
|
||||
FUN name:testPlatformEqualsPlatform visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testPlatformEqualsPlatform (): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Ambiguity: equals, [kotlin/Any.equals, kotlin/Any.equals]>#' type=IrErrorType
|
||||
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
|
||||
FUN name:testPlatformEqualsKotlin visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testPlatformEqualsKotlin (): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Ambiguity: equals, [kotlin/Any.equals, kotlin/Any.equals]>#' type=IrErrorType
|
||||
CONST Double type=kotlin.Double value=0.0
|
||||
FUN name:testKotlinEqualsPlatform visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testKotlinEqualsPlatform (): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Ambiguity: equals, [kotlin/Any.equals, kotlin/Any.equals]>#' type=IrErrorType
|
||||
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
|
||||
FUN name:testPlatformCompareToPlatform visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testPlatformCompareToPlatform (): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Ambiguity: compareTo, [kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Comparable.compareTo]>#' type=IrErrorType
|
||||
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
|
||||
FUN name:testPlatformCompareToKotlin visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testPlatformCompareToKotlin (): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Ambiguity: compareTo, [kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Comparable.compareTo]>#' type=IrErrorType
|
||||
CONST Double type=kotlin.Double value=0.0
|
||||
FUN name:testKotlinCompareToPlatform visibility:public modality:FINAL <> () returnType:IrErrorType
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testKotlinCompareToPlatform (): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Ambiguity: compareTo, [kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Double.compareTo, kotlin/Comparable.compareTo]>#' type=IrErrorType
|
||||
CALL 'public open fun null0 (): kotlin.Double? declared in <root>.JavaClass' type=kotlin.Double? origin=null
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// FILE: explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt
|
||||
|
||||
fun JavaClass.testPlatformEqualsPlatform() =
|
||||
null0().equals(null0())
|
||||
|
||||
fun JavaClass.testPlatformEqualsKotlin() =
|
||||
null0().equals(0.0)
|
||||
|
||||
fun JavaClass.testKotlinEqualsPlatform() =
|
||||
0.0.equals(null0())
|
||||
|
||||
fun JavaClass.testPlatformCompareToPlatform() =
|
||||
null0().compareTo(null0())
|
||||
|
||||
fun JavaClass.testPlatformCompareToKotlin() =
|
||||
null0().compareTo(0.0)
|
||||
|
||||
fun JavaClass.testKotlinCompareToPlatform() =
|
||||
0.0.compareTo(null0())
|
||||
|
||||
// FILE: JavaClass.java
|
||||
|
||||
public class JavaClass {
|
||||
public Double null0(){
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+57
@@ -0,0 +1,57 @@
|
||||
FILE fqName:<root> fileName:/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt
|
||||
FUN name:testPlatformEqualsPlatform visibility:public modality:FINAL <> ($receiver:<root>.JavaClass) returnType:kotlin.Boolean
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.JavaClass
|
||||
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 declared in kotlin.Double' type=kotlin.Boolean 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
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.JavaClass
|
||||
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 declared in kotlin.Double' type=kotlin.Boolean 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
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testKotlinEqualsPlatform (): kotlin.Boolean declared in <root>'
|
||||
CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Double' type=kotlin.Boolean 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>.testKotlinEqualsPlatform' type=<root>.JavaClass origin=null
|
||||
FUN name:testPlatformCompareToPlatform 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 testPlatformCompareToPlatform (): kotlin.Int declared in <root>'
|
||||
CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int declared in kotlin.Double' type=kotlin.Int 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 declared in kotlin.Double' type=kotlin.Int 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
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun testKotlinCompareToPlatform (): kotlin.Int declared in <root>'
|
||||
CALL 'public open fun compareTo (other: kotlin.Double): kotlin.Int declared in kotlin.Double' type=kotlin.Int origin=null
|
||||
$this: CONST Double type=kotlin.Double value=0.0
|
||||
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
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
FILE fqName:<root> fileName:/nullabilityAssertionOnExtensionReceiver.kt
|
||||
FUN name:extension visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
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) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.C
|
||||
BLOCK_BODY
|
||||
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean
|
||||
overridden:
|
||||
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
|
||||
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
|
||||
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
|
||||
FUN name:testMemberExt visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
CALL 'public final fun memberExtension (): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=null
|
||||
@@ -0,0 +1,20 @@
|
||||
// FILE: nullabilityAssertionOnExtensionReceiver.kt
|
||||
|
||||
fun String.extension() {}
|
||||
|
||||
class C {
|
||||
fun String.memberExtension() {}
|
||||
}
|
||||
|
||||
fun testExt() {
|
||||
J.s().extension()
|
||||
}
|
||||
|
||||
fun C.testMemberExt() {
|
||||
J.s().memberExtension()
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static String s() { return null; }
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
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
|
||||
overridden:
|
||||
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
|
||||
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
|
||||
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=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: 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
|
||||
@@ -1606,6 +1606,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/types"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt")
|
||||
public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("intersectionType1_NI.kt")
|
||||
public void testIntersectionType1_NI() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/intersectionType1_NI.kt");
|
||||
@@ -1640,5 +1645,10 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
public void testLocalVariableOfIntersectionType_NI() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType_NI.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullabilityAssertionOnExtensionReceiver.kt")
|
||||
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user