Add location parameter to JetScope::getFunctions

This commit is contained in:
Zalim Bashorov
2015-07-14 22:05:46 +03:00
parent f79155df97
commit 0f92036353
37 changed files with 56 additions and 44 deletions
@@ -153,7 +153,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
protected static FunctionDescriptor getFunctionDescriptor(@NotNull PackageFragmentDescriptor packageView, @NotNull String name) {
Name functionName = Name.identifier(name);
JetScope memberScope = packageView.getMemberScope();
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName);
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, Location.NOWHERE);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + packageView.getName();
return functions.iterator().next();
}
@@ -162,7 +162,7 @@ public abstract class AbstractAnnotationDescriptorResolveTest extends JetLiteFix
private static FunctionDescriptor getFunctionDescriptor(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
Name functionName = Name.identifier(name);
JetScope memberScope = classDescriptor.getMemberScope(Collections.<TypeProjection>emptyList());
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName);
Collection<FunctionDescriptor> functions = memberScope.getFunctions(functionName, Location.NOWHERE);
assert functions.size() == 1 : "Failed to find function " + functionName + " in class" + "." + classDescriptor.getName();
return functions.iterator().next();
}
@@ -418,7 +418,7 @@ public class DescriptorValidator {
public Void visitFunctionDescriptor(
FunctionDescriptor descriptor, JetScope scope
) {
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName()));
assertFound(scope, descriptor, scope.getFunctions(descriptor.getName(), Location.NOWHERE));
return null;
}
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.renderer.DescriptorRenderer;
import org.jetbrains.kotlin.resolve.lazy.KotlinTestWithEnvironment;
import org.jetbrains.kotlin.resolve.lazy.LazyResolveTestUtil;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.test.ConfigurationKind;
import java.util.Collection;
@@ -72,7 +73,8 @@ public class BoundsSubstitutorTest extends KotlinTestWithEnvironment {
private void doTest(String text, String expected) {
JetFile jetFile = JetPsiFactory(getProject()).createFile("fun.kt", text);
ModuleDescriptor module = LazyResolveTestUtil.resolveLazily(Collections.singletonList(jetFile), getEnvironment());
Collection<FunctionDescriptor> functions = module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"));
Collection<FunctionDescriptor> functions =
module.getPackage(FqName.ROOT).getMemberScope().getFunctions(Name.identifier("f"), Location.NOWHERE);
assert functions.size() == 1 : "Many functions defined";
FunctionDescriptor function = ContainerUtil.getFirstItem(functions);