[FIR] Use tower to resolve delegated constructors, set dispatch receiver

This commit is contained in:
Mikhail Glukhikh
2020-04-10 18:29:14 +03:00
parent 0b8c497d2e
commit 457fb09e3a
60 changed files with 226 additions and 106 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Outer() {
open inner class InnerBase() {
}
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A() {
open inner class InnerA
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Outer() {
val s = "xyzzy"
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
interface Test {
fun test(): String
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// FILE: JavaClass.java
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A1(y: String) {
val x = "A1.x,$y"
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class A(val s: String) {
open inner class B(s: String): A(s)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class Father(val param: String) {
abstract inner class InClass {
fun work(): String {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class Father(val param: String) {
abstract inner class InClass {
fun work(): String {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
abstract class Father {
abstract inner class InClass {
abstract fun work(): String
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
abstract class Father {
abstract inner class InClass {
abstract fun work(): String
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
fun bar(): Any {
return {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
open class Father(val param: String) {
abstract inner class InClass {
fun work(): String {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
open inner class Inner(val result: String)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
open inner class Inner(val result: String = "OK", val int: Int)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
fun bar(): Any {
return {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
fun box(): String {
class Local : Inner() {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// IGNORE_BACKEND: JVM
class A(val x: String) {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class A {
val x: Any get() {
return object : Inner() {
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Outer(val x: String) {
abstract inner class InnerBase
@@ -1,30 +0,0 @@
// !LANGUAGE: +NewInference
open class A<T1, T2> {
open inner class A1(val a1: T1)
open inner class A2(val a2: T2)
open fun f1(arg: T1) = arg
open fun f2(arg: T2) = arg
}
open class B<T> : A<T, Int>() {
open inner class B1(b1: T) : <!INAPPLICABLE_CANDIDATE!>A1<!>(b1)
open inner class B2(b2: Int) : <!INAPPLICABLE_CANDIDATE!>A2<!>(b2)
fun variableToKnownParameter(p: T): Int =
p as? Int ?: 0
inner class B3(b3: T) : <!INAPPLICABLE_CANDIDATE!>A2<!>(variableToKnownParameter(b3))
override fun f1(arg: T) = arg
override fun f2(arg: Int) = arg
}
class C : B<String>() {
inner class C1(c1: String): <!INAPPLICABLE_CANDIDATE!>B1<!>(c1)
inner class C2 : B2(15)
override fun f1(arg: String) = arg
override fun f2(arg: Int) = arg
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
open class A<T1, T2> {
@@ -1,9 +0,0 @@
// !LANGUAGE: +NewInference
abstract class TestType<V: Any> {
open inner class Inner(val item: V)
}
class Derived: TestType<Long>() {
inner class DerivedInner(item: Long): <!INAPPLICABLE_CANDIDATE!>Inner<!>(item)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
abstract class TestType<V: Any> {
@@ -1,6 +1,6 @@
class Test {
@`InnerAnnotation` @InnerAnnotation
companion object : StaticClass(), InnerClass() {
companion object : StaticClass(), <!UNRESOLVED_REFERENCE!>InnerClass<!>() {
}
@@ -5,8 +5,8 @@ class TestSome<P> {
}
class Test {
companion object : InnerClass() {
val a = object: InnerClass() {
companion object : <!UNRESOLVED_REFERENCE!>InnerClass<!>() {
val a = object: <!UNRESOLVED_REFERENCE!>InnerClass<!>() {
}
fun more(): InnerClass {
@@ -5,8 +5,8 @@ class TestSome<P> {
}
class Test {
object Some : InnerClass() {
val a = object: InnerClass() {
object Some : <!UNRESOLVED_REFERENCE!>InnerClass<!>() {
val a = object: <!UNRESOLVED_REFERENCE!>InnerClass<!>() {
}
fun more(): InnerClass {
+1 -1
View File
@@ -7,7 +7,7 @@ class Outer {
class Nested1 : OpenNested()
class Nested2 : FinalNested()
class Nested3 : OpenInner()
class Nested3 : <!UNRESOLVED_REFERENCE!>OpenInner<!>()
class Nested4 : FinalInner()
inner class Inner1 : OpenNested()
@@ -2,6 +2,6 @@ class A {
open inner class Inner
class Nested : Inner {
constructor()
<!UNRESOLVED_REFERENCE!>constructor()<!>
}
}
@@ -31,6 +31,7 @@ FILE fqName:<root> fileName:/innerClass.kt
$outer: VALUE_PARAMETER name:<this> type:<root>.Outer
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Outer.TestInnerClass'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.Outer' type=<root>.Outer origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DerivedInnerClass modality:FINAL visibility:public [inner] superTypes:[<root>.Outer.TestInnerClass]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
@@ -28,6 +28,7 @@ FILE fqName:<root> fileName:/innerClassWithDelegatingConstructor.kt
$outer: VALUE_PARAMETER name:<this> type:<root>.Outer
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (x: kotlin.Int) [primary] declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.Outer' type=<root>.Outer origin=null
x: CONST Int type=kotlin.Int value=0
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
@@ -121,6 +121,7 @@ FILE fqName:<root> fileName:/objectLiteralExpressions.kt
CONSTRUCTOR visibility:private <> () returnType:<root>.Outer.test3.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.Outer.test3' type=<root>.Outer origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Outer.Inner]'
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.Outer.test3.<no name provided>) returnType:kotlin.Unit
overridden:
@@ -166,6 +167,7 @@ FILE fqName:<root> fileName:/objectLiteralExpressions.kt
CONSTRUCTOR visibility:private <> () returnType:<root>.test4.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.test4' type=<root>.Outer origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Outer.Inner]'
FUN name:foo visibility:public modality:FINAL <> ($this:<root>.test4.<no name provided>) returnType:kotlin.Unit
overridden:
@@ -90,6 +90,7 @@ FILE fqName:<root> fileName:/constructor.kt
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (z: Z of <root>.Test2.TestInner) [primary] declared in <root>.Test2.TestInner'
<Z>: <none>
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2 origin=null
z: GET_VAR 'z: Z of <root>.Test2.TestInner declared in <root>.Test2.TestInner.<init>' type=Z of <root>.Test2.TestInner origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
@@ -31,6 +31,7 @@ FILE fqName:<root> fileName:/kt16905.kt
$outer: VALUE_PARAMETER name:<this> type:<root>.Outer
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.Outer' type=<root>.Outer origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:InnerDerived0 modality:FINAL visibility:public [inner] superTypes:[<root>.Outer.Inner]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
@@ -51,6 +52,7 @@ FILE fqName:<root> fileName:/kt16905.kt
$outer: VALUE_PARAMETER name:<this> type:<root>.Outer
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.Outer' type=<root>.Outer origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:InnerDerived1 modality:FINAL visibility:public [inner] superTypes:[<root>.Outer.Inner]'
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
@@ -79,6 +79,7 @@ FILE fqName:<root> fileName:/multipleThisReferences.kt
CONSTRUCTOR visibility:private <> () returnType:<root>.Host.test.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (x: kotlin.Int) [primary] declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer declared in <root>.Host.test' type=<root>.Outer origin=null
x: CONST Int type=kotlin.Int value=42
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Outer.Inner]'
PROPERTY name:xx visibility:public modality:FINAL [val]
@@ -72,7 +72,8 @@ FILE fqName:<root> fileName:/thisOfGenericOuterClass.kt
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test.<no name provided>
CONSTRUCTOR visibility:private <> () returnType:<root>.test.<no name provided> [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (y: kotlin.Int) [primary] declared in <root>.Outer.Inner'
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (y: kotlin.Int) declared in <root>.Outer.Inner'
$this: GET_VAR '<this>: <root>.Outer<kotlin.Int> declared in <root>.test' type=<root>.Outer<kotlin.Int> origin=null
y: CONST Int type=kotlin.Int value=42
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:<no name provided> modality:FINAL visibility:local superTypes:[<root>.Outer.Inner<kotlin.Int>]'
PROPERTY name:xx visibility:public modality:FINAL [val]