7b4f781ea8
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
18 lines
533 B
Kotlin
Vendored
18 lines
533 B
Kotlin
Vendored
class Foo(var x: Int?) {
|
|
init {
|
|
if (x != null) {
|
|
val y = x
|
|
// Error: x is not stable, Type(y) = Int?
|
|
x.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
|
y.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
|
if (y == x) {
|
|
// Still error
|
|
y.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
|
}
|
|
if (x == null && y != x) {
|
|
// Still error
|
|
y.<!INAPPLICABLE_CANDIDATE!>hashCode<!>()
|
|
}
|
|
}
|
|
}
|
|
} |