FIR: resolve anonymous initializer in context independent mode

This commit is contained in:
Mikhail Glukhikh
2019-12-19 14:57:45 +03:00
parent 99643e1b2d
commit ada7f3da6c
4 changed files with 31 additions and 1 deletions
@@ -372,7 +372,7 @@ class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransformer)
return withScopeCleanup(localScopes) {
dataFlowAnalyzer.enterInitBlock(anonymousInitializer)
localScopes.addIfNotNull(primaryConstructorParametersScope)
transformDeclaration(anonymousInitializer, data).also {
transformDeclaration(anonymousInitializer, ResolutionMode.ContextIndependent).also {
dataFlowAnalyzer.exitInitBlock(it.single as FirAnonymousInitializer)
}
}
@@ -0,0 +1,8 @@
class TestInitValInLambdaCalledOnce {
val x: Int
init {
1.run {
x = 0
}
}
}
@@ -0,0 +1,17 @@
FILE: runOnIntegerLiteral.kt
public final class TestInitValInLambdaCalledOnce : R|kotlin/Any| {
public constructor(): R|TestInitValInLambdaCalledOnce| {
super<R|kotlin/Any|>()
}
public final val x: R|kotlin/Int|
public get(): R|kotlin/Int|
init {
Int(1).R|kotlin/run|<R|kotlin/Int|, R|kotlin/Nothing|>(<L> = run@fun R|kotlin/Int|.<anonymous>(): R|kotlin/Nothing| <kind=EXACTLY_ONCE> {
this@R|/TestInitValInLambdaCalledOnce|.R|/TestInitValInLambdaCalledOnce.x| = Int(0)
}
)
}
}
@@ -173,6 +173,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
runTest("compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.kt");
}
@TestMetadata("runOnIntegerLiteral.kt")
public void testRunOnIntegerLiteral() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.kt");
}
@TestMetadata("simpleDelegateProvider.kt")
public void testSimpleDelegateProvider() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/stdlib/simpleDelegateProvider.kt");