[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.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static kotlin.collections.CollectionsKt.emptyList;
|
||||||
import static kotlin.collections.CollectionsKt.firstOrNull;
|
import static kotlin.collections.CollectionsKt.firstOrNull;
|
||||||
import static org.jetbrains.kotlin.descriptors.DescriptorVisibilities.PRIVATE;
|
import static org.jetbrains.kotlin.descriptors.DescriptorVisibilities.PRIVATE;
|
||||||
import static org.jetbrains.kotlin.descriptors.DescriptorVisibilities.PUBLIC;
|
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);
|
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) {
|
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
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||||
|
|
||||||
abstract class SealedClassInheritorsProvider {
|
abstract class SealedClassInheritorsProvider {
|
||||||
|
/**
|
||||||
|
* This method may be called by compiler only for classes/interfaces with sealed modality
|
||||||
|
*/
|
||||||
abstract fun computeSealedSubclasses(
|
abstract fun computeSealedSubclasses(
|
||||||
sealedClass: ClassDescriptor,
|
sealedClass: ClassDescriptor,
|
||||||
freedomForSealedInterfacesSupported: Boolean
|
freedomForSealedInterfacesSupported: Boolean
|
||||||
|
|||||||
+5
-1
@@ -54,7 +54,11 @@ class CommonizedClassDescriptor(
|
|||||||
private val typeConstructor = CommonizedClassTypeConstructor(targetComponents, cirSupertypes)
|
private val typeConstructor = CommonizedClassTypeConstructor(targetComponents, cirSupertypes)
|
||||||
private val sealedSubclasses = targetComponents.storageManager.createLazyValue {
|
private val sealedSubclasses = targetComponents.storageManager.createLazyValue {
|
||||||
// TODO: pass proper language version settings
|
// 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 {
|
private val declaredTypeParametersAndTypeParameterResolver = targetComponents.storageManager.createLazyValue {
|
||||||
|
|||||||
Reference in New Issue
Block a user