FIR: resolve anonymous initializer in context independent mode
This commit is contained in:
+1
-1
@@ -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)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user