Support suspend functions as superinterfaces
Forbid mixing suspend and non-suspend functional supertypes. Since JVM BE generates suspend functional types as non-suspend ones with SuspendFunction marker interface, there is not way to distinguish non-suspend functional type from suspend one if they are mixed. #KT-18707 Fixed
This commit is contained in:
+130
@@ -5680,6 +5680,136 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SuspendFunctionAsSupertype {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspendFunctionAsSupertype() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class KSuspendFunctionN {
|
||||
@Test
|
||||
public void testAllFilesPresentInKSuspendFunctionN() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Simple {
|
||||
@Test
|
||||
public void testAllFilesPresentInSimple() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SuspendFunctionN {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspendFunctionN() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/simple.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+130
@@ -5680,6 +5680,136 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SuspendFunctionAsSupertype {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspendFunctionAsSupertype() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class KSuspendFunctionN {
|
||||
@Test
|
||||
public void testAllFilesPresentInKSuspendFunctionN() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Simple {
|
||||
@Test
|
||||
public void testAllFilesPresentInSimple() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SuspendFunctionN {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspendFunctionN() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/simple.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -9366,6 +9366,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void testSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionMethodReference.kt")
|
||||
public void testSuspendFunctionMethodReference() throws Exception {
|
||||
|
||||
@@ -325,6 +325,7 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_IS_KSUSPEND_FUNCTION_TYPE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<PsiElement> MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
DiagnosticFactory0<KtTypeReference> MANY_CLASSES_IN_SUPERTYPE_LIST = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeReference> SUPERTYPE_APPEARS_TWICE = DiagnosticFactory0.create(ERROR);
|
||||
|
||||
+1
@@ -635,6 +635,7 @@ public class DefaultErrorMessages {
|
||||
MAP.put(SUPERTYPE_INITIALIZED_IN_INTERFACE, "Interfaces cannot initialize supertypes");
|
||||
MAP.put(SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE, "Suspend function type is not allowed as supertypes");
|
||||
MAP.put(SUPERTYPE_IS_KSUSPEND_FUNCTION_TYPE, "KSuspendFunctionN interfaces are not allowed as supertypes");
|
||||
MAP.put(MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES, "Mixing suspend and non-suspend supertypes is not allowed");
|
||||
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(METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, "An interface may not implement a method of 'Any'");
|
||||
|
||||
@@ -587,10 +587,13 @@ public class BodyResolver {
|
||||
if (FunctionTypesKt.isExtensionFunctionType(supertype)) {
|
||||
trace.report(SUPERTYPE_IS_EXTENSION_FUNCTION_TYPE.on(typeReference));
|
||||
}
|
||||
else if (FunctionTypesKt.isSuspendFunctionType(supertype)) {
|
||||
else if (FunctionTypesKt.isSuspendFunctionType(supertype) &&
|
||||
!languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionAsSupertype)
|
||||
) {
|
||||
trace.report(SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE.on(typeReference));
|
||||
}
|
||||
else if (FunctionTypesKt.isKSuspendFunctionType(supertype)) {
|
||||
else if (FunctionTypesKt.isKSuspendFunctionType(supertype) &&
|
||||
!languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionAsSupertype)) {
|
||||
trace.report(SUPERTYPE_IS_KSUSPEND_FUNCTION_TYPE.on(typeReference));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
|
||||
SealedInheritorInSamePackageChecker,
|
||||
SealedInheritorInSameModuleChecker,
|
||||
SealedInterfaceAllowedChecker,
|
||||
SuspendFunctionAsSupertypeChecker,
|
||||
)
|
||||
|
||||
private val DEFAULT_CALL_CHECKERS = listOf(
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.resolve.checkers
|
||||
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassKind
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getAllSuperClassifiers
|
||||
|
||||
object SuspendFunctionAsSupertypeChecker : DeclarationChecker {
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionAsSupertype)) return
|
||||
if (descriptor !is ClassDescriptor) return
|
||||
|
||||
val functionalSupertypes = descriptor.getAllSuperClassifiers().filterIsInstance<FunctionClassDescriptor>().toList()
|
||||
|
||||
if (functionalSupertypes.none {
|
||||
it.functionKind == FunctionClassKind.SuspendFunction ||
|
||||
it.functionKind == FunctionClassKind.KSuspendFunction
|
||||
}
|
||||
) return
|
||||
|
||||
if (functionalSupertypes.any {
|
||||
it.functionKind == FunctionClassKind.Function ||
|
||||
it.functionKind == FunctionClassKind.KFunction
|
||||
}
|
||||
) {
|
||||
val reportOn = (declaration as? KtClassOrObject)?.getSuperTypeList() ?: declaration
|
||||
context.trace.report(Errors.MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES.on(reportOn))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS, JS_IR, JVM
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
var res = "FAIL"
|
||||
|
||||
class C: suspend () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
res = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val o: suspend () -> Unit = object : suspend () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
res = "OK"
|
||||
}
|
||||
}
|
||||
o.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
if (res != "OK") return "FAIL 1: $res"
|
||||
|
||||
res = "FAIL 2"
|
||||
C().startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
return res
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class C: KSuspendFunction0<Unit>, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: KSuspendFunction0<Unit>, () -> Unit {
|
||||
}
|
||||
|
||||
object O: KSuspendFunction0<Unit>, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
abstract class CSuper: () -> Unit
|
||||
|
||||
class C: CSuper(), KSuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O: CSuper(), KSuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SCSuper: KSuspendFunction0<Unit>
|
||||
|
||||
class C1: SCSuper(), () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O1: SCSuper(), () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
abstract class CSuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>CSuper(), KSuspendFunction0<Unit><!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>CSuper(), KSuspendFunction0<Unit><!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SCSuper: KSuspendFunction0<Unit>
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SCSuper(), () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SCSuper(), () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun interface FISuper: () -> Unit
|
||||
|
||||
class C: KSuspendFunction0<Unit>, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: KSuspendFunction0<Unit>, FISuper {
|
||||
}
|
||||
|
||||
object O: KSuspendFunction0<Unit>, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun interface FISuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, FISuper<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
interface ISuper: () -> Unit
|
||||
|
||||
class C: KSuspendFunction0<Unit>, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: KSuspendFunction0<Unit>, ISuper {
|
||||
}
|
||||
|
||||
object O: KSuspendFunction0<Unit>, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface SISuper: KSuspendFunction0<Unit>
|
||||
|
||||
class C1: SISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I1: SISuper, () -> Unit {
|
||||
}
|
||||
|
||||
object O1: SISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: SISuper, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I2: SISuper, ISuper {
|
||||
}
|
||||
|
||||
object O2: SISuper, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS, -ABSTRACT_MEMBER_NOT_IMPLEMENTED, -ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
interface ISuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, ISuper<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>KSuspendFunction0<Unit>, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface SISuper: KSuspendFunction0<Unit>
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
}
|
||||
|
||||
object O2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// FIR_IDENTICAL
|
||||
// DIAGNOSTICS: -ABSTRACT_MEMBER_NOT_IMPLEMENTED
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
class C: KSuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface I: KSuspendFunction0<Unit> {
|
||||
}
|
||||
|
||||
object O: KSuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
class C: suspend () -> Unit, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: suspend () -> Unit, () -> Unit {
|
||||
}
|
||||
|
||||
interface I: suspend () -> Unit, () -> Unit {
|
||||
}
|
||||
|
||||
object O: suspend () -> Unit, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, () -> Unit<!> {
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
abstract class CSuper: () -> Unit
|
||||
|
||||
class C: CSuper(), suspend () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O: CSuper(), suspend () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SCSuper: suspend () -> Unit
|
||||
|
||||
class C1: SCSuper(), () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O1: SCSuper(), () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
abstract class CSuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>CSuper(), suspend () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>CSuper(), suspend () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SCSuper: suspend () -> Unit
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SCSuper(), () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SCSuper(), () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
fun interface FISuper: () -> Unit
|
||||
|
||||
class C: suspend () -> Unit, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: suspend () -> Unit, FISuper {
|
||||
}
|
||||
|
||||
interface I: suspend () -> Unit, FISuper {
|
||||
}
|
||||
|
||||
object O: suspend () -> Unit, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface SFISuper: suspend () -> Unit
|
||||
|
||||
class C1: SFISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: SFISuper, () -> Unit {
|
||||
}
|
||||
|
||||
interface I1: SFISuper, () -> Unit {
|
||||
}
|
||||
|
||||
object O1: SFISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: SFISuper, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: SFISuper, FISuper {
|
||||
}
|
||||
|
||||
interface I2: SFISuper, FISuper {
|
||||
}
|
||||
|
||||
object O2: SFISuper, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
fun interface FISuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, FISuper<!> {
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, FISuper<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface SFISuper: suspend () -> Unit
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
interface I1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
}
|
||||
|
||||
interface I2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
}
|
||||
|
||||
object O2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
interface ISuper: () -> Unit
|
||||
|
||||
class C: suspend () -> Unit, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: suspend () -> Unit, ISuper {
|
||||
}
|
||||
|
||||
interface I: suspend () -> Unit, ISuper {
|
||||
}
|
||||
|
||||
object O: suspend () -> Unit, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface SISuper: suspend () -> Unit
|
||||
|
||||
class C1: SISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: SISuper, () -> Unit {
|
||||
}
|
||||
|
||||
interface I1: SISuper, () -> Unit {
|
||||
}
|
||||
|
||||
object O1: SISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: SISuper, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: SISuper, ISuper {
|
||||
}
|
||||
|
||||
interface I2: SISuper, ISuper {
|
||||
}
|
||||
|
||||
object O2: SISuper, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
interface ISuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, ISuper<!> {
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, ISuper<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>suspend () -> Unit, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface SISuper: suspend () -> Unit
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
interface I1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
}
|
||||
|
||||
interface I2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
}
|
||||
|
||||
object O2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// FIR_IDENTICAL
|
||||
|
||||
class C: suspend () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: suspend () -> Unit {
|
||||
}
|
||||
|
||||
interface I: suspend () -> Unit {
|
||||
}
|
||||
|
||||
object O: suspend () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
import kotlin.coroutines.*
|
||||
|
||||
class C: SuspendFunction0<Unit>, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: SuspendFunction0<Unit>, () -> Unit {
|
||||
}
|
||||
|
||||
interface I: SuspendFunction0<Unit>, () -> Unit {
|
||||
}
|
||||
|
||||
object O: SuspendFunction0<Unit>, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
import kotlin.coroutines.*
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, () -> Unit<!> {
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
abstract class CSuper: () -> Unit
|
||||
|
||||
class C: CSuper(), SuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O: CSuper(), SuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SCSuper: SuspendFunction0<Unit>
|
||||
|
||||
class C1: SCSuper(), () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O1: SCSuper(), () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
abstract class CSuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>CSuper(), SuspendFunction0<Unit><!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>CSuper(), SuspendFunction0<Unit><!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class SCSuper: SuspendFunction0<Unit>
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SCSuper(), () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SCSuper(), () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun interface FISuper: () -> Unit
|
||||
|
||||
class C: SuspendFunction0<Unit>, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: SuspendFunction0<Unit>, FISuper {
|
||||
}
|
||||
|
||||
interface I: SuspendFunction0<Unit>, FISuper {
|
||||
}
|
||||
|
||||
object O: SuspendFunction0<Unit>, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface SFISuper: SuspendFunction0<Unit>
|
||||
|
||||
class C1: SFISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: SFISuper, () -> Unit {
|
||||
}
|
||||
|
||||
interface I1: SFISuper, () -> Unit {
|
||||
}
|
||||
|
||||
object O1: SFISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: SFISuper, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: SFISuper, FISuper {
|
||||
}
|
||||
|
||||
interface I2: SFISuper, FISuper {
|
||||
}
|
||||
|
||||
object O2: SFISuper, FISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun interface FISuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, FISuper<!> {
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, FISuper<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface SFISuper: SuspendFunction0<Unit>
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
interface I1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
}
|
||||
|
||||
interface I2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
}
|
||||
|
||||
object O2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SFISuper, FISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
interface ISuper: () -> Unit
|
||||
|
||||
class C: SuspendFunction0<Unit>, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: SuspendFunction0<Unit>, ISuper {
|
||||
}
|
||||
|
||||
interface I: SuspendFunction0<Unit>, ISuper {
|
||||
}
|
||||
|
||||
object O: SuspendFunction0<Unit>, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface SISuper: SuspendFunction0<Unit>
|
||||
|
||||
class C1: SISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: SISuper, () -> Unit {
|
||||
}
|
||||
|
||||
interface I1: SISuper, () -> Unit {
|
||||
}
|
||||
|
||||
object O1: SISuper, () -> Unit {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: SISuper, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: SISuper, ISuper {
|
||||
}
|
||||
|
||||
interface I2: SISuper, ISuper {
|
||||
}
|
||||
|
||||
object O2: SISuper, ISuper {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// DIAGNOSTICS: -CONFLICTING_INHERITED_MEMBERS, -CONFLICTING_OVERLOADS
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
interface ISuper: () -> Unit
|
||||
|
||||
class C: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, ISuper<!> {
|
||||
}
|
||||
|
||||
interface I: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, ISuper<!> {
|
||||
}
|
||||
|
||||
object O: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SuspendFunction0<Unit>, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
interface SISuper: SuspendFunction0<Unit>
|
||||
|
||||
class C1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
interface I1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
}
|
||||
|
||||
object O1: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, () -> Unit<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
class C2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
}
|
||||
|
||||
interface I2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
}
|
||||
|
||||
object O2: <!MIXING_SUSPEND_AND_NON_SUSPEND_SUPERTYPES!>SISuper, ISuper<!> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/simple.kt
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +SuspendFunctionAsSupertype
|
||||
// SKIP_TXT
|
||||
// FIR_IDENTICAL
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
class C: SuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
|
||||
fun interface FI: SuspendFunction0<Unit> {
|
||||
}
|
||||
|
||||
interface I: SuspendFunction0<Unit> {
|
||||
}
|
||||
|
||||
object O: SuspendFunction0<Unit> {
|
||||
override suspend fun invoke() {
|
||||
}
|
||||
}
|
||||
Generated
+130
@@ -5686,6 +5686,136 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/callableReference/outsideSuspend.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SuspendFunctionAsSupertype {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspendFunctionAsSupertype() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class KSuspendFunctionN {
|
||||
@Test
|
||||
public void testAllFilesPresentInKSuspendFunctionN() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/kSuspendFunctionN/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class Simple {
|
||||
@Test
|
||||
public void testAllFilesPresentInSimple() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/simple/simple.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
public class SuspendFunctionN {
|
||||
@Test
|
||||
public void testAllFilesPresentInSuspendFunctionN() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypes.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperFunInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperFunInterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt")
|
||||
public void testMixingSuspendAndNonSuspendSupertypesThruSuperinterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/mixingSuspendAndNonSuspendSupertypesThruSuperinterface.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/coroutines/suspendFunctionAsSupertype/suspendFunctionN/simple.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
+6
@@ -9366,6 +9366,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void testSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionMethodReference.kt")
|
||||
public void testSuspendFunctionMethodReference() throws Exception {
|
||||
|
||||
+6
@@ -9366,6 +9366,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void testSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendFunctionMethodReference.kt")
|
||||
public void testSuspendFunctionMethodReference() throws Exception {
|
||||
|
||||
+5
@@ -6801,6 +6801,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt38099.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void ignoreSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
|
||||
}
|
||||
|
||||
@@ -205,6 +205,8 @@ enum class LanguageFeature(
|
||||
DefinitelyNotNullTypeParameters(KOTLIN_1_6),
|
||||
ProhibitUsingNullableTypeParameterAgainstNotNullAnnotated(KOTLIN_1_6, kind = BUG_FIX),
|
||||
|
||||
SuspendFunctionAsSupertype(KOTLIN_1_6),
|
||||
|
||||
// Temporarily disabled, see KT-27084/KT-22379
|
||||
SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX),
|
||||
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -6558,6 +6558,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void testSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionMethodReference.kt")
|
||||
public void testSuspendFunctionMethodReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");
|
||||
|
||||
Generated
+5
@@ -5969,6 +5969,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void testSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionMethodReference.kt")
|
||||
public void testSuspendFunctionMethodReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");
|
||||
|
||||
Generated
+5
@@ -5969,6 +5969,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunImportedFromObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionAsSupertype.kt")
|
||||
public void testSuspendFunctionAsSupertype() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionAsSupertype.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendFunctionMethodReference.kt")
|
||||
public void testSuspendFunctionMethodReference() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/suspendFunctionMethodReference.kt");
|
||||
|
||||
Reference in New Issue
Block a user