[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:
Mikhail Glukhikh
2020-10-21 10:39:59 +03:00
parent 2d0535a713
commit 7b4f781ea8
24 changed files with 592 additions and 426 deletions
@@ -20,11 +20,11 @@ FILE: RedundantSingleExpressionStringTemplateChecker.kt
public get(): R|ProductGroup?|
public final val name: R|kotlin/String| = when () {
==(R|<local>/parent|, Null(null)) -> {
R|<local>/short_name|
==(this@R|/ProductGroup|.R|/ProductGroup.parent|, Null(null)) -> {
this@R|/ProductGroup|.R|/ProductGroup.short_name|
}
else -> {
<strcat>(R|<local>/parent|.R|/ProductGroup.name|.R|kotlin/Any.toString|(), String( ), R|<local>/short_name|.R|kotlin/Any.toString|())
<strcat>(this@R|/ProductGroup|.R|/ProductGroup.parent|.R|/ProductGroup.name|.R|kotlin/Any.toString|(), String( ), this@R|/ProductGroup|.R|/ProductGroup.short_name|.R|kotlin/Any.toString|())
}
}
@@ -47,7 +47,7 @@ FILE: propertyTypeMismatchOnOverride.kt
public final val value: R|T| = R|<local>/value|
public get(): R|T|
public final override var test: R|T| = R|<local>/value|
public final override var test: R|T| = this@R|/E|.R|/E.value|
public get(): R|T|
public set(value: R|T|): R|kotlin/Unit|
@@ -60,7 +60,7 @@ FILE: propertyTypeMismatchOnOverride.kt
public final val value: R|T| = R|<local>/value|
public get(): R|T|
public open var rest: R|T| = R|<local>/value|
public open var rest: R|T| = this@R|/F|.R|/F.value|
public get(): R|T|
public set(value: R|T|): R|kotlin/Unit|
@@ -73,7 +73,7 @@ FILE: propertyTypeMismatchOnOverride.kt
public final val balue: R|E| = R|<local>/balue|
public get(): R|E|
public final override var rest: R|E| = R|<local>/balue|
public final override var rest: R|E| = this@R|/G|.R|/G.balue|
public get(): R|E|
public set(value: R|E|): R|kotlin/Unit|
@@ -86,7 +86,7 @@ FILE: propertyTypeMismatchOnOverride.kt
public final val balue: R|E| = R|<local>/balue|
public get(): R|E|
public final override var rest: R|E| = R|<local>/balue|
public final override var rest: R|E| = this@R|/H|.R|/H.balue|
public get(): R|E|
public set(value: R|E|): R|kotlin/Unit|
@@ -99,7 +99,7 @@ FILE: propertyTypeMismatchOnOverride.kt
public final val balue: R|E| = R|<local>/balue|
public get(): R|E|
public final override var rest: R|E| = R|<local>/balue|
public final override var rest: R|E| = this@R|/M|.R|/M.balue|
public get(): R|E|
public set(value: R|E|): R|kotlin/Unit|
@@ -47,7 +47,7 @@ FILE: repeatedModifier.kt
private final val int: R|kotlin/Int| = R|<local>/int|
private get(): R|kotlin/Int|
protected final var double: R|kotlin/Double| = R|<local>/int|.R|kotlin/Int.plus|(Double(8.0))
protected final var double: R|kotlin/Double| = this@R|/E|.R|/E.int|.R|kotlin/Int.plus|(Double(8.0))
protected get(): R|kotlin/Double|
protected set(value: R|kotlin/Double|): R|kotlin/Unit|
@@ -29,7 +29,7 @@ FILE: CallBasedInExpressionGenerator.kt
public final val codegen: R|org/jetbrains/kotlin/codegen/range/inExpression/ExpressionCodegen| = R|<local>/codegen|
public get(): R|org/jetbrains/kotlin/codegen/range/inExpression/ExpressionCodegen|
private final val resolvedCall: R|ERROR CLASS: Unresolved name: getResolvedCallWithAssert| = R|<local>/operatorReference|.<Unresolved name: getResolvedCallWithAssert>#(R|<local>/codegen|.<Unresolved name: bindingContext>#)
private final val resolvedCall: R|ERROR CLASS: Unresolved name: getResolvedCallWithAssert| = R|<local>/operatorReference|.<Unresolved name: getResolvedCallWithAssert>#(this@R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator|.R|org/jetbrains/kotlin/codegen/range/inExpression/CallBasedInExpressionGenerator.codegen|.<Unresolved name: bindingContext>#)
private get(): R|ERROR CLASS: Unresolved name: getResolvedCallWithAssert|
private final val isInverted: R|kotlin/Boolean| = ==(R|<local>/operatorReference|.<Unresolved name: getReferencedNameElementType>#(), <Unresolved name: KtTokens>#.<Unresolved name: NOT_IN>#)
@@ -58,7 +58,7 @@ FILE: enums.kt
}
public final val g: R|kotlin/Double| = this@R|/Planet.Companion|.R|/Planet.Companion.G|.R|kotlin/Double.times|(R|<local>/m|).R|kotlin/Double.div|(R|<local>/r|.R|kotlin/Double.times|(R|<local>/r|))
public final val g: R|kotlin/Double| = this@R|/Planet.Companion|.R|/Planet.Companion.G|.R|kotlin/Double.times|(this@R|/Planet|.R|/Planet.m|).R|kotlin/Double.div|(this@R|/Planet|.R|/Planet.r|.R|kotlin/Double.times|(this@R|/Planet|.R|/Planet.r|))
public get(): R|kotlin/Double|
public abstract fun sayHello(): R|kotlin/Unit|
@@ -46,9 +46,9 @@ FILE: KotlinClass.kt
public get(): R|JavaClass?|
public final val x: R|(KotlinClass) -> kotlin/Boolean| = when () {
!=(R|<local>/javaClass|, Null(null)) -> {
!=(this@R|/Case1|.R|/Case1.javaClass|, Null(null)) -> {
fun <anonymous>(it: R|KotlinClass|): R|kotlin/Boolean| {
^ ==(R|<local>/it|, R|<local>/javaClass|)
^ ==(R|<local>/it|, this@R|/Case1|.R|/Case1.javaClass|)
}
}
@@ -139,9 +139,9 @@ FILE: KotlinClass.kt
public get(): R|KotlinClass?|
public final val x: R|(KotlinClass) -> kotlin/Boolean| = when () {
!=(R|<local>/kotlinClass|, Null(null)) -> {
!=(this@R|/Case2|.R|/Case2.kotlinClass|, Null(null)) -> {
fun <anonymous>(it: R|KotlinClass|): R|kotlin/Boolean| {
^ ==(R|<local>/it|, R|<local>/kotlinClass|)
^ ==(R|<local>/it|, this@R|/Case2|.R|/Case2.kotlinClass|)
}
}
@@ -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|)
}
@@ -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
}
}
@@ -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)
}
}