diff --git a/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt index bdeaee6c49c..f1e784c78c1 100644 --- a/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt +++ b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowProcessor.kt @@ -1329,7 +1329,7 @@ class ControlFlowProcessor( override fun visitObjectDeclaration(objectDeclaration: KtObjectDeclaration) { generateHeaderDelegationSpecifiers(objectDeclaration) - generateInitializersForScriptClassOrObject(objectDeclaration) + generateInitializersForClassOrObject(objectDeclaration) generateDeclarationForLocalClassOrObjectIfNeeded(objectDeclaration) } @@ -1363,7 +1363,7 @@ class ControlFlowProcessor( } } - private fun generateInitializersForScriptClassOrObject(classOrObject: KtDeclarationContainer) { + private fun generateInitializersForClassOrObject(classOrObject: KtDeclarationContainer) { for (declaration in classOrObject.declarations) { if (declaration is KtProperty || declaration is KtAnonymousInitializer) { generateInstructions(declaration) @@ -1389,7 +1389,7 @@ class ControlFlowProcessor( // delegation specifiers of primary constructor, anonymous class and property initializers generateHeaderDelegationSpecifiers(klass) - generateInitializersForScriptClassOrObject(klass) + generateInitializersForClassOrObject(klass) } generateDeclarationForLocalClassOrObjectIfNeeded(klass) @@ -1409,7 +1409,11 @@ class ControlFlowProcessor( } override fun visitScript(script: KtScript) { - generateInitializersForScriptClassOrObject(script) + for (declaration in script.declarations) { + if (declaration is KtProperty || declaration is KtAnonymousInitializer || declaration is KtDestructuringDeclaration) { + generateInstructions(declaration) + } + } } private fun generateDeclarationForLocalClassOrObjectIfNeeded(classOrObject: KtClassOrObject) { @@ -1440,7 +1444,7 @@ class ControlFlowProcessor( generateCallOrMarkUnresolved(constructor.getDelegationCall()) if (!constructor.getDelegationCall().isCallToThis) { - generateInitializersForScriptClassOrObject(classOrObject) + generateInitializersForClassOrObject(classOrObject) } generateInstructions(constructor.bodyExpression) @@ -1577,7 +1581,7 @@ class ControlFlowProcessor( when (kind) { ExplicitReceiverKind.DISPATCH_RECEIVER -> explicitReceiver = resolvedCall.dispatchReceiver ExplicitReceiverKind.EXTENSION_RECEIVER, ExplicitReceiverKind.BOTH_RECEIVERS -> explicitReceiver = - resolvedCall.extensionReceiver + resolvedCall.extensionReceiver ExplicitReceiverKind.NO_EXPLICIT_RECEIVER -> { } }