Prohibit suspend function type in supertype list
#KT-15391 Fixed
This commit is contained in:
@@ -237,6 +237,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory2<KtDeclaration, CallableMemberDescriptor, List<CallableMemberDescriptor>> DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE = DiagnosticFactory2.create(ERROR);
|
DiagnosticFactory2<KtDeclaration, CallableMemberDescriptor, List<CallableMemberDescriptor>> DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE = DiagnosticFactory2.create(ERROR);
|
||||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<KtTypeReference> SUPERTYPE_NOT_A_CLASS_OR_INTERFACE = DiagnosticFactory0.create(ERROR);
|
||||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||||
|
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
DiagnosticFactory0<PsiElement> NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<PsiElement> NO_GENERICS_IN_SUPERTYPE_SPECIFIER = DiagnosticFactory0.create(ERROR);
|
||||||
|
|
||||||
|
|||||||
+1
@@ -544,6 +544,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(MANY_CLASSES_IN_SUPERTYPE_LIST, "Only one class may appear in a supertype list");
|
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_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_IS_EXTENSION_FUNCTION_TYPE, "Extension function type is not allowed as supertypes");
|
||||||
|
MAP.put(SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE, "Suspend function type is not allowed as supertypes");
|
||||||
MAP.put(SUPERTYPE_INITIALIZED_IN_INTERFACE, "Interfaces cannot initialize 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(CLASS_IN_SUPERTYPE_FOR_ENUM, "Enum class cannot inherit from classes");
|
||||||
MAP.put(CONSTRUCTOR_IN_INTERFACE, "An interface may not have a constructor");
|
MAP.put(CONSTRUCTOR_IN_INTERFACE, "An interface may not have a constructor");
|
||||||
|
|||||||
@@ -471,6 +471,9 @@ public class BodyResolver {
|
|||||||
if (FunctionTypesKt.isExtensionFunctionType(supertype)) {
|
if (FunctionTypesKt.isExtensionFunctionType(supertype)) {
|
||||||
trace.report(SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE.on(typeReference));
|
trace.report(SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE.on(typeReference));
|
||||||
}
|
}
|
||||||
|
else if (FunctionTypesKt.isSuspendFunctionType(supertype)) {
|
||||||
|
trace.report(SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE.on(typeReference));
|
||||||
|
}
|
||||||
|
|
||||||
if (classDescriptor.getKind() != ClassKind.INTERFACE) {
|
if (classDescriptor.getKind() != ClassKind.INTERFACE) {
|
||||||
if (supertypeOwner.getKind() == ClassKind.ENUM_CLASS) {
|
if (supertypeOwner.getKind() == ClassKind.ENUM_CLASS) {
|
||||||
|
|||||||
Vendored
+8
@@ -16,3 +16,11 @@ typealias Test9 = suspend (() -> Unit) -> Unit
|
|||||||
typealias Test10 = suspend (suspend () -> Unit) -> Unit
|
typealias Test10 = suspend (suspend () -> Unit) -> Unit
|
||||||
typealias Test11 = suspend () -> (suspend () -> Unit)
|
typealias Test11 = suspend () -> (suspend () -> Unit)
|
||||||
typealias Test12 = suspend (suspend (() -> Unit)) -> Unit
|
typealias Test12 = suspend (suspend (() -> Unit)) -> Unit
|
||||||
|
|
||||||
|
interface Supertype1 : <!SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE!>suspend () -> Unit<!> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Supertype2 : <!SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE!>suspend String.() -> Unit<!> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Vendored
+14
@@ -6,6 +6,20 @@ public interface SAM {
|
|||||||
public abstract fun run(): kotlin.Unit
|
public abstract fun run(): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface Supertype1 : suspend () -> kotlin.Unit {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public abstract suspend override /*1*/ /*fake_override*/ fun invoke(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface Supertype2 : suspend kotlin.String.() -> kotlin.Unit {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public abstract suspend override /*1*/ /*fake_override*/ fun invoke(/*0*/ p1: kotlin.String): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
public typealias Action = () -> kotlin.Unit
|
public typealias Action = () -> kotlin.Unit
|
||||||
public typealias Test1 = suspend () -> kotlin.Unit
|
public typealias Test1 = suspend () -> kotlin.Unit
|
||||||
public typealias Test10 = suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
public typealias Test10 = suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
||||||
|
|||||||
Reference in New Issue
Block a user