Extension function type is not allowed as supertype
This commit is contained in:
@@ -172,6 +172,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory0<JetTypeReference> DELEGATION_NOT_TO_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<JetTypeReference> SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<PsiElement> NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
|
||||
+1
@@ -434,6 +434,7 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(MANY_CLASSES_IN_SUPERTYPE_LIST, "Only one class may appear in a supertype list");
|
||||
MAP.put(SUPERTYPE_NOT_A_CLASS_OR_INTERFACE, "Only classes and interfaces may serve as supertypes");
|
||||
MAP.put(SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE, "Extension function type is not allowed as supertypes");
|
||||
MAP.put(SUPERTYPE_INITIALIZED_IN_INTERFACE, "Interfaces cannot initialize supertypes");
|
||||
MAP.put(CLASS_IN_SUPERTYPE_FOR_ENUM, "Enum class cannot inherit from classes");
|
||||
MAP.put(CONSTRUCTOR_IN_INTERFACE, "An interface may not have a constructor");
|
||||
|
||||
@@ -24,6 +24,7 @@ import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
@@ -444,6 +445,10 @@ public class BodyResolver {
|
||||
if (classDescriptor != null) {
|
||||
if (ErrorUtils.isError(classDescriptor)) continue;
|
||||
|
||||
if (KotlinBuiltIns.isExactExtensionFunctionType(supertype)) {
|
||||
trace.report(SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE.on(typeReference));
|
||||
}
|
||||
|
||||
if (classDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||
if (supertypeOwner.getKind() == ClassKind.ENUM_CLASS) {
|
||||
trace.report(CLASS_IN_SUPERTYPE_FOR_ENUM.on(typeReference));
|
||||
|
||||
Reference in New Issue
Block a user