[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
@@ -2,7 +2,7 @@ sealed class My(open val x: Int?) {
init {
if (x != null) {
// Should be error: property is open
x.hashCode()
x.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
}
}
}
@@ -3,15 +3,15 @@ class Foo(var x: Int?) {
if (x != null) {
val y = x
// Error: x is not stable, Type(y) = Int?
x.hashCode()
y.hashCode()
x.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
y.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
if (y == x) {
// Still error
y.hashCode()
y.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
}
if (x == null && y != x) {
// Still error
y.hashCode()
y.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
}
}
}
@@ -7,15 +7,15 @@ class Foo(var x: Any) {
if (x is Bar) {
val y = x
// Error: x is not stable, Type(y) = Any
x.bar()
y.bar()
x.<!UNRESOLVED_REFERENCE!>bar<!>()
y.<!UNRESOLVED_REFERENCE!>bar<!>()
if (y == x) {
// Still error
y.bar()
y.<!UNRESOLVED_REFERENCE!>bar<!>()
}
if (x !is Bar && y != x) {
// Still error
y.bar()
y.<!UNRESOLVED_REFERENCE!>bar<!>()
}
}
}