[FIR] Add separate local scope for init blocks
This commit is contained in:
+1
@@ -451,6 +451,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
|
|||||||
return withLocalScopeCleanup {
|
return withLocalScopeCleanup {
|
||||||
dataFlowAnalyzer.enterInitBlock(anonymousInitializer)
|
dataFlowAnalyzer.enterInitBlock(anonymousInitializer)
|
||||||
addLocalScope(primaryConstructorParametersScope)
|
addLocalScope(primaryConstructorParametersScope)
|
||||||
|
addLocalScope(FirLocalScope())
|
||||||
transformDeclaration(anonymousInitializer, ResolutionMode.ContextIndependent).also {
|
transformDeclaration(anonymousInitializer, ResolutionMode.ContextIndependent).also {
|
||||||
dataFlowAnalyzer.exitInitBlock(it.single as FirAnonymousInitializer)
|
dataFlowAnalyzer.exitInitBlock(it.single as FirAnonymousInitializer)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class WithC() {
|
|||||||
val a : Int get() = 1
|
val a : Int get() = 1
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val z = b
|
val z = <!UNRESOLVED_REFERENCE!>b<!>
|
||||||
val zz = x
|
val zz = x
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -57,8 +57,8 @@ class Test5 {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
val x: String
|
val x: String
|
||||||
<!UNRESOLVED_REFERENCE!>x<!> = ""
|
x = ""
|
||||||
z = <!UNRESOLVED_REFERENCE!>x<!>
|
z = x
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(y: Int) {
|
constructor(y: Int) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
class Your {
|
class Your {
|
||||||
init {
|
init {
|
||||||
var y: String? = "xyz"
|
var y: String? = "xyz"
|
||||||
if (<!UNRESOLVED_REFERENCE!>y<!> != null) {
|
if (y != null) {
|
||||||
// Bug that should be fixed
|
// Bug that should be fixed
|
||||||
// Problem: descriptorToDeclaration cannot get here init block by its descriptor
|
// Problem: descriptorToDeclaration cannot get here init block by its descriptor
|
||||||
// See PreliminaryDeclarationVisitor.getVisitorByVariable
|
// See PreliminaryDeclarationVisitor.getVisitorByVariable
|
||||||
<!UNRESOLVED_REFERENCE!>y<!>.<!UNRESOLVED_REFERENCE!>hashCode<!>()
|
y.hashCode()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user