Removed KtScope.Empty and created util function emptyScope
This commit is contained in:
@@ -35,12 +35,8 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.DelegationToTraitImpl
|
|||||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor
|
|
||||||
import org.jetbrains.org.objectweb.asm.FieldVisitor
|
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_FINAL
|
import org.jetbrains.org.objectweb.asm.Opcodes.*
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_PUBLIC
|
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes.V1_6
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
public class InterfaceImplBodyCodegen(
|
public class InterfaceImplBodyCodegen(
|
||||||
@@ -69,7 +65,7 @@ public class InterfaceImplBodyCodegen(
|
|||||||
descriptor, Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME),
|
descriptor, Name.identifier(JvmAbi.DEFAULT_IMPLS_CLASS_NAME),
|
||||||
Modality.FINAL, Collections.emptyList(), SourceElement.NO_SOURCE)
|
Modality.FINAL, Collections.emptyList(), SourceElement.NO_SOURCE)
|
||||||
|
|
||||||
classDescriptorImpl.initialize(KtScope.Empty, emptySet(), null)
|
classDescriptorImpl.initialize(KtScope.empty(classDescriptorImpl), emptySet(), null)
|
||||||
return classDescriptorImpl
|
return classDescriptorImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -161,13 +161,13 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public KtScope getUnsubstitutedMemberScope() {
|
public KtScope getUnsubstitutedMemberScope() {
|
||||||
return KtScope.Empty.INSTANCE$; // used for getDefaultType
|
return KtScope.Companion.empty(this); // used for getDefaultType
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public KtScope getStaticScope() {
|
public KtScope getStaticScope() {
|
||||||
return KtScope.Empty.INSTANCE$;
|
return KtScope.Companion.empty(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+1
-1
@@ -101,7 +101,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
|||||||
supertypes,
|
supertypes,
|
||||||
KotlinSourceElementKt.toSourceElement(element)
|
KotlinSourceElementKt.toSourceElement(element)
|
||||||
);
|
);
|
||||||
classDescriptor.initialize(KtScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
|
classDescriptor.initialize(KtScope.Companion.empty(classDescriptor), Collections.<ConstructorDescriptor>emptySet(), null);
|
||||||
|
|
||||||
bindingTrace.record(CLASS_FOR_CALLABLE, callableDescriptor, classDescriptor);
|
bindingTrace.record(CLASS_FOR_CALLABLE, callableDescriptor, classDescriptor);
|
||||||
return classDescriptor;
|
return classDescriptor;
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ public class CodegenBinding {
|
|||||||
new ClassDescriptorImpl(descriptor, Name.special("<script-" + simpleName + ">"), Modality.FINAL,
|
new ClassDescriptorImpl(descriptor, Name.special("<script-" + simpleName + ">"), Modality.FINAL,
|
||||||
Collections.singleton(DescriptorUtilsKt.getBuiltIns(descriptor).getAnyType()),
|
Collections.singleton(DescriptorUtilsKt.getBuiltIns(descriptor).getAnyType()),
|
||||||
KotlinSourceElementKt.toSourceElement(script));
|
KotlinSourceElementKt.toSourceElement(script));
|
||||||
classDescriptor.initialize(KtScope.Empty.INSTANCE$, Collections.<ConstructorDescriptor>emptySet(), null);
|
classDescriptor.initialize(KtScope.Companion.empty(classDescriptor), Collections.<ConstructorDescriptor>emptySet(), null);
|
||||||
|
|
||||||
recordClosure(trace, classDescriptor, null, asmType, fileClassesManager);
|
recordClosure(trace, classDescriptor, null, asmType, fileClassesManager);
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -99,7 +99,7 @@ public class IncrementalPackageFragmentProvider(
|
|||||||
|
|
||||||
val memberScope: NotNullLazyValue<KtScope> = storageManager.createLazyValue {
|
val memberScope: NotNullLazyValue<KtScope> = storageManager.createLazyValue {
|
||||||
if (fqName !in fqNamesToLoad) {
|
if (fqName !in fqNamesToLoad) {
|
||||||
KtScope.Empty
|
KtScope.empty(this)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val moduleMapping = incrementalCache.getModuleMappingData()?.let { ModuleMapping.create(it) }
|
val moduleMapping = incrementalCache.getModuleMappingData()?.let { ModuleMapping.create(it) }
|
||||||
@@ -128,7 +128,7 @@ public class IncrementalPackageFragmentProvider(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scopes.isEmpty()) {
|
if (scopes.isEmpty()) {
|
||||||
KtScope.Empty
|
KtScope.empty(this)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ChainedScope(this, "Member scope for incremental compilation: union of package parts data", *scopes.toTypedArray())
|
ChainedScope(this, "Member scope for incremental compilation: union of package parts data", *scopes.toTypedArray())
|
||||||
@@ -151,7 +151,7 @@ public class IncrementalPackageFragmentProvider(
|
|||||||
val memberScope = storageManager.createLazyValue {
|
val memberScope = storageManager.createLazyValue {
|
||||||
val partsData = partsNames.map { incrementalCache.getPackagePartData(it) }.filterNotNull()
|
val partsData = partsNames.map { incrementalCache.getPackagePartData(it) }.filterNotNull()
|
||||||
if (partsData.isEmpty())
|
if (partsData.isEmpty())
|
||||||
KtScope.Empty
|
KtScope.empty(this)
|
||||||
else {
|
else {
|
||||||
val scopes = partsData.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it.data, it.strings)) }
|
val scopes = partsData.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it.data, it.strings)) }
|
||||||
ChainedScope(this,
|
ChainedScope(this,
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ class PropagationHeuristics {
|
|||||||
arrayTypeFromSuper.getConstructor(),
|
arrayTypeFromSuper.getConstructor(),
|
||||||
arrayTypeFromSuper.isMarkedNullable(),
|
arrayTypeFromSuper.isMarkedNullable(),
|
||||||
Arrays.asList(new TypeProjectionImpl(Variance.OUT_VARIANCE, elementTypeInSuper)),
|
Arrays.asList(new TypeProjectionImpl(Variance.OUT_VARIANCE, elementTypeInSuper)),
|
||||||
KtScope.Empty.INSTANCE$);
|
KtScope.Companion.empty(elementType.getMemberScope().getContainingDeclaration()));
|
||||||
|
|
||||||
data.reportError("Return type is not a subtype of overridden method. " +
|
data.reportError("Return type is not a subtype of overridden method. " +
|
||||||
"To fix it, add annotation with Kotlin signature to super method with type "
|
"To fix it, add annotation with Kotlin signature to super method with type "
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ public class MutablePackageFragmentDescriptor extends PackageFragmentDescriptorI
|
|||||||
public MutablePackageFragmentDescriptor(@NotNull ModuleDescriptor module, @NotNull FqName fqName) {
|
public MutablePackageFragmentDescriptor(@NotNull ModuleDescriptor module, @NotNull FqName fqName) {
|
||||||
super(module, fqName);
|
super(module, fqName);
|
||||||
|
|
||||||
scope = new SimpleKtScope(this, "Members of " + fqName + " in " + module);
|
scope = KtScope.Companion.empty(module);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+2
-2
@@ -165,7 +165,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
|
|||||||
|
|
||||||
val TypeParameterDescriptor.correspondingType: KotlinType
|
val TypeParameterDescriptor.correspondingType: KotlinType
|
||||||
get() = cachedTypeForVariable.getOrPut(this) {
|
get() = cachedTypeForVariable.getOrPut(this) {
|
||||||
KotlinTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
KotlinTypeImpl.create(Annotations.EMPTY, this.getTypeConstructor(), false, listOf(), KtScope.empty(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinType.isProper() = !TypeUtils.containsSpecialType(this) {
|
fun KotlinType.isProper() = !TypeUtils.containsSpecialType(this) {
|
||||||
@@ -573,7 +573,7 @@ public fun createTypeSubstitutor(conversion: (TypeParameterDescriptor) -> TypePa
|
|||||||
if (descriptor !is TypeParameterDescriptor) return null
|
if (descriptor !is TypeParameterDescriptor) return null
|
||||||
val typeParameterDescriptor = conversion(descriptor) ?: return null
|
val typeParameterDescriptor = conversion(descriptor) ?: return null
|
||||||
|
|
||||||
val type = KotlinTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), KtScope.Empty)
|
val type = KotlinTypeImpl.create(Annotations.EMPTY, typeParameterDescriptor.getTypeConstructor(), false, listOf(), KtScope.empty(typeParameterDescriptor))
|
||||||
return TypeProjectionImpl(type)
|
return TypeProjectionImpl(type)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class ClassifierQualifier(
|
|||||||
|
|
||||||
override val scope: KtScope get() {
|
override val scope: KtScope get() {
|
||||||
if (classifier !is ClassDescriptor) {
|
if (classifier !is ClassDescriptor) {
|
||||||
return KtScope.Empty
|
return KtScope.empty(classifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
val scopes = ArrayList<KtScope>(3)
|
val scopes = ArrayList<KtScope>(3)
|
||||||
@@ -125,7 +125,7 @@ class ClassifierQualifier(
|
|||||||
|
|
||||||
override fun getNestedClassesAndPackageMembersScope(): KtScope {
|
override fun getNestedClassesAndPackageMembersScope(): KtScope {
|
||||||
if (classifier !is ClassDescriptor) {
|
if (classifier !is ClassDescriptor) {
|
||||||
return KtScope.Empty
|
return KtScope.empty(classifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
val scopes = ArrayList<KtScope>(2)
|
val scopes = ArrayList<KtScope>(2)
|
||||||
|
|||||||
+10
-2
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.test.util.DescriptorValidator.ValidationVisitor.erro
|
|||||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator
|
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator
|
||||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator.Configuration
|
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator.Configuration
|
||||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||||
|
import org.jetbrains.kotlin.utils.Printer
|
||||||
import org.jetbrains.kotlin.utils.sure
|
import org.jetbrains.kotlin.utils.sure
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
@@ -210,8 +211,11 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
|||||||
get() = throw UnsupportedOperationException()
|
get() = throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ScopeWithClassifiers(classifiers: List<ClassifierDescriptor>, ownerDescriptor: DeclarationDescriptor)
|
private class ScopeWithClassifiers(
|
||||||
: SimpleKtScope(ownerDescriptor, "runtime descriptor loader test") {
|
classifiers: List<ClassifierDescriptor>,
|
||||||
|
val ownerDescriptor: DeclarationDescriptor
|
||||||
|
) : KtScopeImpl() {
|
||||||
|
override fun getContainingDeclaration() = ownerDescriptor
|
||||||
|
|
||||||
private val classifierMap = HashMap<Name, ClassifierDescriptor>()
|
private val classifierMap = HashMap<Name, ClassifierDescriptor>()
|
||||||
val redeclarationHandler = RedeclarationHandler.THROW_EXCEPTION
|
val redeclarationHandler = RedeclarationHandler.THROW_EXCEPTION
|
||||||
@@ -227,6 +231,10 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
|
|||||||
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = classifierMap[name]
|
override fun getClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? = classifierMap[name]
|
||||||
|
|
||||||
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = classifierMap.values
|
override fun getDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<DeclarationDescriptor> = classifierMap.values
|
||||||
|
|
||||||
|
override fun printScopeStructure(p: Printer) {
|
||||||
|
p.println("runtime descriptor loader test")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ public class ConstraintSystemTestData(
|
|||||||
val number = matcher.group(1)!!
|
val number = matcher.group(1)!!
|
||||||
return KotlinTypeImpl.create(
|
return KotlinTypeImpl.create(
|
||||||
Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns), false, listOf(),
|
Annotations.EMPTY, IntegerValueTypeConstructor(number.toLong(), functionFoo.builtIns), false, listOf(),
|
||||||
KtScope.Empty
|
KtScope.empty(functionFoo)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return typeResolver.resolveType(
|
return typeResolver.resolveType(
|
||||||
|
|||||||
+1
-1
@@ -71,7 +71,7 @@ public class LazyJavaPackageScope(
|
|||||||
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
c.components.deserializedDescriptorResolver.readData(binaryClass, DeserializedDescriptorResolver.KOTLIN_PACKAGE_FACADE)
|
||||||
}
|
}
|
||||||
|
|
||||||
KtScope.Empty
|
KtScope.empty(packageFragment)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, containingDeclaration.kotlinBinaryClasses)
|
c.components.deserializedDescriptorResolver.createKotlinPackageScope(packageFragment, containingDeclaration.kotlinBinaryClasses)
|
||||||
|
|||||||
+2
-2
@@ -42,7 +42,7 @@ class BuiltInClassesAreSerializableOnJvm(
|
|||||||
|
|
||||||
private fun createMockJavaIoSerializableType(): KotlinType {
|
private fun createMockJavaIoSerializableType(): KotlinType {
|
||||||
val mockJavaIoPackageFragment = object : PackageFragmentDescriptorImpl(moduleDescriptor, FqName("java.io")) {
|
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
|
//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
|
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
|
return mockSerializableClass.defaultType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -104,7 +104,7 @@ public final class DeserializedDescriptorResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (list.isEmpty()) {
|
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()]));
|
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 {
|
override val memberScope: KtScope = LazyScopeAdapter(storageManager.createLazyValue {
|
||||||
if (fragments.isEmpty()) {
|
if (fragments.isEmpty()) {
|
||||||
KtScope.Empty
|
KtScope.empty(this)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
val scopes = fragments.map { it.getMemberScope() } + SubpackagesScope(module, fqName)
|
val scopes = fragments.map { it.getMemberScope() } + SubpackagesScope(module, fqName)
|
||||||
|
|||||||
@@ -50,19 +50,19 @@ public interface KtScope {
|
|||||||
*/
|
*/
|
||||||
public fun printScopeStructure(p: Printer)
|
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 {
|
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 }
|
public val ALL_NAME_FILTER: (Name) -> Boolean = { true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,3 @@ abstract class KtScopeImpl : KtScope {
|
|||||||
// This method should not be implemented here by default: every scope class has its unique structure pattern
|
// This method should not be implemented here by default: every scope class has its unique structure pattern
|
||||||
abstract override fun printScopeStructure(p: Printer)
|
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
|
|
||||||
}
|
|
||||||
+1
-1
@@ -74,7 +74,7 @@ private class MissingDependencyErrorClassDescriptor(
|
|||||||
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
val emptyConstructor = ConstructorDescriptorImpl.create(this, Annotations.EMPTY, true, SourceElement.NO_SOURCE)
|
||||||
emptyConstructor.initialize(listOf(), listOf(), Visibilities.DEFAULT_VISIBILITY)
|
emptyConstructor.initialize(listOf(), listOf(), Visibilities.DEFAULT_VISIBILITY)
|
||||||
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
|
emptyConstructor.setReturnType(createErrorType("<ERROR RETURN TYPE>"))
|
||||||
initialize(KtScope.Empty, setOf(emptyConstructor), emptyConstructor)
|
initialize(KtScope.empty(this), setOf(emptyConstructor), emptyConstructor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun substitute(substitutor: TypeSubstitutor) = this
|
override fun substitute(substitutor: TypeSubstitutor) = this
|
||||||
|
|||||||
Reference in New Issue
Block a user