IR: fixes after rebase
This commit is contained in:
+15
@@ -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("asOnPlatformType.kt")
|
||||
public void testAsOnPlatformType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/asOnPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt")
|
||||
public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
||||
@@ -1650,5 +1655,15 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastOnFieldReceiverOfGenericType.kt")
|
||||
public void testSmartCastOnFieldReceiverOfGenericType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastOnReceiverOfGenericType.kt")
|
||||
public void testSmartCastOnReceiverOfGenericType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,14 @@ import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection
|
||||
import org.jetbrains.kotlin.types.AbstractTypeCheckerContext
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeArgumentMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
|
||||
class IrTypeCheckerContext(override val irBuiltIns: IrBuiltIns) : IrTypeSystemContext, AbstractTypeCheckerContext() {
|
||||
|
||||
override fun anyType(): SimpleTypeMarker =
|
||||
irBuiltIns.anyType as IrSimpleType
|
||||
|
||||
override fun substitutionSupertypePolicy(type: SimpleTypeMarker): SupertypesPolicy.DoCustomTransform {
|
||||
require(type is IrSimpleType)
|
||||
val parameters = extractTypeParameters((type.classifier as IrClassSymbol).owner).map { it.symbol }
|
||||
@@ -60,4 +65,26 @@ class IrTypeCheckerContext(override val irBuiltIns: IrBuiltIns) : IrTypeSystemCo
|
||||
// TODO remove 'Exact' annotation only
|
||||
return removeAnnotations()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isUninferredParameter(): Boolean = false
|
||||
|
||||
override fun captureFromExpression(type: KotlinTypeMarker): KotlinTypeMarker? =
|
||||
error("Captured type is unsupported in IR")
|
||||
|
||||
override fun SimpleTypeMarker.isPrimitiveType(): Boolean {
|
||||
// TODO this is currently used in overload resolution only
|
||||
return false
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.argumentsCount(): Int =
|
||||
when (this) {
|
||||
is IrSimpleType -> arguments.size
|
||||
else -> 0
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.getArgument(index: Int): TypeArgumentMarker =
|
||||
when (this) {
|
||||
is IrSimpleType -> arguments[index]
|
||||
else -> error("Type $this has no arguments")
|
||||
}
|
||||
}
|
||||
@@ -65,13 +65,6 @@ interface IrTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
|
||||
override fun SimpleTypeMarker.typeConstructor() = (this as IrSimpleType).classifier
|
||||
|
||||
override fun SimpleTypeMarker.argumentsCount(): Int = (this as IrSimpleType).arguments.size
|
||||
|
||||
override fun SimpleTypeMarker.getArgument(index: Int): TypeArgumentMarker {
|
||||
val simpleType = this as IrSimpleType
|
||||
return simpleType.arguments[index]
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.asTypeArgument() = this as IrTypeArgument
|
||||
|
||||
override fun CapturedTypeMarker.lowerType(): KotlinTypeMarker? = error("Captured Type is not valid for IrTypes")
|
||||
@@ -328,6 +321,14 @@ interface IrTypeSystemContext : TypeSystemInferenceExtensionContext {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun intersectTypes(types: List<KotlinTypeMarker>): KotlinTypeMarker =
|
||||
makeTypeIntersection(types as List<IrType>)
|
||||
|
||||
override fun TypeConstructorMarker.isCapturedTypeConstructor(): Boolean = false
|
||||
|
||||
override fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker =
|
||||
TODO("IrTypeSystemContext doesn't support constraint system resolution")
|
||||
|
||||
override fun CapturedTypeMarker.captureStatus(): CaptureStatus =
|
||||
error("Captured type is unsupported in IR")
|
||||
}
|
||||
|
||||
fun extractTypeParameters(klass: IrDeclarationParent): List<IrTypeParameter> {
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrTypeOperatorCallImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: asOnPlatformType.kt
|
||||
fun test() {
|
||||
val nullStr = JavaClass.nullString()
|
||||
val nonnullStr = JavaClass.nonnullString()
|
||||
|
||||
nullStr.foo()
|
||||
nonnullStr.foo()
|
||||
nullStr.fooN()
|
||||
nonnullStr.fooN()
|
||||
}
|
||||
|
||||
inline fun <reified T> T.foo(): T = this as T
|
||||
inline fun <reified T> T.fooN(): T? = this as T?
|
||||
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public static String nullString() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String nonnullString() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
FILE fqName:<root> fileName:/asOnPlatformType.kt
|
||||
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR name:nullStr type:kotlin.String? [val]
|
||||
CALL 'public open fun nullString (): kotlin.String? declared in <root>.JavaClass' type=kotlin.String? origin=null
|
||||
VAR name:nonnullStr type:kotlin.String? [val]
|
||||
CALL 'public open fun nonnullString (): kotlin.String? declared in <root>.JavaClass' type=kotlin.String? origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun foo <T> (): T of <root>.foo [inline] declared in <root>' type=kotlin.String? origin=null
|
||||
<T>: kotlin.String?
|
||||
$receiver: GET_VAR 'val nullStr: kotlin.String? [val] declared in <root>.test' type=kotlin.String? origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun foo <T> (): T of <root>.foo [inline] declared in <root>' type=kotlin.String? origin=null
|
||||
<T>: kotlin.String?
|
||||
$receiver: GET_VAR 'val nonnullStr: kotlin.String? [val] declared in <root>.test' type=kotlin.String? origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun fooN <T> (): T of <root>.fooN? [inline] declared in <root>' type=kotlin.String? origin=null
|
||||
<T>: kotlin.String?
|
||||
$receiver: GET_VAR 'val nullStr: kotlin.String? [val] declared in <root>.test' type=kotlin.String? origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun fooN <T> (): T of <root>.fooN? [inline] declared in <root>' type=kotlin.String? origin=null
|
||||
<T>: kotlin.String?
|
||||
$receiver: GET_VAR 'val nonnullStr: kotlin.String? [val] declared in <root>.test' type=kotlin.String? origin=null
|
||||
FUN name:foo visibility:public modality:FINAL <T> ($receiver:T of <root>.foo) returnType:T of <root>.foo [inline]
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:T of <root>.foo
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun foo <T> (): T of <root>.foo [inline] declared in <root>'
|
||||
TYPE_OP type=T of <root>.foo origin=CAST typeOperand=T of <root>.foo
|
||||
GET_VAR '<this>: T of <root>.foo declared in <root>.foo' type=T of <root>.foo origin=null
|
||||
FUN name:fooN visibility:public modality:FINAL <T> ($receiver:T of <root>.fooN) returnType:T of <root>.fooN? [inline]
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
$receiver: VALUE_PARAMETER name:<this> type:T of <root>.fooN
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun fooN <T> (): T of <root>.fooN? [inline] declared in <root>'
|
||||
TYPE_OP type=T of <root>.fooN? origin=CAST typeOperand=T of <root>.fooN?
|
||||
GET_VAR '<this>: T of <root>.fooN declared in <root>.fooN' type=T of <root>.fooN origin=null
|
||||
@@ -57,14 +57,14 @@ FILE fqName:<root> fileName:/intersectionType1_OI.kt
|
||||
CALL 'public final fun arrayOf <T> (vararg elements: T of kotlin.arrayOf): kotlin.Array<T of kotlin.arrayOf> [inline] declared in kotlin' type=kotlin.Array<<root>.In<kotlin.Int>> origin=null
|
||||
<T>: <root>.In<kotlin.Int>
|
||||
elements: VARARG type=kotlin.Array<out <root>.In<kotlin.Int>> varargElementType=<root>.In<kotlin.Int>
|
||||
CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.Int> origin=null
|
||||
<I>: kotlin.Int
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.Int> origin=null
|
||||
<class: I>: kotlin.Int
|
||||
VAR name:a2 type:kotlin.Array<<root>.In<kotlin.String>> [val]
|
||||
CALL 'public final fun arrayOf <T> (vararg elements: T of kotlin.arrayOf): kotlin.Array<T of kotlin.arrayOf> [inline] declared in kotlin' type=kotlin.Array<<root>.In<kotlin.String>> origin=null
|
||||
<T>: <root>.In<kotlin.String>
|
||||
elements: VARARG type=kotlin.Array<out <root>.In<kotlin.String>> varargElementType=<root>.In<kotlin.String>
|
||||
CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.String> origin=null
|
||||
<I>: kotlin.String
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.In' type=<root>.In<kotlin.String> origin=null
|
||||
<class: I>: kotlin.String
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun foo <T> (a: kotlin.Array<<root>.In<T of <root>.foo>>, b: kotlin.Array<<root>.In<kotlin.String>>): kotlin.Boolean declared in <root>' type=kotlin.Boolean origin=null
|
||||
<T>: kotlin.Int
|
||||
|
||||
@@ -90,9 +90,9 @@ FILE fqName:<root> fileName:/intersectionType2_OI.kt
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any
|
||||
BLOCK_BODY
|
||||
VAR name:mm type:<root>.B [val]
|
||||
CALL 'public constructor <init> () [primary] declared in <root>.B' type=<root>.B origin=null
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.B' type=<root>.B origin=null
|
||||
VAR name:nn type:<root>.C [val]
|
||||
CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.C' type=<root>.C origin=null
|
||||
VAR name:c type:kotlin.Any [val]
|
||||
WHEN type=kotlin.Any origin=IF
|
||||
BRANCH
|
||||
|
||||
@@ -100,24 +100,29 @@ FILE fqName:<root> fileName:/localVariableOfIntersectionType_NI.kt
|
||||
$this: CALL 'public abstract fun create <T> (x: <root>.In<T of <root>.Z.create>, y: <root>.In<T of <root>.Z.create>): <root>.Inv<T of <root>.Z.create> declared in <root>.Z' type=<root>.Inv<kotlin.Any> origin=null
|
||||
<T>: kotlin.Any
|
||||
$this: GET_VAR 'z: <root>.Z declared in <root>.test' type=<root>.Z origin=null
|
||||
x: GET_VAR 'a: <root>.In<<root>.IA> declared in <root>.test' type=<root>.In<<root>.IA> origin=null
|
||||
y: GET_VAR 'b: <root>.In<<root>.IB> declared in <root>.test' type=<root>.In<<root>.IB> origin=null
|
||||
x: TYPE_OP type=<root>.In<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.In<kotlin.Any>
|
||||
GET_VAR 'a: <root>.In<<root>.IA> declared in <root>.test' type=<root>.In<<root>.IA> origin=null
|
||||
y: TYPE_OP type=<root>.In<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.In<kotlin.Any>
|
||||
GET_VAR 'b: <root>.In<<root>.IB> declared in <root>.test' type=<root>.In<<root>.IB> origin=null
|
||||
CALL 'public abstract fun bar (): kotlin.Unit declared in <root>.IB' type=kotlin.Unit origin=null
|
||||
$this: TYPE_OP type=<root>.IB origin=IMPLICIT_CAST typeOperand=<root>.IB
|
||||
CALL 'public abstract fun <get-t> (): T of <root>.Inv declared in <root>.Inv' type=kotlin.Any origin=GET_PROPERTY
|
||||
$this: CALL 'public abstract fun create <T> (x: <root>.In<T of <root>.Z.create>, y: <root>.In<T of <root>.Z.create>): <root>.Inv<T of <root>.Z.create> declared in <root>.Z' type=<root>.Inv<kotlin.Any> origin=null
|
||||
<T>: kotlin.Any
|
||||
$this: GET_VAR 'z: <root>.Z declared in <root>.test' type=<root>.Z origin=null
|
||||
x: GET_VAR 'a: <root>.In<<root>.IA> declared in <root>.test' type=<root>.In<<root>.IA> origin=null
|
||||
y: GET_VAR 'b: <root>.In<<root>.IB> declared in <root>.test' type=<root>.In<<root>.IB> origin=null
|
||||
x: TYPE_OP type=<root>.In<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.In<kotlin.Any>
|
||||
GET_VAR 'a: <root>.In<<root>.IA> declared in <root>.test' type=<root>.In<<root>.IA> origin=null
|
||||
y: TYPE_OP type=<root>.In<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.In<kotlin.Any>
|
||||
GET_VAR 'b: <root>.In<<root>.IB> declared in <root>.test' type=<root>.In<<root>.IB> origin=null
|
||||
VAR name:t type:kotlin.Any [val]
|
||||
TYPE_OP type=kotlin.Any origin=IMPLICIT_CAST typeOperand=kotlin.Any
|
||||
CALL 'public abstract fun <get-t> (): T of <root>.Inv declared in <root>.Inv' type=kotlin.Any origin=GET_PROPERTY
|
||||
$this: CALL 'public abstract fun create <T> (x: <root>.In<T of <root>.Z.create>, y: <root>.In<T of <root>.Z.create>): <root>.Inv<T of <root>.Z.create> declared in <root>.Z' type=<root>.Inv<kotlin.Any> origin=null
|
||||
<T>: kotlin.Any
|
||||
$this: GET_VAR 'z: <root>.Z declared in <root>.test' type=<root>.Z origin=null
|
||||
x: GET_VAR 'a: <root>.In<<root>.IA> declared in <root>.test' type=<root>.In<<root>.IA> origin=null
|
||||
y: GET_VAR 'b: <root>.In<<root>.IB> declared in <root>.test' type=<root>.In<<root>.IB> origin=null
|
||||
CALL 'public abstract fun <get-t> (): T of <root>.Inv declared in <root>.Inv' type=kotlin.Any origin=GET_PROPERTY
|
||||
$this: CALL 'public abstract fun create <T> (x: <root>.In<T of <root>.Z.create>, y: <root>.In<T of <root>.Z.create>): <root>.Inv<T of <root>.Z.create> declared in <root>.Z' type=<root>.Inv<kotlin.Any> origin=null
|
||||
<T>: kotlin.Any
|
||||
$this: GET_VAR 'z: <root>.Z declared in <root>.test' type=<root>.Z origin=null
|
||||
x: TYPE_OP type=<root>.In<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.In<kotlin.Any>
|
||||
GET_VAR 'a: <root>.In<<root>.IA> declared in <root>.test' type=<root>.In<<root>.IA> origin=null
|
||||
y: TYPE_OP type=<root>.In<kotlin.Any> origin=IMPLICIT_CAST typeOperand=<root>.In<kotlin.Any>
|
||||
GET_VAR 'b: <root>.In<<root>.IB> declared in <root>.test' type=<root>.In<<root>.IB> origin=null
|
||||
CALL 'public abstract fun foo (): kotlin.Unit declared in <root>.IA' type=kotlin.Unit origin=null
|
||||
$this: TYPE_OP type=<root>.IA origin=IMPLICIT_CAST typeOperand=<root>.IA
|
||||
GET_VAR 'val t: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// FILE: smartCastOnFieldReceiverOfGenericType.kt
|
||||
fun testSetField(a: Any, b: Any) {
|
||||
a as JCell<String>
|
||||
b as String
|
||||
a.value = b
|
||||
}
|
||||
|
||||
fun testGetField(a: Any): String {
|
||||
a as JCell<String>
|
||||
return a.value
|
||||
}
|
||||
|
||||
// FILE: JCell.java
|
||||
public class JCell<T> {
|
||||
public T value;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
FILE fqName:<root> fileName:/smartCastOnFieldReceiverOfGenericType.kt
|
||||
FUN name:testSetField visibility:public modality:FINAL <> (a:kotlin.Any, b:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=<root>.JCell<kotlin.String> origin=CAST typeOperand=<root>.JCell<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testSetField' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testSetField' type=kotlin.Any origin=null
|
||||
SET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:value type:T of <root>.JCell? visibility:public ' type=kotlin.Unit origin=EQ
|
||||
receiver: TYPE_OP type=<root>.JCell<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.JCell<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testSetField' type=kotlin.Any origin=null
|
||||
value: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testSetField' type=kotlin.Any origin=null
|
||||
FUN name:testGetField visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.String
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
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=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: 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
|
||||
@@ -0,0 +1,33 @@
|
||||
fun testFunction(a: Any, b: Any) {
|
||||
a as MutableList<String>
|
||||
b as String
|
||||
a.add(b)
|
||||
}
|
||||
|
||||
fun testProperty(a: Any, b: Any) {
|
||||
a as Cell<String>
|
||||
b as String
|
||||
a.value = b
|
||||
}
|
||||
|
||||
fun testInnerClass(a: Any, b: Any, c: Any) {
|
||||
a as Outer<Int>.Inner<String>
|
||||
b as Int
|
||||
c as String
|
||||
a.use(b, c)
|
||||
}
|
||||
|
||||
fun <T> testNonSubstitutedTypeParameter(a: Any, b: Any) {
|
||||
a as MutableList<List<T>>
|
||||
b as List<T>
|
||||
a.add(b)
|
||||
}
|
||||
|
||||
class Cell<T>(var value: T)
|
||||
|
||||
class Outer<T1> {
|
||||
inner class Inner<T2> {
|
||||
fun use(x1: T1, x2: T2) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
FILE fqName:<root> fileName:/smartCastOnReceiverOfGenericType.kt
|
||||
FUN name:testFunction visibility:public modality:FINAL <> (a:kotlin.Any, b:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.collections.MutableList<kotlin.String> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testFunction' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testFunction' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun add (element: E of kotlin.collections.MutableList): kotlin.Boolean declared in kotlin.collections.MutableList' type=kotlin.Boolean origin=null
|
||||
$this: TYPE_OP type=kotlin.collections.MutableList<kotlin.String> origin=IMPLICIT_CAST typeOperand=kotlin.collections.MutableList<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testFunction' type=kotlin.Any origin=null
|
||||
element: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testFunction' type=kotlin.Any origin=null
|
||||
FUN name:testProperty visibility:public modality:FINAL <> (a:kotlin.Any, b:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=<root>.Cell<kotlin.String> origin=CAST typeOperand=<root>.Cell<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testProperty' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testProperty' type=kotlin.Any origin=null
|
||||
CALL 'public final fun <set-value> (<set-?>: T of <root>.Cell): kotlin.Unit declared in <root>.Cell' type=kotlin.Unit origin=EQ
|
||||
$this: TYPE_OP type=<root>.Cell<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.Cell<kotlin.String>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testProperty' type=kotlin.Any origin=null
|
||||
<set-?>: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testProperty' type=kotlin.Any origin=null
|
||||
FUN name:testInnerClass visibility:public modality:FINAL <> (a:kotlin.Any, b:kotlin.Any, c:kotlin.Any) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Any
|
||||
VALUE_PARAMETER name:c index:2 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=<root>.Outer.Inner<kotlin.String, kotlin.Int> origin=CAST typeOperand=<root>.Outer.Inner<kotlin.String, kotlin.Int>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testInnerClass' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.Int origin=CAST typeOperand=kotlin.Int
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testInnerClass' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.String origin=CAST typeOperand=kotlin.String
|
||||
GET_VAR 'c: kotlin.Any declared in <root>.testInnerClass' type=kotlin.Any origin=null
|
||||
CALL 'public final fun use (x1: T1 of <root>.Outer, x2: T2 of <root>.Outer.Inner): kotlin.Unit declared in <root>.Outer.Inner' type=kotlin.Unit origin=null
|
||||
$this: TYPE_OP type=<root>.Outer.Inner<kotlin.String, kotlin.Int> origin=IMPLICIT_CAST typeOperand=<root>.Outer.Inner<kotlin.String, kotlin.Int>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testInnerClass' type=kotlin.Any origin=null
|
||||
x1: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testInnerClass' type=kotlin.Any origin=null
|
||||
x2: TYPE_OP type=kotlin.String origin=IMPLICIT_CAST typeOperand=kotlin.String
|
||||
GET_VAR 'c: kotlin.Any declared in <root>.testInnerClass' type=kotlin.Any origin=null
|
||||
FUN name:testNonSubstitutedTypeParameter visibility:public modality:FINAL <T> (a:kotlin.Any, b:kotlin.Any) returnType:kotlin.Unit
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
VALUE_PARAMETER name:a index:0 type:kotlin.Any
|
||||
VALUE_PARAMETER name:b index:1 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.collections.MutableList<kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter>> origin=CAST typeOperand=kotlin.collections.MutableList<kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter>>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testNonSubstitutedTypeParameter' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
TYPE_OP type=kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter> origin=CAST typeOperand=kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter>
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testNonSubstitutedTypeParameter' type=kotlin.Any origin=null
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public abstract fun add (element: E of kotlin.collections.MutableList): kotlin.Boolean declared in kotlin.collections.MutableList' type=kotlin.Boolean origin=null
|
||||
$this: TYPE_OP type=kotlin.collections.MutableList<kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter>> origin=IMPLICIT_CAST typeOperand=kotlin.collections.MutableList<kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter>>
|
||||
GET_VAR 'a: kotlin.Any declared in <root>.testNonSubstitutedTypeParameter' type=kotlin.Any origin=null
|
||||
element: TYPE_OP type=kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter> origin=IMPLICIT_CAST typeOperand=kotlin.collections.List<T of <root>.testNonSubstitutedTypeParameter>
|
||||
GET_VAR 'b: kotlin.Any declared in <root>.testNonSubstitutedTypeParameter' type=kotlin.Any origin=null
|
||||
CLASS CLASS name:Cell modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Cell<T of <root>.Cell>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> (value:T of <root>.Cell) returnType:<root>.Cell<T of <root>.Cell> [primary]
|
||||
VALUE_PARAMETER name:value index:0 type:T of <root>.Cell
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Cell modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||
PROPERTY name:value visibility:public modality:FINAL [var]
|
||||
FIELD PROPERTY_BACKING_FIELD name:value type:T of <root>.Cell visibility:public
|
||||
EXPRESSION_BODY
|
||||
GET_VAR 'value: T of <root>.Cell declared in <root>.Cell.<init>' type=T of <root>.Cell origin=INITIALIZE_PROPERTY_FROM_PARAMETER
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.Cell<T of <root>.Cell>) returnType:T of <root>.Cell
|
||||
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Cell<T of <root>.Cell>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-value> (): T of <root>.Cell declared in <root>.Cell'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:T of <root>.Cell visibility:public ' type=T of <root>.Cell origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Cell<T of <root>.Cell> declared in <root>.Cell.<get-value>' type=<root>.Cell<T of <root>.Cell> origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-value> visibility:public modality:FINAL <> ($this:<root>.Cell<T of <root>.Cell>, <set-?>:T of <root>.Cell) returnType:kotlin.Unit
|
||||
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Cell<T of <root>.Cell>
|
||||
VALUE_PARAMETER name:<set-?> index:0 type:T of <root>.Cell
|
||||
BLOCK_BODY
|
||||
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:T of <root>.Cell visibility:public ' type=kotlin.Unit origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Cell<T of <root>.Cell> declared in <root>.Cell.<set-value>' type=<root>.Cell<T of <root>.Cell> origin=null
|
||||
value: GET_VAR '<set-?>: T of <root>.Cell declared in <root>.Cell.<set-value>' type=T of <root>.Cell origin=null
|
||||
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
|
||||
CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Outer<T1 of <root>.Outer>
|
||||
TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Outer<T1 of <root>.Outer> [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]'
|
||||
CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Outer.Inner<T2 of <root>.Outer.Inner, T1 of <root>.Outer>
|
||||
TYPE_PARAMETER name:T2 index:0 variance: superTypes:[kotlin.Any?]
|
||||
CONSTRUCTOR visibility:public <> ($this:<root>.Outer<T1 of <root>.Outer>) returnType:<root>.Outer.Inner<T2 of <root>.Outer.Inner, T1 of <root>.Outer> [primary]
|
||||
$outer: VALUE_PARAMETER name:<this> type:<root>.Outer<T1 of <root>.Outer>
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]'
|
||||
FUN name:use visibility:public modality:FINAL <> ($this:<root>.Outer.Inner<T2 of <root>.Outer.Inner, T1 of <root>.Outer>, x1:T1 of <root>.Outer, x2:T2 of <root>.Outer.Inner) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Outer.Inner<T2 of <root>.Outer.Inner, T1 of <root>.Outer>
|
||||
VALUE_PARAMETER name:x1 index:0 type:T1 of <root>.Outer
|
||||
VALUE_PARAMETER name:x2 index:1 type:T2 of <root>.Outer.Inner
|
||||
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 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
|
||||
@@ -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("asOnPlatformType.kt")
|
||||
public void testAsOnPlatformType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/asOnPlatformType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt")
|
||||
public void testExplicitEqualsAndCompareToCallsOnPlatformTypeReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/explicitEqualsAndCompareToCallsOnPlatformTypeReceiver.kt");
|
||||
@@ -1650,5 +1655,15 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
public void testNullabilityAssertionOnExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/nullabilityAssertionOnExtensionReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastOnFieldReceiverOfGenericType.kt")
|
||||
public void testSmartCastOnFieldReceiverOfGenericType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/smartCastOnFieldReceiverOfGenericType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("smartCastOnReceiverOfGenericType.kt")
|
||||
public void testSmartCastOnReceiverOfGenericType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/smartCastOnReceiverOfGenericType.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user