Treat field initializer as class initializer
when checking for allowance of other field initialization in lambda with EXACTLY_ONCE contract. #KT-40948 Fixed
This commit is contained in:
+3
-1
@@ -60,7 +60,9 @@ class CapturingInClosureChecker : CallChecker {
|
||||
if (variable !is PropertyDescriptor || scopeContainer !is AnonymousFunctionDescriptor || variable.isVar) return
|
||||
if (!isLhsOfAssignment(nameElement as KtExpression)) return
|
||||
val scopeDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(scopeContainer) as? KtFunction ?: return
|
||||
if (scopeContainer.containingDeclaration !is ConstructorDescriptor) return
|
||||
if (scopeContainer.containingDeclaration !is ConstructorDescriptor &&
|
||||
scopeContainer.containingDeclaration !is PropertyDescriptor
|
||||
) return
|
||||
if (!isExactlyOnceContract(trace.bindingContext, scopeDeclaration)) return
|
||||
if (trace.bindingContext[CAPTURED_IN_CLOSURE, variable] == CaptureKind.NOT_INLINE) return
|
||||
val (callee, param) = getCalleeDescriptorAndParameter(trace.bindingContext, scopeDeclaration) ?: return
|
||||
|
||||
Reference in New Issue
Block a user