[FE] Call SealedClassInheritorsProvider only for sealed classes
This commit is contained in:
+9
-1
@@ -54,6 +54,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static kotlin.collections.CollectionsKt.emptyList;
|
||||
import static kotlin.collections.CollectionsKt.firstOrNull;
|
||||
import static org.jetbrains.kotlin.descriptors.DescriptorVisibilities.PRIVATE;
|
||||
import static org.jetbrains.kotlin.descriptors.DescriptorVisibilities.PUBLIC;
|
||||
@@ -270,7 +271,14 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
);
|
||||
|
||||
boolean freedomForSealedInterfacesSupported = c.getLanguageVersionSettings().supportsFeature(LanguageFeature.AllowSealedInheritorsInDifferentFilesOfSamePackage);
|
||||
this.sealedSubclasses = storageManager.createLazyValue(() -> c.getSealedClassInheritorsProvider().computeSealedSubclasses(this, freedomForSealedInterfacesSupported));
|
||||
this.sealedSubclasses =
|
||||
storageManager.createLazyValue(() -> {
|
||||
if (getModality() == Modality.SEALED) {
|
||||
return c.getSealedClassInheritorsProvider().computeSealedSubclasses(this, freedomForSealedInterfacesSupported);
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isIllegalInner(@NotNull DeclarationDescriptor descriptor) {
|
||||
|
||||
@@ -13,6 +13,9 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
|
||||
abstract class SealedClassInheritorsProvider {
|
||||
/**
|
||||
* This method may be called by compiler only for classes/interfaces with sealed modality
|
||||
*/
|
||||
abstract fun computeSealedSubclasses(
|
||||
sealedClass: ClassDescriptor,
|
||||
freedomForSealedInterfacesSupported: Boolean
|
||||
|
||||
+5
-1
@@ -54,7 +54,11 @@ class CommonizedClassDescriptor(
|
||||
private val typeConstructor = CommonizedClassTypeConstructor(targetComponents, cirSupertypes)
|
||||
private val sealedSubclasses = targetComponents.storageManager.createLazyValue {
|
||||
// TODO: pass proper language version settings
|
||||
SealedClassInheritorsProviderImpl.computeSealedSubclasses(this, freedomForSealedInterfacesSupported = false)
|
||||
if (modality == Modality.SEALED) {
|
||||
SealedClassInheritorsProviderImpl.computeSealedSubclasses(this, freedomForSealedInterfacesSupported = false)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
|
||||
private val declaredTypeParametersAndTypeParameterResolver = targetComponents.storageManager.createLazyValue {
|
||||
|
||||
Reference in New Issue
Block a user