[FIR] Add NO_THIS & INSTANCE_ACCESS_BEFORE_SUPER_CALL
This commit is contained in:
+1
-1
@@ -14,4 +14,4 @@ fun A.test_2() {
|
||||
object : B by b {}
|
||||
}
|
||||
|
||||
class D(val x: String, val y: String = this.<!UNRESOLVED_REFERENCE!>x<!>) {}
|
||||
class D(val x: String, val y: String = <!NO_THIS!>this<!>.<!UNRESOLVED_REFERENCE!>x<!>) {}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
class A {
|
||||
constructor(x: Int = <!UNRESOLVED_REFERENCE!>getSomeInt<!>(), other: A = <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>, header: String = <!UNRESOLVED_REFERENCE!>keker<!>) {}
|
||||
fun getSomeInt() = 10
|
||||
var keker = "test"
|
||||
}
|
||||
|
||||
class B(other: B = <!NO_THIS!>this<!>)
|
||||
|
||||
class C() {
|
||||
constructor(x: Int) : <!INAPPLICABLE_CANDIDATE!>this<!>({
|
||||
val a = 10
|
||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
|
||||
}) {}
|
||||
}
|
||||
|
||||
class D {
|
||||
var a = 20
|
||||
constructor() {
|
||||
this.a = 10
|
||||
}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val x1: String.() -> String = if (true) {
|
||||
{ <!NO_THIS!>this<!> }
|
||||
} else {
|
||||
{ <!NO_THIS!>this<!> }
|
||||
}
|
||||
}
|
||||
|
||||
fun test(f: F) {}
|
||||
|
||||
val a = <!NO_THIS!>this<!>
|
||||
|
||||
class F(var a: Int, b: Int, closure: () -> Unit, instance: F?) {
|
||||
constructor(x: Int) : this(x, x, {
|
||||
val a = 10
|
||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>
|
||||
test(<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>)
|
||||
<!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>.<!UNRESOLVED_REFERENCE!>a<!> = 20
|
||||
}, <!INSTANCE_ACCESS_BEFORE_SUPER_CALL!>this<!>) {
|
||||
this.a = 30
|
||||
}
|
||||
}
|
||||
|
||||
open class Base(val x: Int)
|
||||
|
||||
class Derived : Base(<!NO_THIS!>this<!>.<!UNRESOLVED_REFERENCE!>y<!>) { // FE 1.0 reports NO_THIS here
|
||||
val y = 42
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
FILE: instanceAccessBeforeSuperCall.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/Int| = <Unresolved name: getSomeInt>#(), other: R|A| = this@R|/A|, header: R|kotlin/String| = <Unresolved name: keker>#): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun getSomeInt(): R|kotlin/Int| {
|
||||
^getSomeInt Int(10)
|
||||
}
|
||||
|
||||
public final var keker: R|kotlin/String| = String(test)
|
||||
public get(): R|kotlin/String|
|
||||
public set(value: R|kotlin/String|): R|kotlin/Unit|
|
||||
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(other: R|B| = this#): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|kotlin/Any| {
|
||||
public constructor(): R|C| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public constructor(x: R|kotlin/Int|): R|C| {
|
||||
this<R|C|>(fun <anonymous>(): R|ERROR CLASS: Cannot access ''<this>'' before superclass constructor has been called| {
|
||||
lval a: R|kotlin/Int| = Int(10)
|
||||
^ this@R|/C|
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
public final class D : R|kotlin/Any| {
|
||||
public final var a: R|kotlin/Int| = Int(20)
|
||||
public get(): R|kotlin/Int|
|
||||
public set(value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
public constructor(): R|D| {
|
||||
super<R|kotlin/Any|>()
|
||||
this@R|/D|.R|/D.a| = Int(10)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
lval x1: R|kotlin/String.() -> kotlin/String| = when () {
|
||||
Boolean(true) -> {
|
||||
fun <anonymous>(it: R|kotlin/String|): R|ERROR CLASS: 'this' is not defined in this context| {
|
||||
^ this#
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
fun <anonymous>(it: R|kotlin/String|): R|ERROR CLASS: 'this' is not defined in this context| {
|
||||
^ this#
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(f: R|F|): R|kotlin/Unit| {
|
||||
}
|
||||
public final val a: R|ERROR CLASS: 'this' is not defined in this context| = this#
|
||||
public get(): R|ERROR CLASS: 'this' is not defined in this context|
|
||||
public final class F : R|kotlin/Any| {
|
||||
public constructor(a: R|kotlin/Int|, b: R|kotlin/Int|, closure: R|() -> kotlin/Unit|, instance: R|F?|): R|F| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final var a: R|kotlin/Int| = R|<local>/a|
|
||||
public get(): R|kotlin/Int|
|
||||
public set(value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
public constructor(x: R|kotlin/Int|): R|F| {
|
||||
this<R|F|>(R|<local>/x|, R|<local>/x|, fun <anonymous>(): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/Int| = Int(10)
|
||||
this@R|/F|
|
||||
R|/test|(this@R|/F|)
|
||||
this@R|/F|.<Unresolved name: a># = Int(20)
|
||||
}
|
||||
, this@R|/F|)
|
||||
this@R|/F|.R|/F.a| = Int(30)
|
||||
}
|
||||
|
||||
}
|
||||
public open class Base : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/Int|): R|Base| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = R|<local>/x|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
public final class Derived : R|Base| {
|
||||
public constructor(): R|Derived| {
|
||||
super<R|Base|>(this#.<Unresolved name: y>#)
|
||||
}
|
||||
|
||||
public final val y: R|kotlin/Int| = Int(42)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user