[FIR] Split primary constructor parameter scope into two different
In init block or property initializers, for `val x` declared in primary constructor, `x` reference is now resolved to property, not to parameter. So we need two different scopes for primary constructor, one for 'pure' parameters and another one for all parameters, including val/var ones. #KT-42844 Fixed
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ FILE: simpleDelegatedToMap.kt
|
||||
public final val map: R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>| = R|<local>/map|
|
||||
public get(): R|kotlin/collections/MutableMap<kotlin/String, kotlin/Any>|
|
||||
|
||||
public final var foo: R|kotlin/Any|by R|<local>/map|
|
||||
public final var foo: R|kotlin/Any|by this@R|/C|.R|/C.map|
|
||||
public get(): R|kotlin/Any| {
|
||||
^ this@R|/C|.D|/C.foo|.R|kotlin/collections/getValue|<R|kotlin/Any|, R|kotlin/Any|>(this@R|/C|, ::R|/C.foo|)
|
||||
}
|
||||
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
class Some(var foo: Int) {
|
||||
init {
|
||||
if (foo < 0) {
|
||||
foo = 0
|
||||
}
|
||||
}
|
||||
|
||||
val y = run {
|
||||
foo = 1
|
||||
foo
|
||||
}
|
||||
|
||||
constructor(): this(-1) {
|
||||
foo = 2
|
||||
}
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
FILE: constructorVarWrite.kt
|
||||
public final class Some : R|kotlin/Any| {
|
||||
public constructor(foo: R|kotlin/Int|): R|Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final var foo: R|kotlin/Int| = R|<local>/foo|
|
||||
public get(): R|kotlin/Int|
|
||||
public set(value: R|kotlin/Int|): R|kotlin/Unit|
|
||||
|
||||
init {
|
||||
when () {
|
||||
CMP(<, this@R|/Some|.R|/Some.foo|.R|kotlin/Int.compareTo|(Int(0))) -> {
|
||||
this@R|/Some|.R|/Some.foo| = Int(0)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final val y: R|kotlin/Int| = this@R|/Some|.R|kotlin/run|<R|Some|, R|kotlin/Int|>(<L> = run@fun R|Some|.<anonymous>(): R|kotlin/Int| <kind=EXACTLY_ONCE> {
|
||||
this@R|special/anonymous|.R|/Some.foo| = Int(1)
|
||||
^ this@R|special/anonymous|.R|/Some.foo|
|
||||
}
|
||||
)
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
public constructor(): R|Some| {
|
||||
this<R|Some|>(Int(-1))
|
||||
this@R|/Some|.R|/Some.foo| = Int(2)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user