KT-8011 Compiler crashes on attempt to create local class inside lambda
- use StackValue from upper-level context if local lookup fails #KT-8011 Fixed
This commit is contained in:
@@ -2022,6 +2022,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
return stackValueForLocal(descriptor, index);
|
||||
}
|
||||
|
||||
return findCapturedValue(descriptor);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public StackValue findCapturedValue(@NotNull DeclarationDescriptor descriptor) {
|
||||
if (context instanceof ConstructorContext) {
|
||||
return lookupCapturedValueInConstructorParameters(descriptor);
|
||||
}
|
||||
|
||||
@@ -159,10 +159,17 @@ public interface LocalLookup {
|
||||
|
||||
@NotNull
|
||||
public StackValue outerValue(@NotNull EnclosedValueDescriptor d, @NotNull ExpressionCodegen codegen) {
|
||||
int idx = codegen.lookupLocalIndex(d.getDescriptor());
|
||||
assert idx != -1;
|
||||
|
||||
return StackValue.local(idx, d.getType());
|
||||
DeclarationDescriptor declarationDescriptor = d.getDescriptor();
|
||||
int idx = codegen.lookupLocalIndex(declarationDescriptor);
|
||||
if (idx >= 0) {
|
||||
return StackValue.local(idx, d.getType());
|
||||
}
|
||||
else {
|
||||
assert declarationDescriptor != null : "No declaration descriptor for " + d;
|
||||
StackValue capturedValue = codegen.findCapturedValue(declarationDescriptor);
|
||||
assert capturedValue != null : "Unresolved captured value for " + d;
|
||||
return capturedValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user