diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index a15eb4a46b0..97128c087d5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -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) } } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.kt b/compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.kt new file mode 100644 index 00000000000..ad72a5de69a --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.kt @@ -0,0 +1,8 @@ +class TestInitValInLambdaCalledOnce { + val x: Int + init { + 1.run { + x = 0 + } + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.txt b/compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.txt new file mode 100644 index 00000000000..f3f4f8c9826 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/runOnIntegerLiteral.txt @@ -0,0 +1,17 @@ +FILE: runOnIntegerLiteral.kt + public final class TestInitValInLambdaCalledOnce : R|kotlin/Any| { + public constructor(): R|TestInitValInLambdaCalledOnce| { + super() + } + + public final val x: R|kotlin/Int| + public get(): R|kotlin/Int| + + init { + Int(1).R|kotlin/run|( = run@fun R|kotlin/Int|.(): R|kotlin/Nothing| { + this@R|/TestInitValInLambdaCalledOnce|.R|/TestInitValInLambdaCalledOnce.x| = Int(0) + } + ) + } + + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index 57e504672de..5e87d21157a 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -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");