Removed 'implicit this' from scope for member lookup
This commit is contained in:
-7
@@ -262,16 +262,9 @@ public abstract class AbstractLazyMemberScope<D extends DeclarationDescriptor, D
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
|
public List<ReceiverParameterDescriptor> getImplicitReceiversHierarchy() {
|
||||||
ReceiverParameterDescriptor receiver = getImplicitReceiver();
|
|
||||||
if (receiver != null) {
|
|
||||||
return Collections.singletonList(receiver);
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
protected abstract ReceiverParameterDescriptor getImplicitReceiver();
|
|
||||||
|
|
||||||
// Do not change this, override in concrete subclasses:
|
// Do not change this, override in concrete subclasses:
|
||||||
// it is very easy to compromise laziness of this class, and fail all the debugging
|
// it is very easy to compromise laziness of this class, and fail all the debugging
|
||||||
// a generic implementation can't do this properly
|
// a generic implementation can't do this properly
|
||||||
|
|||||||
+1
@@ -243,6 +243,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
private JetScope computeScopeForMemberDeclarationResolution() {
|
private JetScope computeScopeForMemberDeclarationResolution() {
|
||||||
WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with 'this' for " + getName());
|
WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Scope with 'this' for " + getName());
|
||||||
thisScope.addLabeledDeclaration(this);
|
thisScope.addLabeledDeclaration(this);
|
||||||
|
thisScope.setImplicitReceiver(this.getThisAsReceiverParameter());
|
||||||
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
|
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||||
|
|
||||||
ClassDescriptor classObject = getClassObjectDescriptor();
|
ClassDescriptor classObject = getClassObjectDescriptor();
|
||||||
|
|||||||
-6
@@ -326,12 +326,6 @@ public class LazyClassMemberScope extends AbstractLazyMemberScope<LazyClassDescr
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected ReceiverParameterDescriptor getImplicitReceiver() {
|
|
||||||
return thisDescriptor.getThisAsReceiverParameter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public Set<ConstructorDescriptor> getConstructors() {
|
public Set<ConstructorDescriptor> getConstructors() {
|
||||||
ConstructorDescriptor constructor = getPrimaryConstructor();
|
ConstructorDescriptor constructor = getPrimaryConstructor();
|
||||||
|
|||||||
-5
@@ -49,11 +49,6 @@ public class LazyPackageMemberScope extends AbstractLazyMemberScope<PackageFragm
|
|||||||
return resolveSession.getScopeProvider().getFileScope(declaration.getContainingJetFile());
|
return resolveSession.getScopeProvider().getFileScope(declaration.getContainingJetFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ReceiverParameterDescriptor getImplicitReceiver() {
|
|
||||||
return ReceiverParameterDescriptor.NO_RECEIVER_PARAMETER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void getNonDeclaredFunctions(@NotNull Name name, @NotNull Set<FunctionDescriptor> result) {
|
protected void getNonDeclaredFunctions(@NotNull Name name, @NotNull Set<FunctionDescriptor> result) {
|
||||||
// No extra functions
|
// No extra functions
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
trait Bar {
|
||||||
|
fun <T> T.bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class A {
|
||||||
|
class object : Bar
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A.<error><error>bar</error></error>()
|
||||||
|
}
|
||||||
@@ -318,6 +318,11 @@ public class JetPsiCheckerTestGenerated extends AbstractJetPsiCheckerTest {
|
|||||||
doTest("idea/testData/checker/regression/DoubleDefine.kt");
|
doTest("idea/testData/checker/regression/DoubleDefine.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("extensionMemberInClassObject.kt")
|
||||||
|
public void testExtensionMemberInClassObject() throws Exception {
|
||||||
|
doTest("idea/testData/checker/regression/extensionMemberInClassObject.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("Jet11.kt")
|
@TestMetadata("Jet11.kt")
|
||||||
public void testJet11() throws Exception {
|
public void testJet11() throws Exception {
|
||||||
doTest("idea/testData/checker/regression/Jet11.kt");
|
doTest("idea/testData/checker/regression/Jet11.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user