Not ignoring other properties in scope.

First one (almost randomly) was chosen instead of ambiguity.
This commit is contained in:
Evgeny Gerashchenko
2013-09-11 00:04:02 +04:00
parent 48e96aece3
commit e4d8e4d61b
4 changed files with 34 additions and 16 deletions
@@ -195,16 +195,6 @@ public class DescriptorUtils {
return false; return false;
} }
@Nullable
public static VariableDescriptor filterNonExtensionProperty(Collection<VariableDescriptor> variables) {
for (VariableDescriptor variable : variables) {
if (variable.getReceiverParameter() == null) {
return variable;
}
}
return null;
}
@NotNull @NotNull
public static JetType getFunctionExpectedReturnType(@NotNull FunctionDescriptor descriptor, @NotNull JetElement function) { public static JetType getFunctionExpectedReturnType(@NotNull FunctionDescriptor descriptor, @NotNull JetElement function) {
JetType expectedType; JetType expectedType;
@@ -20,7 +20,6 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.ErrorUtils;
@@ -84,12 +83,18 @@ public class CallableDescriptorCollectors {
@NotNull @NotNull
@Override @Override
public Collection<VariableDescriptor> getNonExtensionsByName(JetScope scope, Name name) { public Collection<VariableDescriptor> getNonExtensionsByName(JetScope scope, Name name) {
VariableDescriptor descriptor = scope.getLocalVariable(name); VariableDescriptor localVariable = scope.getLocalVariable(name);
if (descriptor == null) { if (localVariable != null) {
descriptor = DescriptorUtils.filterNonExtensionProperty(scope.getProperties(name)); return Collections.singleton(localVariable);
} }
if (descriptor == null) return Collections.emptyList();
return Collections.singleton(descriptor); LinkedHashSet<VariableDescriptor> variables = Sets.newLinkedHashSet();
for (VariableDescriptor variable : scope.getProperties(name)) {
if (variable.getReceiverParameter() == null) {
variables.add(variable);
}
}
return variables;
} }
@NotNull @NotNull
@@ -0,0 +1,18 @@
// FILE: a.kt
package a
val v = 1
fun f() = 1
// FILE: b.kt
package b
val v = 1
fun f() = 1
// FILE: main.kt
import a.*
import b.*
val vv = <!OVERLOAD_RESOLUTION_AMBIGUITY!>v<!>
val ff = <!OVERLOAD_RESOLUTION_AMBIGUITY!>f<!>()
@@ -5034,6 +5034,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
doTest("compiler/testData/diagnostics/tests/scopes/AmbiguityBetweenRootAndPackage.kt"); doTest("compiler/testData/diagnostics/tests/scopes/AmbiguityBetweenRootAndPackage.kt");
} }
@TestMetadata("AmbiguousNonExtensions.kt")
public void testAmbiguousNonExtensions() throws Exception {
doTest("compiler/testData/diagnostics/tests/scopes/AmbiguousNonExtensions.kt");
}
@TestMetadata("ImportFromCurrentWithDifferentName.kt") @TestMetadata("ImportFromCurrentWithDifferentName.kt")
public void testImportFromCurrentWithDifferentName() throws Exception { public void testImportFromCurrentWithDifferentName() throws Exception {
doTest("compiler/testData/diagnostics/tests/scopes/ImportFromCurrentWithDifferentName.kt"); doTest("compiler/testData/diagnostics/tests/scopes/ImportFromCurrentWithDifferentName.kt");