FE: Use safe call when searching for suspend modifier
The modifier does not exist, when the parameter type is typealias. #KT-35187 Fixed
This commit is contained in:
+6
@@ -6582,6 +6582,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
||||||
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
||||||
|
|||||||
+6
@@ -6582,6 +6582,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
||||||
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
||||||
|
|||||||
+6
@@ -6582,6 +6582,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
||||||
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
||||||
|
|||||||
+6
-1
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollectorV
|
|||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||||
|
import org.jetbrains.kotlin.fir.analysis.checkers.getModifier
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.withSuppressedDiagnostics
|
import org.jetbrains.kotlin.fir.analysis.diagnostics.withSuppressedDiagnostics
|
||||||
import org.jetbrains.kotlin.fir.containingClass
|
import org.jetbrains.kotlin.fir.containingClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
@@ -40,6 +41,7 @@ import org.jetbrains.kotlin.fir.types.isNullable
|
|||||||
import org.jetbrains.kotlin.fir.types.toSymbol
|
import org.jetbrains.kotlin.fir.types.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
|
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||||
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
abstract class FirInlineDeclarationChecker : FirFunctionChecker() {
|
abstract class FirInlineDeclarationChecker : FirFunctionChecker() {
|
||||||
@@ -375,7 +377,10 @@ abstract class FirInlineDeclarationChecker : FirFunctionChecker() {
|
|||||||
|
|
||||||
if (isSuspendFunctionalType && !param.isCrossinline) {
|
if (isSuspendFunctionalType && !param.isCrossinline) {
|
||||||
if (function.isSuspend) {
|
if (function.isSuspend) {
|
||||||
reporter.reportOn(param.returnTypeRef.source, FirErrors.REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE, context)
|
val modifier = param.returnTypeRef.getModifier(KtTokens.SUSPEND_KEYWORD)
|
||||||
|
if (modifier != null) {
|
||||||
|
reporter.reportOn(param.returnTypeRef.source, FirErrors.REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE, context)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
reporter.reportOn(param.source, FirErrors.INLINE_SUSPEND_FUNCTION_TYPE_UNSUPPORTED, context)
|
reporter.reportOn(param.source, FirErrors.INLINE_SUSPEND_FUNCTION_TYPE_UNSUPPORTED, context)
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -10059,6 +10059,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
|
|||||||
+4
-4
@@ -44,10 +44,10 @@ object InlineParameterChecker : DeclarationChecker {
|
|||||||
parameterDescriptor?.type?.isSuspendFunctionType == true
|
parameterDescriptor?.type?.isSuspendFunctionType == true
|
||||||
) {
|
) {
|
||||||
if (declaration.hasModifier(KtTokens.SUSPEND_KEYWORD)) {
|
if (declaration.hasModifier(KtTokens.SUSPEND_KEYWORD)) {
|
||||||
val typeReference = parameter.typeReference!!
|
val modifier = parameter.typeReference?.modifierList?.getModifier(KtTokens.SUSPEND_KEYWORD)
|
||||||
val modifierList = typeReference.modifierList!!
|
if (modifier != null) {
|
||||||
val modifier = modifierList.getModifier(KtTokens.SUSPEND_KEYWORD)!!
|
context.trace.report(Errors.REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE.on(modifier))
|
||||||
context.trace.report(Errors.REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE.on(modifier))
|
}
|
||||||
} else {
|
} else {
|
||||||
context.trace.report(Errors.INLINE_SUSPEND_FUNCTION_TYPE_UNSUPPORTED.on(parameter))
|
context.trace.report(Errors.INLINE_SUSPEND_FUNCTION_TYPE_UNSUPPORTED.on(parameter))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
|
typealias Handler = suspend (String) -> Unit
|
||||||
|
|
||||||
|
suspend inline fun foo(handler: Handler) {
|
||||||
|
handler("OK")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||||
|
it.getOrThrow()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var result = "FAIL"
|
||||||
|
builder {
|
||||||
|
foo {
|
||||||
|
result = it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
// FIR_IDENTICAL
|
||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
typealias Handler = suspend (String) -> Unit
|
||||||
|
suspend inline fun foo(handler: Handler) = Unit
|
||||||
Generated
+6
@@ -6588,6 +6588,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/coroutines"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
@TestMetadata("modifierFormBuiltinSuspendFun.kt")
|
||||||
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
public void testModifierFormBuiltinSuspendFun() throws Exception {
|
||||||
|
|||||||
+6
@@ -9939,6 +9939,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
|
|||||||
+6
@@ -10059,6 +10059,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
|
|||||||
+5
@@ -7824,6 +7824,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt");
|
||||||
|
|||||||
+6
@@ -7019,6 +7019,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
|
|||||||
+6
@@ -7061,6 +7061,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
|
|||||||
+5
@@ -6219,6 +6219,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlinedTryCatchFinally.kt");
|
||||||
|
|||||||
+6
@@ -7921,6 +7921,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendLambdaNonLocalReturn.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("inlineSuspendTypealias.kt")
|
||||||
|
public void testInlineSuspendTypealias() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/inlineSuspendTypealias.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("inlinedTryCatchFinally.kt")
|
@TestMetadata("inlinedTryCatchFinally.kt")
|
||||||
public void testInlinedTryCatchFinally() throws Exception {
|
public void testInlinedTryCatchFinally() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user