[FIR] Fix INSTANCE_ACCESS_BEFORE_SUPER_CALL

This commit is contained in:
Nikolay Lunyak
2021-09-24 16:50:51 +00:00
committed by Space
parent 9790b81f38
commit 1a9f63efeb
10 changed files with 9 additions and 16 deletions
@@ -261,7 +261,7 @@ class BodyResolveContext(
) {
if (owningClass == null) return
addReceiver(
name = null,
name = owningClass.name,
implicitReceiverValue = InaccessibleImplicitReceiverValue(
owningClass.symbol,
owningClass.defaultType(),
@@ -7,7 +7,7 @@ open class Base<T>(p: Any?) {
class D: Base<Int>(1) {
inner class B : Base<Int> {
constructor() : super(foo1(1))
constructor(x: Int) : super(this<!UNRESOLVED_LABEL!>@B<!>.foo1(1))
constructor(x: Int) : super(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@B<!>.foo1(1))
constructor(x: Int, y: Int) : super(this@D.foo1(1))
}
}
@@ -7,6 +7,6 @@ fun Base.foo() {
class B : Base {
constructor() : super(foo1())
constructor(x: Int) : super(this@foo.foo1())
constructor(x: Int, y: Int) : super(this<!UNRESOLVED_LABEL!>@B<!>.foo1())
constructor(x: Int, y: Int) : super(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@B<!>.foo1())
}
}
@@ -8,6 +8,6 @@ fun Base<Int>.foo() {
constructor() : super(foo1(<!ARGUMENT_TYPE_MISMATCH!>""<!>))
constructor(x: Int) : super(foo1(1))
constructor(x: Int, y: Int) : super(this@foo.foo1(12))
constructor(x: Int, y: Int, z: Int) : super(this<!UNRESOLVED_LABEL!>@B<!>.foo1(""))
constructor(x: Int, y: Int, z: Int) : super(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@B<!>.foo1(""))
}
}
@@ -9,7 +9,7 @@ class A {
{
<!ARGUMENT_TYPE_MISMATCH, TYPE_MISMATCH!><!UNRESOLVED_REFERENCE!>foo<!>() +
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.foo() +
this<!UNRESOLVED_LABEL!>@A<!>.foo() +
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@A<!>.foo() +
<!UNRESOLVED_REFERENCE!>foobar<!>()<!>
})
}
@@ -6,7 +6,7 @@ class A {
fun foo() = 1
constructor(x: Any?)
constructor() : this(object {
fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + this<!UNRESOLVED_LABEL!>@A<!>.foo() +
fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@A<!>.foo() +
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foobar<!>() + super<!UNRESOLVED_LABEL!>@A<!>.hashCode()
})
}
@@ -5,7 +5,7 @@ fun A.foobar() = 3
class A {
fun foo() = 1
constructor( x: Any = object {
fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + this<!UNRESOLVED_LABEL!>@A<!>.foo() +
fun bar() = <!UNRESOLVED_REFERENCE!>foo<!>() + <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@A<!>.foo() +
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foobar<!>()
})
}
@@ -1,8 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(x: A) = 1
class A {
constructor(x: Int)
constructor(x: Int, y: Int, z: Int = x + foo(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) + foo(this<!UNRESOLVED_LABEL!>@A<!>)) :
this(x + foo(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) + foo(this<!UNRESOLVED_LABEL!>@A<!>))
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun foo(x: A) = 1
@@ -10,6 +10,6 @@ class A {
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.foobar() +
<!UNRESOLVED_REFERENCE!>prop<!> +
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.prop +
this<!UNRESOLVED_LABEL!>@A<!>.prop<!>
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this@A<!>.prop<!>
)
}