Vars modified in closures are marked with a MUST_BE_WRAPPED_IN_A_REF key
This commit is contained in:
@@ -44,9 +44,12 @@ public interface BindingContext {
|
||||
WritableSlice<JetExpression, Boolean> PROCESSED = Slices.createSimpleSetSlice("PROCESSED");
|
||||
WritableSlice<JetElement, Boolean> STATEMENT = Slices.createRemovableSetSlice("STATEMENT");
|
||||
WritableSlice<CallableMemberDescriptor, Boolean> DELEGATED = Slices.createRemovableSetSlice("DELEGATED");
|
||||
|
||||
WritableSlice<VariableDescriptor, Boolean> MUST_BE_WRAPPED_IN_A_REF = Slices.createSimpleSetSlice("MUST_BE_WRAPPED_IN_A_REF");
|
||||
|
||||
enum DeferredTypeKey {DEFERRED_TYPE_KEY}
|
||||
WritableSlice<DeferredTypeKey, Collection<DeferredType>> DEFERRED_TYPES = Slices.createSimpleSlice("DEFERRED_TYPES");
|
||||
|
||||
WritableSlice<DeferredTypeKey, DeferredType> DEFERRED_TYPE = new CollectionSliceWrapper<DeferredTypeKey, DeferredType>(DEFERRED_TYPES, CommonSuppliers.<DeferredType>getArrayListSupplier());
|
||||
|
||||
WritableSlice<PropertyDescriptor, Boolean> BACKING_FIELD_REQUIRED = new Slices.SetSlice<PropertyDescriptor>("BACKING_FIELD_REQUIRED", RewritePolicy.DO_NOTHING) {
|
||||
|
||||
@@ -2815,13 +2815,20 @@ public class JetTypeInferrer {
|
||||
// }
|
||||
}
|
||||
if (left instanceof JetSimpleNameExpression) {
|
||||
JetSimpleNameExpression variable = (JetSimpleNameExpression) left;
|
||||
String referencedName = variable.getReferencedName();
|
||||
if (variable.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER
|
||||
JetSimpleNameExpression simpleName = (JetSimpleNameExpression) left;
|
||||
String referencedName = simpleName.getReferencedName();
|
||||
if (simpleName.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER
|
||||
&& referencedName != null) {
|
||||
PropertyDescriptor property = context.scope.getPropertyByFieldReference(referencedName);
|
||||
if (property != null) {
|
||||
context.trace.record(BindingContext.VARIABLE_ASSIGNMENT, variable, property);
|
||||
context.trace.record(BindingContext.VARIABLE_ASSIGNMENT, simpleName, property);
|
||||
}
|
||||
}
|
||||
VariableDescriptor variable = AutoCastUtils.getVariableDescriptorFromSimpleName(context.trace.getBindingContext(), simpleName);
|
||||
if (variable != null) {
|
||||
DeclarationDescriptor containingDeclaration = variable.getContainingDeclaration();
|
||||
if (context.scope.getContainingDeclaration() != containingDeclaration && containingDeclaration instanceof CallableDescriptor) {
|
||||
context.trace.record(MUST_BE_WRAPPED_IN_A_REF, variable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user