Correct scope for property accessors in lazy resolve
This commit is contained in:
@@ -161,11 +161,11 @@ public class TopDownAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
private void registerScope(@Nullable JetDeclaration declaration, @NotNull JetDeclaration anchorForScope) {
|
||||
private void registerScope(@Nullable JetDeclaration declaration) {
|
||||
if (declaration == null) return;
|
||||
c.registerDeclaringScope(
|
||||
declaration,
|
||||
resolveSession.getScopeProvider().getResolutionScopeForDeclaration(anchorForScope)
|
||||
resolveSession.getScopeProvider().getResolutionScopeForDeclaration(declaration)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ public class TopDownAnalyzer {
|
||||
|
||||
@Override
|
||||
public void visitAnonymousInitializer(@NotNull JetClassInitializer initializer) {
|
||||
registerScope(initializer, initializer);
|
||||
registerScope(initializer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -272,7 +272,7 @@ public class TopDownAnalyzer {
|
||||
(SimpleFunctionDescriptor) resolveSession.resolveToDescriptor(function)
|
||||
)
|
||||
);
|
||||
registerScope(function, function);
|
||||
registerScope(function);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -284,9 +284,9 @@ public class TopDownAnalyzer {
|
||||
c.getProperties().put(property, descriptor);
|
||||
registerTopLevelFqName(property, descriptor);
|
||||
|
||||
registerScope(property, property);
|
||||
registerScope(property.getGetter(), property);
|
||||
registerScope(property.getSetter(), property);
|
||||
registerScope(property);
|
||||
registerScope(property.getGetter());
|
||||
registerScope(property.getSetter());
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -126,6 +126,11 @@ public class ScopeProvider {
|
||||
"For JetDeclaration element getParentOfType() should return itself.";
|
||||
|
||||
JetDeclaration parentDeclaration = PsiTreeUtil.getParentOfType(jetDeclaration, JetDeclaration.class);
|
||||
|
||||
if (jetDeclaration instanceof JetPropertyAccessor) {
|
||||
parentDeclaration = PsiTreeUtil.getParentOfType(parentDeclaration, JetDeclaration.class);
|
||||
}
|
||||
|
||||
if (parentDeclaration == null) {
|
||||
return getFileScope((JetFile) elementOfDeclaration.getContainingFile());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo(val a: Int, b: Int) {
|
||||
val c = a + b
|
||||
|
||||
val d: Int
|
||||
get() = a
|
||||
|
||||
val e: Int
|
||||
get() = <!UNRESOLVED_REFERENCE!>b<!>
|
||||
}
|
||||
@@ -364,6 +364,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest("compiler/testData/diagnostics/tests/Properties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("PropertyInitializers.kt")
|
||||
public void testPropertyInitializers() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/PropertyInitializers.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("QualifiedExpressions.kt")
|
||||
public void testQualifiedExpressions() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/QualifiedExpressions.kt");
|
||||
|
||||
Reference in New Issue
Block a user