Data classes cannot have class supertypes, a new test, relevant test fixes
This commit is contained in:
@@ -173,6 +173,7 @@ public interface Errors {
|
||||
|
||||
|
||||
DiagnosticFactory0<JetTypeReference> FINAL_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES = DiagnosticFactory0.create(WARNING);
|
||||
DiagnosticFactory0<JetTypeReference> SINGLETON_IN_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetNullableType> NULLABLE_SUPERTYPE = DiagnosticFactory0.create(ERROR, NULLABLE_TYPE);
|
||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_SUPERTYPE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
+1
@@ -415,6 +415,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(TRAIT_WITH_SUPERCLASS, "An interface cannot inherit from a class");
|
||||
MAP.put(SUPERTYPE_APPEARS_TWICE, "A supertype appears twice");
|
||||
MAP.put(FINAL_SUPERTYPE, "This type is final, so it cannot be inherited from");
|
||||
MAP.put(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES, "Data class inheritance from other classes is deprecated");
|
||||
MAP.put(SEALED_SUPERTYPE, "This type is sealed, so it can be inherited by only its own nested classes or objects");
|
||||
MAP.put(SEALED_SUPERTYPE_IN_LOCAL_CLASS, "Local class cannot extend a sealed class");
|
||||
MAP.put(SINGLETON_IN_SUPERTYPE, "Cannot inherit from a singleton");
|
||||
|
||||
@@ -440,6 +440,10 @@ public class BodyResolver {
|
||||
trace.report(TRAIT_WITH_SUPERCLASS.on(typeReference));
|
||||
addSupertype = false;
|
||||
}
|
||||
else if (jetClass.hasModifier(JetTokens.DATA_KEYWORD)) {
|
||||
trace.report(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES.on(typeReference));
|
||||
addSupertype = false;
|
||||
}
|
||||
|
||||
if (classAppeared) {
|
||||
trace.report(MANY_CLASSES_IN_SUPERTYPE_LIST.on(typeReference));
|
||||
|
||||
Reference in New Issue
Block a user