Add language feature for suspend functions in fun interfaces
Since in 1.5 JVM_IR is enabled by default and supports suspend functions in fun interfaces, it is safe to enable the feature by default as well.
This commit is contained in:
+22
@@ -10054,6 +10054,28 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.kt");
|
runTest("compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/tests/functionLiterals/suspend")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class Suspend extends AbstractFirDiagnosticTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInSuspend() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/functionLiterals/suspend"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("disabled.kt")
|
||||||
|
public void testDisabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enabled.kt")
|
||||||
|
public void testEnabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+5
-1
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.resolve.checkers
|
package org.jetbrains.kotlin.resolve.checkers
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||||
@@ -60,7 +61,10 @@ class FunInterfaceDeclarationChecker : DeclarationChecker {
|
|||||||
) {
|
) {
|
||||||
val ktFunction = abstractMember.source.getPsi() as? KtNamedFunction
|
val ktFunction = abstractMember.source.getPsi() as? KtNamedFunction
|
||||||
|
|
||||||
if (abstractMember.isSuspend) {
|
if (abstractMember.isSuspend &&
|
||||||
|
!(context.languageVersionSettings.supportsFeature(LanguageFeature.SuspendFunctionsInFunInterfaces) &&
|
||||||
|
context.languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault))
|
||||||
|
) {
|
||||||
val reportOn = ktFunction?.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD) ?: funInterfaceKeyword
|
val reportOn = ktFunction?.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD) ?: funInterfaceKeyword
|
||||||
context.trace.report(Errors.FUN_INTERFACE_WITH_SUSPEND_FUNCTION.on(reportOn))
|
context.trace.report(Errors.FUN_INTERFACE_WITH_SUSPEND_FUNCTION.on(reportOn))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// LANGUAGE: -SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault
|
||||||
|
|
||||||
|
fun interface I {
|
||||||
|
suspend fun foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// LANGUAGE: -SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault
|
||||||
|
|
||||||
|
fun interface I {
|
||||||
|
<!FUN_INTERFACE_WITH_SUSPEND_FUNCTION!>suspend<!> fun foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun interface I {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public abstract suspend fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// LANGUAGE: +SuspendFunctionsInFunInterfaces, +JvmIrEnabledByDefault
|
||||||
|
|
||||||
|
fun interface I {
|
||||||
|
suspend fun foo()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun interface I {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public abstract suspend fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
Generated
+22
@@ -10060,6 +10060,28 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.kt");
|
runTest("compiler/testData/diagnostics/tests/functionLiterals/return/unresolvedReferenceInReturnBlock.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
@TestMetadata("compiler/testData/diagnostics/tests/functionLiterals/suspend")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
public class Suspend extends AbstractDiagnosticTest {
|
||||||
|
@Test
|
||||||
|
public void testAllFilesPresentInSuspend() throws Exception {
|
||||||
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/functionLiterals/suspend"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("disabled.kt")
|
||||||
|
public void testDisabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/disabled.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("enabled.kt")
|
||||||
|
public void testEnabled() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/functionLiterals/suspend/enabled.kt");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ enum class LanguageFeature(
|
|||||||
|
|
||||||
InlineClasses(sinceVersion = KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE),
|
InlineClasses(sinceVersion = KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE),
|
||||||
JvmInlineValueClasses(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
JvmInlineValueClasses(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
||||||
|
SuspendFunctionsInFunInterfaces(sinceVersion = KOTLIN_1_5, defaultState = State.ENABLED, kind = OTHER),
|
||||||
;
|
;
|
||||||
|
|
||||||
val presentableName: String
|
val presentableName: String
|
||||||
|
|||||||
Reference in New Issue
Block a user