Added JetScope.getSyntheticExtensionFunctions()
This commit is contained in:
@@ -58,6 +58,10 @@ class AllUnderImportsScope : JetScope {
|
||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes, name) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionFunctions(receiverTypes, name) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||
return scopes.flatMap { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
}
|
||||
|
||||
@@ -263,6 +263,11 @@ class LazyImportScope(
|
||||
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionProperties(receiverTypes, name) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
return importResolver.collectFromImports(name, LookupMode.EVERYTHING) { scope, name -> scope.getSyntheticExtensionFunctions(receiverTypes, name) }
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||
// we do not perform any filtering by visibility here because all descriptors from both visible/invisible filter scopes are to be added anyway
|
||||
if (filteringKind == FilteringKind.INVISIBLE_CLASSES) return listOf()
|
||||
|
||||
@@ -51,6 +51,10 @@ public abstract class AbstractScopeAdapter : JetScope {
|
||||
return workerScope.getSyntheticExtensionProperties(receiverTypes, name)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> {
|
||||
return workerScope.getSyntheticExtensionFunctions(receiverTypes, name)
|
||||
}
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> {
|
||||
return workerScope.getSyntheticExtensionProperties(receiverTypes)
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.util.collectionUtils.concat
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
import java.util.ArrayList
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
public open class ChainedScope(
|
||||
private val containingDeclaration: DeclarationDescriptor?/* it's nullable as a hack for TypeUtils.intersect() */,
|
||||
@@ -68,6 +67,9 @@ public open class ChainedScope(
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes, name) }
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor>
|
||||
= getFromAllScopes { it.getSyntheticExtensionFunctions(receiverTypes, name) }
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||
= getFromAllScopes { it.getSyntheticExtensionProperties(receiverTypes) }
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
@@ -39,6 +40,8 @@ public class FilteringScope(private val workerScope: JetScope, private val predi
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = workerScope.getSyntheticExtensionProperties(receiverTypes, name).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> = workerScope.getSyntheticExtensionFunctions(receiverTypes, name).filter(predicate)
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = workerScope.getSyntheticExtensionProperties(receiverTypes).filter(predicate)
|
||||
|
||||
override fun getLocalVariable(name: Name) = filterDescriptor(workerScope.getLocalVariable(name))
|
||||
|
||||
@@ -36,6 +36,7 @@ public interface JetScope {
|
||||
public fun getFunctions(name: Name, location: UsageLocation = UsageLocation.NO_LOCATION): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
|
||||
public fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor>
|
||||
|
||||
public fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor>
|
||||
|
||||
|
||||
@@ -24,26 +24,27 @@ import org.jetbrains.kotlin.utils.Printer
|
||||
public abstract class JetScopeImpl : JetScope {
|
||||
override fun getClassifier(name: Name, location: UsageLocation): ClassifierDescriptor? = null
|
||||
|
||||
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> = setOf()
|
||||
override fun getProperties(name: Name, location: UsageLocation): Collection<VariableDescriptor> = emptyList()
|
||||
|
||||
override fun getLocalVariable(name: Name): VariableDescriptor? = null
|
||||
|
||||
override fun getPackage(name: Name): PackageViewDescriptor? = null
|
||||
|
||||
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = setOf()
|
||||
override fun getFunctions(name: Name, location: UsageLocation): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = listOf()
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = emptyList()
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor> = emptyList()
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = listOf()
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = emptyList()
|
||||
|
||||
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = listOf()
|
||||
override fun getDeclarationsByLabel(labelName: Name): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
override fun getDescriptors(kindFilter: DescriptorKindFilter,
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = listOf()
|
||||
nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> = listOf()
|
||||
override fun getImplicitReceiversHierarchy(): List<ReceiverParameterDescriptor> = emptyList()
|
||||
|
||||
override fun getOwnDeclaredDescriptors(): Collection<DeclarationDescriptor> = listOf()
|
||||
override fun getOwnDeclaredDescriptors(): Collection<DeclarationDescriptor> = emptyList()
|
||||
|
||||
// This method should not be implemented here by default: every scope class has its unique structure pattern
|
||||
abstract override fun printScopeStructure(p: Printer)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -69,7 +70,11 @@ public class SubstitutingScope(private val workerScope: JetScope, private val su
|
||||
|
||||
override fun getFunctions(name: Name, location: UsageLocation) = substitute(workerScope.getFunctions(name, location))
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor> = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name))
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>, name: Name): Collection<PropertyDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionProperties(receiverTypes, name))
|
||||
|
||||
override fun getSyntheticExtensionFunctions(receiverTypes: Collection<JetType>, name: Name): Collection<FunctionDescriptor>
|
||||
= substitute(workerScope.getSyntheticExtensionFunctions(receiverTypes, name))
|
||||
|
||||
override fun getSyntheticExtensionProperties(receiverTypes: Collection<JetType>): Collection<PropertyDescriptor> = substitute(workerScope.getSyntheticExtensionProperties(receiverTypes))
|
||||
|
||||
|
||||
@@ -101,6 +101,14 @@ public class ErrorUtils {
|
||||
return ERROR_PROPERTY_GROUP;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name
|
||||
) {
|
||||
return Collections.<FunctionDescriptor>singleton(createErrorFunction(this));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(@NotNull Collection<? extends JetType> receiverTypes) {
|
||||
@@ -217,6 +225,14 @@ public class ErrorUtils {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<FunctionDescriptor> getSyntheticExtensionFunctions(
|
||||
@NotNull Collection<? extends JetType> receiverTypes, @NotNull Name name
|
||||
) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<PropertyDescriptor> getSyntheticExtensionProperties(@NotNull Collection<? extends JetType> receiverTypes) {
|
||||
|
||||
Reference in New Issue
Block a user