Removed KtScope.Empty and created util function emptyScope
This commit is contained in:
+1
-1
@@ -71,7 +71,7 @@ public class LazyJavaPackageScope(
|
||||
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
||||
}
|
||||
|
||||
KtScope.Empty
|
||||
KtScope.empty(packageFragment)
|
||||
}
|
||||
else {
|
||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, containingDeclaration.kotlinBinaryClasses)
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
|
||||
private fun createMockJavaIoSerializableType(): KotlinType {
|
||||
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl(moduleDescriptor, FqName("java.io")) {
|
||||
override fun getMemberScope() = KtScope.Empty
|
||||
override fun getMemberScope() = KtScope.empty(this)
|
||||
}
|
||||
|
||||
//NOTE: can't reference anyType right away, because this is sometimes called when JvmBuiltIns are initializing
|
||||
@@ -56,7 +56,7 @@ class BuiltInClassesAreSerializableOnJvm(
|
||||
mockJavaIoPackageFragment, Name.identifier("Serializable"), Modality.ABSTRACT, superTypes, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
mockSerializableClass.initialize(KtScope.Empty, emptySet(), null)
|
||||
mockSerializableClass.initialize(KtScope.empty(mockSerializableClass), emptySet(), null)
|
||||
return mockSerializableClass.defaultType
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -104,7 +104,7 @@ public final class DeserializedDescriptorResolver {
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
return KtScope.Empty.INSTANCE$;
|
||||
return KtScope.Companion.empty(descriptor);
|
||||
}
|
||||
return new ChainedScope(descriptor, "Member scope for union of package parts data", list.toArray(new KtScope[list.size()]));
|
||||
}
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ public class LazyPackageViewDescriptorImpl(
|
||||
|
||||
override val memberScope: KtScope = LazyScopeAdapter(storageManager.createLazyValue {
|
||||
if (fragments.isEmpty()) {
|
||||
KtScope.Empty
|
||||
KtScope.empty(this)
|
||||
}
|
||||
else {
|
||||
val scopes = fragments.map { it.getMemberScope() } + SubpackagesScope(module, fqName)
|
||||
|
||||
@@ -50,19 +50,19 @@ public interface KtScope {
|
||||
*/
|
||||
public fun printScopeStructure(p: Printer)
|
||||
|
||||
public object Empty : KtScopeImpl() {
|
||||
override fun getContainingDeclaration(): DeclarationDescriptor {
|
||||
throw UnsupportedOperationException("Don't take containing declaration of the Empty scope")
|
||||
}
|
||||
|
||||
override fun toString() = "Empty"
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println("Empty")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
public fun empty(ownerDescriptor: DeclarationDescriptor): KtScope {
|
||||
return object : KtScopeImpl() {
|
||||
override fun getContainingDeclaration() = ownerDescriptor
|
||||
|
||||
override fun toString() = "Empty scope with owner: $ownerDescriptor"
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public val ALL_NAME_FILTER: (Name) -> Boolean = { true }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,12 +35,4 @@ abstract class KtScopeImpl : KtScope {
|
||||
|
||||
// This method should not be implemented here by default: every scope class has its unique structure pattern
|
||||
abstract override fun printScopeStructure(p: Printer)
|
||||
}
|
||||
|
||||
open class SimpleKtScope(val ownerDescriptor: DeclarationDescriptor, val debugName: String): KtScopeImpl() {
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.getSimpleName(), ": ", debugName, " for ", ownerDescriptor, " {")
|
||||
}
|
||||
|
||||
override fun getContainingDeclaration() = ownerDescriptor
|
||||
}
|
||||
Reference in New Issue
Block a user