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
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilPackage;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilPackage;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -59,7 +60,7 @@ public class CodegenUtil {
@NotNull ClassifierDescriptor returnedClassifier,
@NotNull ClassifierDescriptor... valueParameterClassifiers
) {
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name);
Collection<FunctionDescriptor> functions = owner.getDefaultType().getMemberScope().getFunctions(name, Location.NOWHERE);
for (FunctionDescriptor function : functions) {
if (!CallResolverUtilPackage.isOrOverridesSynthesized(function)
&& function.getTypeParameters().isEmpty()
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.psi.JetElement;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.kotlin.utils.UtilsPackage;
@@ -452,6 +453,6 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
ClassDescriptor elementClass = elementDescriptor.getExtensionReceiverParameter() == null
? getBuiltIns(elementDescriptor).getFunction(arity)
: getBuiltIns(elementDescriptor).getExtensionFunction(arity);
return elementClass.getDefaultType().getMemberScope().getFunctions(OperatorConventions.INVOKE).iterator().next();
return elementClass.getDefaultType().getMemberScope().getFunctions(OperatorConventions.INVOKE, Location.NOWHERE).iterator().next();
}
}
@@ -62,6 +62,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver;
@@ -401,7 +402,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}
private boolean isGenericToArrayPresent() {
Collection<FunctionDescriptor> functions = descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray"));
Collection<FunctionDescriptor> functions =
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier("toArray"), Location.NOWHERE);
for (FunctionDescriptor function : functions) {
if (CallResolverUtilPackage.isOrOverridesSynthesized(function)) {
continue;
@@ -815,7 +817,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
Type type = typeMapper.mapType(getBuiltIns(descriptor).getArrayType(INVARIANT, descriptor.getDefaultType()));
FunctionDescriptor valuesFunction =
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUES), new Function1<FunctionDescriptor, Boolean>() {
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUES, Location.NOWHERE), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValuesMethod(descriptor);
@@ -835,7 +837,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void generateEnumValueOfMethod() {
FunctionDescriptor valueOfFunction =
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF), new Function1<FunctionDescriptor, Boolean>() {
KotlinPackage.single(descriptor.getStaticScope().getFunctions(ENUM_VALUE_OF, Location.NOWHERE), new Function1<FunctionDescriptor, Boolean>() {
@Override
public Boolean invoke(FunctionDescriptor descriptor) {
return CodegenUtil.isEnumValueOfMethod(descriptor);
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.JetFile;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
import org.jetbrains.org.objectweb.asm.MethodVisitor;
@@ -148,7 +149,7 @@ public class SamWrapperCodegen {
(ClassDescriptor) erasedInterfaceFunction.getContainingDeclaration(), OwnerKind.IMPLEMENTATION, state), cv, state, parentCodegen);
FunctionDescriptor invokeFunction =
functionJetType.getMemberScope().getFunctions(OperatorConventions.INVOKE).iterator().next().getOriginal();
functionJetType.getMemberScope().getFunctions(OperatorConventions.INVOKE, Location.NOWHERE).iterator().next().getOriginal();
StackValue functionField = StackValue.field(functionType, ownerType, FUNCTION_FIELD_NAME, false, StackValue.none());
codegen.genDelegate(erasedInterfaceFunction, invokeFunction, functionField);
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmSignaturePackage;
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.types.*;
import java.util.*;
@@ -302,7 +303,7 @@ public class SignaturesPropagationData {
Name name = method.getName();
JvmMethodSignature autoSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(autoMethodDescriptor);
for (JetType supertype : containingClass.getTypeConstructor().getSupertypes()) {
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name);
Collection<FunctionDescriptor> superFunctionCandidates = supertype.getMemberScope().getFunctions(name, Location.NOWHERE);
for (FunctionDescriptor candidate : superFunctionCandidates) {
JvmMethodSignature candidateSignature = SIGNATURE_MAPPER.mapToJvmMethodSignature(candidate);
if (JvmSignaturePackage.erasedSignaturesEqualIgnoringReturnTypes(autoSignature, candidateSignature)) {
@@ -50,7 +50,7 @@ class AllUnderImportsScope : JetScope {
return scopes.flatMap { it.getProperties(name) }
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
return scopes.flatMap { it.getFunctions(name) }
}
@@ -734,7 +734,7 @@ public class OverrideResolver {
) {
for (JetType supertype : declaringClass.getTypeConstructor().getSupertypes()) {
Set<CallableMemberDescriptor> all = Sets.newLinkedHashSet();
all.addAll(supertype.getMemberScope().getFunctions(declared.getName()));
all.addAll(supertype.getMemberScope().getFunctions(declared.getName(), Location.NOWHERE));
//noinspection unchecked
all.addAll((Collection) supertype.getMemberScope().getProperties(declared.getName(), Location.NOWHERE));
for (CallableMemberDescriptor fromSuper : all) {
@@ -234,7 +234,7 @@ public class QualifiedExpressionResolver {
}
if (lookupMode == LookupMode.EVERYTHING) {
descriptors.addAll(outerScope.getFunctions(referencedName));
descriptors.addAll(outerScope.getFunctions(referencedName, Location.NOWHERE));
descriptors.addAll(outerScope.getProperties(referencedName, Location.NOWHERE));
VariableDescriptor localVariable = outerScope.getLocalVariable(referencedName);
@@ -33,7 +33,7 @@ class SingleImportScope(private val aliasName: Name, private val descriptors: Co
override fun getProperties(name: Name, location: Location)
= if (name == aliasName) descriptors.filterIsInstance<VariableDescriptor>() else emptyList()
override fun getFunctions(name: Name)
override fun getFunctions(name: Name, location: Location)
= if (name == aliasName) descriptors.filterIsInstance<FunctionDescriptor>() else emptyList()
override fun getContainingDeclaration(): DeclarationDescriptor = throw UnsupportedOperationException()
@@ -49,7 +49,7 @@ object DynamicCallableDescriptors {
p.println(javaClass.getSimpleName(), ": dynamic candidates for " + call)
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
if (isAugmentedAssignmentConvention(name)) return listOf()
if (call.getCallType() == Call.CallType.INVOKE
&& call.getValueArgumentList() == null && call.getFunctionLiteralArguments().isEmpty()) {
@@ -134,7 +134,7 @@ public class LazyDeclarationResolver {
@Override
public DeclarationDescriptor visitNamedFunction(@NotNull JetNamedFunction function, Void data) {
JetScope scopeForDeclaration = resolutionScopeToResolveDeclaration(function);
scopeForDeclaration.getFunctions(function.getNameAsSafeName());
scopeForDeclaration.getFunctions(function.getNameAsSafeName(), Location.NOWHERE);
return getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, function);
}
@@ -253,7 +253,7 @@ class LazyImportScope(
override fun getLocalVariable(name: Name) = null
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getFunctions(name) }
}
@@ -64,7 +64,7 @@ protected constructor(
override fun getClassifier(name: Name): ClassDescriptor? = classDescriptors(name).firstOrNull()
override fun getFunctions(name: Name): Collection<FunctionDescriptor> = functionDescriptors(name)
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> = functionDescriptors(name)
private fun doGetFunctions(name: Name): Collection<FunctionDescriptor> {
val result = Sets.newLinkedHashSet<FunctionDescriptor>()
@@ -115,7 +115,7 @@ public open class LazyClassMemberScope(
OverrideResolver.resolveUnknownVisibilities(result, trace)
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
// TODO: this should be handled by lazy function descriptors
val functions = super.getFunctions(name)
resolveUnknownVisibilitiesForMembers(functions)
@@ -156,7 +156,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
functionsByName!![name] = functionsByName!![name] + descriptorIndex
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name), workerScope.getFunctions(name))
@@ -270,7 +270,7 @@ public class WritableScopeImpl @jvmOverloads constructor(
return workerScope.getLocalVariable(name)
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
checkMayRead()
return concatInOrder(functionsByName(name, descriptorLimit), workerScope.getFunctions(name))
@@ -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);
@@ -218,7 +218,7 @@ public abstract class LazyJavaMemberScope(
return ResolvedValueParameters(descriptors, synthesizedNames)
}
override fun getFunctions(name: Name) = functions(name)
override fun getFunctions(name: Name, location: Location) = functions(name)
protected open fun getFunctionNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
= memberIndex().getMethodNames(nameFilter)
@@ -73,7 +73,7 @@ public class LazyPackageFragmentScopeForJavaPackage(
override fun getClassifier(name: Name): ClassifierDescriptor? = classes(name)
override fun getProperties(name: Name, location: Location) = deserializedPackageScope().getProperties(name)
override fun getFunctions(name: Name) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
override fun getFunctions(name: Name, location: Location) = deserializedPackageScope().getFunctions(name) + super.getFunctions(name)
override fun addExtraDescriptors(result: MutableSet<DeclarationDescriptor>,
kindFilter: DescriptorKindFilter,
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
import org.jetbrains.kotlin.types.*;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -1018,6 +1019,6 @@ public class KotlinBuiltIns {
@NotNull
public FunctionDescriptor getIdentityEquals() {
return KotlinPackage.first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals")));
return KotlinPackage.first(getBuiltInsPackageFragment().getMemberScope().getFunctions(Name.identifier("identityEquals"), Location.NOWHERE));
}
}
@@ -48,7 +48,7 @@ class FunctionClassScope(
return allDescriptors()
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
return allDescriptors().filterIsInstance<FunctionDescriptor>().filter { it.getName() == name }
}
@@ -204,13 +204,13 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull Location location) {
return functions.invoke(name);
}
@NotNull
private Collection<FunctionDescriptor> computeFunctions(@NotNull Name name) {
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name));
return resolveFakeOverrides(name, getSupertypeScope().getFunctions(name, Location.NOWHERE));
}
@NotNull
@@ -266,7 +266,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
private Collection<DeclarationDescriptor> computeAllDeclarations() {
Collection<DeclarationDescriptor> result = new HashSet<DeclarationDescriptor>();
for (Name name : enumMemberNames.invoke()) {
result.addAll(getFunctions(name));
result.addAll(getFunctions(name, Location.NOWHERE));
result.addAll(getProperties(name, Location.NOWHERE));
}
return result;
@@ -31,7 +31,7 @@ public abstract class AbstractScopeAdapter : JetScope {
return workerScope.getImplicitReceiversHierarchy()
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> {
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> {
return workerScope.getFunctions(name)
}
@@ -62,7 +62,7 @@ public open class ChainedScope(
override fun getLocalVariable(name: Name): VariableDescriptor?
= getFirstMatch { it.getLocalVariable(name) }
override fun getFunctions(name: Name): Collection<FunctionDescriptor>
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor>
= getFromAllScopes { it.getFunctions(name) }
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
@@ -29,7 +29,7 @@ public class ExplicitImportsScope(private val descriptors: Collection<Declaratio
override fun getProperties(name: Name, location: Location) = descriptors.filter { it.getName() == name }.filterIsInstance<VariableDescriptor>()
override fun getFunctions(name: Name) = descriptors.filter { it.getName() == name }.filterIsInstance<FunctionDescriptor>()
override fun getFunctions(name: Name, location: Location) = descriptors.filter { it.getName() == name }.filterIsInstance<FunctionDescriptor>()
override fun getContainingDeclaration() = throw UnsupportedOperationException()
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.utils.Printer
public class FilteringScope(private val workerScope: JetScope, private val predicate: (DeclarationDescriptor) -> Boolean) : JetScope {
override fun getFunctions(name: Name) = workerScope.getFunctions(name).filter(predicate)
override fun getFunctions(name: Name, location: Location) = workerScope.getFunctions(name).filter(predicate)
override fun getContainingDeclaration() = workerScope.getContainingDeclaration()
@@ -33,7 +33,7 @@ public interface JetScope {
public fun getLocalVariable(name: Name): VariableDescriptor?
public fun getFunctions(name: Name): Collection<FunctionDescriptor>
public fun getFunctions(name: Name, location: Location = Location.NOWHERE): Collection<FunctionDescriptor>
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
@@ -30,7 +30,7 @@ public abstract class JetScopeImpl : JetScope {
override fun getPackage(name: Name): PackageViewDescriptor? = null
override fun getFunctions(name: Name): Collection<FunctionDescriptor> = setOf()
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> = setOf()
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = listOf()
@@ -44,7 +44,7 @@ public class StaticScopeForKotlinClass(
override fun getOwnDeclaredDescriptors() = functions
override fun getFunctions(name: Name) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getFunctions(name: Name, location: Location) = functions.filterTo(ArrayList<FunctionDescriptor>(2)) { it.getName() == name }
override fun getContainingDeclaration() = containingClass
@@ -67,7 +67,7 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
override fun getClassifier(name: Name) = substitute(workerScope.getClassifier(name))
override fun getFunctions(name: Name) = substitute(workerScope.getFunctions(name))
override fun getFunctions(name: Name, location: Location) = substitute(workerScope.getFunctions(name))
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name))
@@ -124,7 +124,7 @@ public class ErrorUtils {
@NotNull
@Override
public Set<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Set<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull Location location) {
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
}
@@ -204,7 +204,7 @@ public class ErrorUtils {
@NotNull
@Override
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name) {
public Collection<FunctionDescriptor> getFunctions(@NotNull Name name, @NotNull Location location) {
throw new IllegalStateException();
}
@@ -93,7 +93,7 @@ public abstract class DeserializedMemberScope protected constructor(
protected open fun computeNonDeclaredFunctions(name: Name, functions: MutableCollection<FunctionDescriptor>) {
}
override fun getFunctions(name: Name): Collection<FunctionDescriptor> = functions(name)
override fun getFunctions(name: Name, location: Location): Collection<FunctionDescriptor> = functions(name)
private fun computeProperties(name: Name): Collection<VariableDescriptor> {
val descriptors = computeMembers<PropertyDescriptor>(name, Kind.PROPERTY)
@@ -140,7 +140,7 @@ public class IDELightClassGenerationSupport extends LightClassGenerationSupport
if (declaration instanceof JetFunction) {
JetFunction jetFunction = (JetFunction) declaration;
Name name = jetFunction.getNameAsSafeName();
Collection<FunctionDescriptor> functions = packageDescriptor.getMemberScope().getFunctions(name);
Collection<FunctionDescriptor> functions = packageDescriptor.getMemberScope().getFunctions(name, Location.NOWHERE);
for (FunctionDescriptor descriptor : functions) {
ForceResolveUtil.forceResolveAllContents(descriptor);
}
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.renderer.NameShortness;
import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil;
import org.jetbrains.kotlin.resolve.VisibilityUtil;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.Location;
import org.jetbrains.kotlin.types.JetType;
import org.jetbrains.kotlin.types.TypeUtils;
import org.jetbrains.kotlin.types.checker.JetTypeChecker;
@@ -267,7 +268,7 @@ public class ChangeMemberFunctionSignatureFix extends JetHintAction<JetNamedFunc
Name name = functionDescriptor.getName();
for (JetType type : TypeUtils.getAllSupertypes(classDescriptor.getDefaultType())) {
JetScope scope = type.getMemberScope();
for (FunctionDescriptor function : scope.getFunctions(name)) {
for (FunctionDescriptor function : scope.getFunctions(name, Location.NOWHERE)) {
if (!function.getKind().isReal()) continue;
if (function.getModality().isOverridable())
superFunctions.add(function);
@@ -579,7 +579,7 @@ public class JetChangeSignatureUsageProcessor implements ChangeSignatureUsagePro
if (!kind.getIsConstructor() && callableScope != null && !info.getNewName().isEmpty()) {
Name newName = Name.identifier(info.getNewName());
Collection<? extends CallableDescriptor> conflicts = oldDescriptor instanceof FunctionDescriptor
? callableScope.getFunctions(newName)
? callableScope.getFunctions(newName, Location.NOWHERE)
: callableScope.getProperties(newName, Location.NOWHERE);
for (CallableDescriptor conflict : conflicts) {
if (conflict == oldDescriptor) continue;
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter;
import org.jetbrains.kotlin.resolve.scopes.JetScope;
import org.jetbrains.kotlin.resolve.scopes.Location;
import java.util.*;
@@ -247,7 +248,8 @@ public class ManglingUtils {
@NotNull
public static String getStableMangledNameForDescriptor(@NotNull ClassDescriptor descriptor, @NotNull String functionName) {
Collection<FunctionDescriptor> functions = descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier(functionName));
Collection<FunctionDescriptor> functions =
descriptor.getDefaultType().getMemberScope().getFunctions(Name.identifier(functionName), Location.NOWHERE);
assert functions.size() == 1 : "Can't select a single function: " + functionName + " in " + descriptor;
return getSuggestedName((DeclarationDescriptor) functions.iterator().next());
}