Fix CFA for destructuring declarations in scripts
in particular without the fix, the CFA skipped marking of the used result values in lambdas and they were coerced to unit in IR
This commit is contained in:
@@ -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 -> {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user