Fix TypeConstructor.isFinal for synthetic class descriptors
As in LazyClassTypeConstructor.isFinal, check if the class modality is Modality.FINAL
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ open class KnownClassDescriptor(
|
|||||||
fun initialize(declaredTypeParameters: List<TypeParameterDescriptor>, supertypes: List<KotlinType>) {
|
fun initialize(declaredTypeParameters: List<TypeParameterDescriptor>, supertypes: List<KotlinType>) {
|
||||||
this.declaredTypeParameters = declaredTypeParameters
|
this.declaredTypeParameters = declaredTypeParameters
|
||||||
this.supertypes = supertypes
|
this.supertypes = supertypes
|
||||||
this.typeConstructor = ClassTypeConstructorImpl(this, true, declaredTypeParameters, supertypes)
|
this.typeConstructor = ClassTypeConstructorImpl(this, declaredTypeParameters, supertypes)
|
||||||
this.defaultType = TypeUtils.makeUnsubstitutedType(this, unsubstitutedMemberScope)
|
this.defaultType = TypeUtils.makeUnsubstitutedType(this, unsubstitutedMemberScope)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val typeConstructor = ClassTypeConstructorImpl(this, /* isFinal = */ true, typeParameters, setOf(module.builtIns.anyType))
|
private val typeConstructor = ClassTypeConstructorImpl(this, typeParameters, setOf(module.builtIns.anyType))
|
||||||
|
|
||||||
override fun getKind() = ClassKind.CLASS
|
override fun getKind() = ClassKind.CLASS
|
||||||
override fun getModality() = Modality.FINAL
|
override fun getModality() = Modality.FINAL
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase {
|
|||||||
this.modality = modality;
|
this.modality = modality;
|
||||||
this.kind = kind;
|
this.kind = kind;
|
||||||
|
|
||||||
this.typeConstructor = new ClassTypeConstructorImpl(this, false, Collections.<TypeParameterDescriptor>emptyList(), supertypes);
|
this.typeConstructor = new ClassTypeConstructorImpl(this, Collections.<TypeParameterDescriptor>emptyList(), supertypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void initialize(
|
public final void initialize(
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase {
|
|||||||
|
|
||||||
this.annotations = annotations;
|
this.annotations = annotations;
|
||||||
this.typeConstructor = new ClassTypeConstructorImpl(
|
this.typeConstructor = new ClassTypeConstructorImpl(
|
||||||
this, true, Collections.<TypeParameterDescriptor>emptyList(), Collections.singleton(supertype)
|
this, Collections.<TypeParameterDescriptor>emptyList(), Collections.singleton(supertype)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.scope = new EnumEntryScope(storageManager);
|
this.scope = new EnumEntryScope(storageManager);
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor {
|
|||||||
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
|
supertypes.add(substitutor.substitute(supertype, Variance.INVARIANT));
|
||||||
}
|
}
|
||||||
|
|
||||||
typeConstructor = new ClassTypeConstructorImpl(this, originalTypeConstructor.isFinal(), typeConstructorParameters, supertypes);
|
typeConstructor = new ClassTypeConstructorImpl(this, typeConstructorParameters, supertypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return typeConstructor;
|
return typeConstructor;
|
||||||
|
|||||||
+1
-1
@@ -157,7 +157,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase {
|
|||||||
|
|
||||||
public void createTypeConstructor() {
|
public void createTypeConstructor() {
|
||||||
assert typeConstructor == null : typeConstructor;
|
assert typeConstructor == null : typeConstructor;
|
||||||
this.typeConstructor = new ClassTypeConstructorImpl(this, ModalityKt.isFinalClass(this), typeParameters, supertypes);
|
this.typeConstructor = new ClassTypeConstructorImpl(this, typeParameters, supertypes);
|
||||||
for (FunctionDescriptor functionDescriptor : getConstructors()) {
|
for (FunctionDescriptor functionDescriptor : getConstructors()) {
|
||||||
((ClassConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
|
((ClassConstructorDescriptorImpl) functionDescriptor).setReturnType(getDefaultType());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.types;
|
|||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.kotlin.descriptors.Modality;
|
||||||
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
|
import org.jetbrains.kotlin.descriptors.SupertypeLoopChecker;
|
||||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
@@ -32,17 +33,14 @@ public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor imple
|
|||||||
private final ClassDescriptor classDescriptor;
|
private final ClassDescriptor classDescriptor;
|
||||||
private final List<TypeParameterDescriptor> parameters;
|
private final List<TypeParameterDescriptor> parameters;
|
||||||
private final Collection<KotlinType> supertypes;
|
private final Collection<KotlinType> supertypes;
|
||||||
private final boolean isFinal;
|
|
||||||
|
|
||||||
public ClassTypeConstructorImpl(
|
public ClassTypeConstructorImpl(
|
||||||
@NotNull ClassDescriptor classDescriptor,
|
@NotNull ClassDescriptor classDescriptor,
|
||||||
boolean isFinal,
|
|
||||||
@NotNull List<? extends TypeParameterDescriptor> parameters,
|
@NotNull List<? extends TypeParameterDescriptor> parameters,
|
||||||
@NotNull Collection<KotlinType> supertypes
|
@NotNull Collection<KotlinType> supertypes
|
||||||
) {
|
) {
|
||||||
super(LockBasedStorageManager.NO_LOCKS);
|
super(LockBasedStorageManager.NO_LOCKS);
|
||||||
this.classDescriptor = classDescriptor;
|
this.classDescriptor = classDescriptor;
|
||||||
this.isFinal = isFinal;
|
|
||||||
this.parameters = Collections.unmodifiableList(new ArrayList<TypeParameterDescriptor>(parameters));
|
this.parameters = Collections.unmodifiableList(new ArrayList<TypeParameterDescriptor>(parameters));
|
||||||
this.supertypes = Collections.unmodifiableCollection(supertypes);
|
this.supertypes = Collections.unmodifiableCollection(supertypes);
|
||||||
}
|
}
|
||||||
@@ -60,7 +58,7 @@ public class ClassTypeConstructorImpl extends AbstractClassTypeConstructor imple
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFinal() {
|
public boolean isFinal() {
|
||||||
return isFinal;
|
return classDescriptor.getModality() == Modality.FINAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user