'sealed' is now not 'final' by default + related code changes #KT-10266 Fixed
This commit is contained in:
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.descriptors.ClassKind;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.Modality;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.lexer.KtToken;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
@@ -60,7 +59,7 @@ public final class WhenChecker {
|
||||
if (type == null) return null;
|
||||
ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type);
|
||||
if (classDescriptor == null) return null;
|
||||
if (classDescriptor.getKind() != ClassKind.ENUM_CLASS || classDescriptor.getModality().isOverridable()) return null;
|
||||
if (classDescriptor.getKind() != ClassKind.ENUM_CLASS) return null;
|
||||
|
||||
return classDescriptor;
|
||||
}
|
||||
|
||||
@@ -488,8 +488,8 @@ public class BodyResolver {
|
||||
trace.report(SINGLETON_IN_SUPERTYPE.on(typeReference));
|
||||
}
|
||||
}
|
||||
else if (constructor.isFinal() && !allowedFinalSupertypes.contains(constructor)) {
|
||||
if (classDescriptor.getModality() == Modality.SEALED) {
|
||||
else if (!allowedFinalSupertypes.contains(constructor)) {
|
||||
if (classDescriptor != null && classDescriptor.getModality() == Modality.SEALED) {
|
||||
DeclarationDescriptor containingDescriptor = supertypeOwner.getContainingDeclaration();
|
||||
while (containingDescriptor != null && containingDescriptor != classDescriptor) {
|
||||
containingDescriptor = containingDescriptor.getContainingDeclaration();
|
||||
@@ -501,7 +501,7 @@ public class BodyResolver {
|
||||
trace.report(SEALED_SUPERTYPE_IN_LOCAL_CLASS.on(typeReference));
|
||||
}
|
||||
}
|
||||
else {
|
||||
else if (constructor.isFinal()) {
|
||||
trace.report(FINAL_SUPERTYPE.on(typeReference));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,10 +614,6 @@ public class DescriptorResolver {
|
||||
) {
|
||||
if (DeclarationsCheckerKt.checkNotEnumEntry(upperBound, trace)) return;
|
||||
if (!TypeUtils.canHaveSubtypes(KotlinTypeChecker.DEFAULT, upperBoundType)) {
|
||||
ClassifierDescriptor descriptor = upperBoundType.getConstructor().getDeclarationDescriptor();
|
||||
if (descriptor instanceof ClassDescriptor) {
|
||||
if (((ClassDescriptor) descriptor).getModality() == Modality.SEALED) return;
|
||||
}
|
||||
trace.report(FINAL_UPPER_BOUND.on(upperBound, upperBoundType));
|
||||
}
|
||||
if (DynamicTypesKt.isDynamic(upperBoundType)) {
|
||||
|
||||
+1
-1
@@ -345,7 +345,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
/*
|
||||
* (a: SubjectType) is Type
|
||||
*/
|
||||
private void checkTypeCompatibility(
|
||||
private static void checkTypeCompatibility(
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@Nullable KotlinType type,
|
||||
@NotNull KotlinType subjectType,
|
||||
|
||||
Reference in New Issue
Block a user