psi2ir: add test for implicit cast on values of intersection type
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
interface In<in T>
|
||||
|
||||
interface Inv<T> {
|
||||
val t: T
|
||||
}
|
||||
|
||||
interface Z {
|
||||
fun <T> create(x: In<T>, y: In<T>): Inv<T>
|
||||
}
|
||||
|
||||
interface IA {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
interface IB {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
fun test(a: In<IA>, b: In<IB>, z: Z) {
|
||||
z.create(a, b).t.foo()
|
||||
z.create(a, b).t.bar()
|
||||
val t = z.create(a, b).t
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
FILE fqName:<root> fileName:/localVariableOfIntersectionType.kt
|
||||
CLASS INTERFACE name:In modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.In<T of <root>.In>
|
||||
TYPE_PARAMETER name:T index:0 variance:in superTypes:[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
|
||||
CLASS INTERFACE name:Inv modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Inv<T of <root>.Inv>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
PROPERTY name:t visibility:public modality:ABSTRACT [val]
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-t> visibility:public modality:ABSTRACT <> ($this:<root>.Inv<T of <root>.Inv>) returnType:T of <root>.Inv
|
||||
correspondingProperty: PROPERTY name:t visibility:public modality:ABSTRACT [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Inv<T of <root>.Inv>
|
||||
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 INTERFACE name:Z modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Z
|
||||
FUN name:create visibility:public modality:ABSTRACT <T> ($this:<root>.Z, x:<root>.In<T of <root>.Z.create>, y:<root>.In<T of <root>.Z.create>) returnType:<root>.Inv<T of <root>.Z.create>
|
||||
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Z
|
||||
VALUE_PARAMETER name:x index:0 type:<root>.In<T of <root>.Z.create>
|
||||
VALUE_PARAMETER name:y index:1 type:<root>.In<T of <root>.Z.create>
|
||||
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 INTERFACE name:IA modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IA
|
||||
FUN name:foo visibility:public modality:ABSTRACT <> ($this:<root>.IA) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IA
|
||||
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 INTERFACE name:IB modality:ABSTRACT visibility:public superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.IB
|
||||
FUN name:bar visibility:public modality:ABSTRACT <> ($this:<root>.IB) returnType:kotlin.Unit
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.IB
|
||||
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:test visibility:public modality:FINAL <> (a:<root>.In<<root>.IA>, b:<root>.In<<root>.IB>, z:<root>.Z) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:a index:0 type:<root>.In<<root>.IA>
|
||||
VALUE_PARAMETER name:b index:1 type:<root>.In<<root>.IB>
|
||||
VALUE_PARAMETER name:z index:2 type:<root>.Z
|
||||
BLOCK_BODY
|
||||
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
|
||||
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 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
|
||||
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 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
|
||||
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
|
||||
GET_VAR 'val t: kotlin.Any [val] declared in <root>.test' type=kotlin.Any origin=null
|
||||
@@ -1590,5 +1590,10 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
public void testIntersectionType3() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/intersectionType3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localVariableOfIntersectionType.kt")
|
||||
public void testLocalVariableOfIntersectionType() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/types/localVariableOfIntersectionType.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user