Introduce basic suspend conversion in FE
#KT-15917 In Progress
This commit is contained in:
+33
@@ -22994,6 +22994,39 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/suspendConversion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SuspendConversion extends AbstractFirOldFrontendDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSuspendConversion() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("basicSuspendConversion.kt")
|
||||
public void testBasicSuspendConversion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicSuspendConversionGenerics.kt")
|
||||
public void testBasicSuspendConversionGenerics() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionGenerics.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("severalConversionsInOneCall.kt")
|
||||
public void testSeveralConversionsInOneCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionDisabled.kt")
|
||||
public void testSuspendConversionDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+20
-2
@@ -290,8 +290,10 @@ class KotlinToResolvedCallTransformer(
|
||||
is ArgumentMatch -> {
|
||||
parameter = argumentMapping.valueParameter
|
||||
|
||||
val expectedType = resolvedCall.getExpectedTypeForSamConvertedArgument(valueArgument)
|
||||
?: getEffectiveExpectedType(argumentMapping.valueParameter, valueArgument, context)
|
||||
val expectedType =
|
||||
resolvedCall.getExpectedTypeForSamConvertedArgument(valueArgument)
|
||||
?: resolvedCall.getExpectedTypeForSuspendConvertedArgument(valueArgument)
|
||||
?: getEffectiveExpectedType(argumentMapping.valueParameter, valueArgument, context)
|
||||
Pair(
|
||||
expectedType,
|
||||
CallPosition.ValueArgumentPosition(resolvedCall, argumentMapping.valueParameter, valueArgument),
|
||||
@@ -656,6 +658,7 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
private var dispatchReceiver = resolvedCallAtom.dispatchReceiverArgument?.receiver?.receiverValue
|
||||
private var smartCastDispatchReceiverType: KotlinType? = null
|
||||
private var expectedTypeForSamConvertedArgumentMap: MutableMap<ValueArgument, UnwrappedType>? = null
|
||||
private var expectedTypeForSuspendConvertedArgumentMap: MutableMap<ValueArgument, UnwrappedType>? = null
|
||||
private var argumentTypeForConstantConvertedMap: MutableMap<KtExpression, IntegerValueTypeConstant>? = null
|
||||
|
||||
|
||||
@@ -737,6 +740,7 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
}
|
||||
|
||||
calculateExpectedTypeForSamConvertedArgumentMap(substitutor)
|
||||
calculateExpectedTypeForSuspendConvertedArgumentMap(substitutor)
|
||||
calculateExpectedTypeForConstantConvertedArgumentMap()
|
||||
}
|
||||
|
||||
@@ -805,6 +809,9 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
fun getExpectedTypeForSamConvertedArgument(valueArgument: ValueArgument): UnwrappedType? =
|
||||
expectedTypeForSamConvertedArgumentMap?.get(valueArgument)
|
||||
|
||||
fun getExpectedTypeForSuspendConvertedArgument(valueArgument: ValueArgument): UnwrappedType? =
|
||||
expectedTypeForSuspendConvertedArgumentMap?.get(valueArgument)
|
||||
|
||||
private fun calculateExpectedTypeForConstantConvertedArgumentMap() {
|
||||
if (resolvedCallAtom.argumentsWithConstantConversion.isEmpty()) return
|
||||
|
||||
@@ -827,6 +834,17 @@ class NewResolvedCallImpl<D : CallableDescriptor>(
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateExpectedTypeForSuspendConvertedArgumentMap(substitutor: NewTypeSubstitutor?) {
|
||||
if (resolvedCallAtom.argumentsWithSuspendConversion.isEmpty()) return
|
||||
|
||||
expectedTypeForSuspendConvertedArgumentMap = hashMapOf()
|
||||
for ((argument, convertedType) in resolvedCallAtom.argumentsWithSuspendConversion) {
|
||||
val typeWithFreshVariables = resolvedCallAtom.freshVariablesSubstitutor.safeSubstitute(convertedType)
|
||||
val expectedType = substitutor?.safeSubstitute(typeWithFreshVariables) ?: typeWithFreshVariables
|
||||
expectedTypeForSuspendConvertedArgumentMap!![argument.psiCallArgument.valueArgument] = expectedType
|
||||
}
|
||||
}
|
||||
|
||||
override fun argumentToParameterMap(
|
||||
resultingDescriptor: CallableDescriptor,
|
||||
valueArguments: Map<ValueParameterDescriptor, ResolvedValueArgument>,
|
||||
|
||||
+4
-4
@@ -483,10 +483,10 @@ private fun KotlinResolutionCandidate.prepareExpectedType(
|
||||
argument: KotlinCallArgument,
|
||||
candidateParameter: ParameterDescriptor
|
||||
): UnwrappedType {
|
||||
val argumentType = getExpectedTypeWithSAMConversion(argument, candidateParameter) ?: argument.getExpectedType(
|
||||
candidateParameter,
|
||||
callComponents.languageVersionSettings
|
||||
)
|
||||
val argumentType =
|
||||
getExpectedTypeWithSAMConversion(argument, candidateParameter)
|
||||
?: getExpectedTypeWithSuspendConversion(argument, candidateParameter)
|
||||
?: argument.getExpectedType(candidateParameter, callComponents.languageVersionSettings)
|
||||
val resultType = knownTypeParametersResultingSubstitutor?.substitute(argumentType) ?: argumentType
|
||||
return resolvedCall.freshVariablesSubstitutor.safeSubstitute(resultType)
|
||||
}
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.calls.components
|
||||
|
||||
import org.jetbrains.kotlin.builtins.*
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
fun KotlinResolutionCandidate.getExpectedTypeWithSuspendConversion(
|
||||
argument: KotlinCallArgument,
|
||||
candidateParameter: ParameterDescriptor
|
||||
): UnwrappedType? {
|
||||
if (!callComponents.languageVersionSettings.supportsFeature(LanguageFeature.SuspendConversion)) return null
|
||||
|
||||
if (argument !is SimpleKotlinCallArgument) return null
|
||||
|
||||
val argumentType = argument.receiver.stableType
|
||||
if (!argumentType.isFunctionType) return null
|
||||
if (argumentType.isSuspendFunctionType) return null
|
||||
|
||||
val parameterType = candidateParameter.type
|
||||
if (!parameterType.isSuspendFunctionType) return null
|
||||
|
||||
val nonSuspendParameterType = createFunctionType(
|
||||
callComponents.builtIns,
|
||||
parameterType.annotations,
|
||||
parameterType.getReceiverTypeFromFunctionType(),
|
||||
parameterType.getValueParameterTypesFromFunctionType().map { it.type },
|
||||
parameterNames = null,
|
||||
parameterType.getReturnTypeFromFunctionType(),
|
||||
suspendFunction = false
|
||||
)
|
||||
|
||||
resolvedCall.registerArgumentWithSuspendConversion(argument, nonSuspendParameterType)
|
||||
|
||||
return nonSuspendParameterType
|
||||
}
|
||||
@@ -71,6 +71,7 @@ abstract class ResolvedCallAtom : ResolvedAtom() {
|
||||
abstract val freshVariablesSubstitutor: FreshVariableNewTypeSubstitutor
|
||||
abstract val knownParametersSubstitutor: TypeSubstitutor
|
||||
abstract val argumentsWithConversion: Map<KotlinCallArgument, SamConversionDescription>
|
||||
abstract val argumentsWithSuspendConversion: Map<KotlinCallArgument, UnwrappedType>
|
||||
abstract val argumentsWithConstantConversion: Map<KotlinCallArgument, IntegerValueTypeConstant>
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.constants.IntegerValueTypeConstant
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
|
||||
|
||||
abstract class ResolutionPart {
|
||||
@@ -185,14 +186,21 @@ class MutableResolvedCallAtom(
|
||||
override lateinit var knownParametersSubstitutor: TypeSubstitutor
|
||||
lateinit var argumentToCandidateParameter: Map<KotlinCallArgument, ValueParameterDescriptor>
|
||||
private var samAdapterMap: HashMap<KotlinCallArgument, SamConversionDescription>? = null
|
||||
private var suspendAdapterMap: HashMap<KotlinCallArgument, UnwrappedType>? = null
|
||||
private var signedUnsignedConstantConversions: HashMap<KotlinCallArgument, IntegerValueTypeConstant>? = null
|
||||
|
||||
val hasSamConversion: Boolean
|
||||
get() = samAdapterMap != null
|
||||
|
||||
val hasSuspendConversion: Boolean
|
||||
get() = suspendAdapterMap != null
|
||||
|
||||
override val argumentsWithConversion: Map<KotlinCallArgument, SamConversionDescription>
|
||||
get() = samAdapterMap ?: emptyMap()
|
||||
|
||||
override val argumentsWithSuspendConversion: Map<KotlinCallArgument, UnwrappedType>
|
||||
get() = suspendAdapterMap ?: emptyMap()
|
||||
|
||||
override val argumentsWithConstantConversion: Map<KotlinCallArgument, IntegerValueTypeConstant>
|
||||
get() = signedUnsignedConstantConversions ?: emptyMap()
|
||||
|
||||
@@ -203,6 +211,13 @@ class MutableResolvedCallAtom(
|
||||
samAdapterMap!![argument] = samConversionDescription
|
||||
}
|
||||
|
||||
fun registerArgumentWithSuspendConversion(argument: KotlinCallArgument, convertedType: UnwrappedType) {
|
||||
if (suspendAdapterMap == null)
|
||||
suspendAdapterMap = hashMapOf()
|
||||
|
||||
suspendAdapterMap!![argument] = convertedType
|
||||
}
|
||||
|
||||
fun registerArgumentWithConstantConversion(argument: KotlinCallArgument, convertedConstant: IntegerValueTypeConstant) {
|
||||
if (signedUnsignedConstantConversions == null)
|
||||
signedUnsignedConstantConversions = hashMapOf()
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo1(f: suspend () -> String) {}
|
||||
fun foo2(f: suspend (Int) -> String) {}
|
||||
fun foo3(f: suspend () -> Unit) {}
|
||||
|
||||
fun test(
|
||||
f0: suspend () -> String,
|
||||
f1: () -> String,
|
||||
f2: (Int) -> String,
|
||||
f3: () -> Unit,
|
||||
) {
|
||||
foo1 { "str" }
|
||||
foo1(f0)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f1)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(f2)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo3<!>(f3)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f2)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f3)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo1(f: suspend () -> String) {}
|
||||
fun foo2(f: suspend (Int) -> String) {}
|
||||
fun foo3(f: suspend () -> Unit) {}
|
||||
|
||||
fun test(
|
||||
f0: suspend () -> String,
|
||||
f1: () -> String,
|
||||
f2: (Int) -> String,
|
||||
f3: () -> Unit,
|
||||
) {
|
||||
foo1 { "str" }
|
||||
foo1(f0)
|
||||
|
||||
foo1(f1)
|
||||
foo2(f2)
|
||||
foo3(f3)
|
||||
|
||||
foo1(<!TYPE_MISMATCH!>f2<!>)
|
||||
foo1(<!TYPE_MISMATCH!>f3<!>)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun foo1(/*0*/ f: suspend () -> kotlin.String): kotlin.Unit
|
||||
public fun foo2(/*0*/ f: suspend (kotlin.Int) -> kotlin.String): kotlin.Unit
|
||||
public fun foo3(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(/*0*/ f0: suspend () -> kotlin.String, /*1*/ f1: () -> kotlin.String, /*2*/ f2: (kotlin.Int) -> kotlin.String, /*3*/ f3: () -> kotlin.Unit): kotlin.Unit
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
class Inv2<T, K>
|
||||
|
||||
fun <T> foo1(f: suspend (T) -> String): T = TODO()
|
||||
fun <T> foo2(f: suspend () -> T): T = TODO()
|
||||
fun <T, K> foo3(f: suspend (T) -> K): Inv2<T, K> = TODO()
|
||||
|
||||
fun <I> id(e: I): I = e
|
||||
|
||||
fun test(f: (Int) -> String, g: () -> String) {
|
||||
val a0 = <!INAPPLICABLE_CANDIDATE!>foo1<!>(f)
|
||||
a0
|
||||
|
||||
val a1 = <!INAPPLICABLE_CANDIDATE!>foo2<!>(g)
|
||||
a1
|
||||
|
||||
val a2 = <!INAPPLICABLE_CANDIDATE!>foo3<!>(f)
|
||||
a2
|
||||
|
||||
val a3 = <!INAPPLICABLE_CANDIDATE!>foo1<!>(id(f))
|
||||
a3
|
||||
|
||||
val a4 = <!INAPPLICABLE_CANDIDATE!>foo2<!>(id(g))
|
||||
a4
|
||||
|
||||
val a5 = <!INAPPLICABLE_CANDIDATE!>foo3<!>(id(f))
|
||||
a5
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
class Inv2<T, K>
|
||||
|
||||
fun <T> foo1(f: suspend (T) -> String): T = TODO()
|
||||
fun <T> foo2(f: suspend () -> T): T = TODO()
|
||||
fun <T, K> foo3(f: suspend (T) -> K): Inv2<T, K> = TODO()
|
||||
|
||||
fun <I> id(e: I): I = e
|
||||
|
||||
fun test(f: (Int) -> String, g: () -> String) {
|
||||
val a0 = foo1(f)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>a0<!>
|
||||
|
||||
val a1 = foo2(g)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>a1<!>
|
||||
|
||||
val a2 = foo3(f)
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv2<kotlin.Int, kotlin.String>")!>a2<!>
|
||||
|
||||
val a3 = foo1(id(f))
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>a3<!>
|
||||
|
||||
val a4 = foo2(id(g))
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>a4<!>
|
||||
|
||||
val a5 = foo3(id(f))
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("Inv2<kotlin.Int, kotlin.String>")!>a5<!>
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> foo1(/*0*/ f: suspend (T) -> kotlin.String): T
|
||||
public fun </*0*/ T> foo2(/*0*/ f: suspend () -> T): T
|
||||
public fun </*0*/ T, /*1*/ K> foo3(/*0*/ f: suspend (T) -> K): Inv2<T, K>
|
||||
public fun </*0*/ I> id(/*0*/ e: I): I
|
||||
public fun test(/*0*/ f: (kotlin.Int) -> kotlin.String, /*1*/ g: () -> kotlin.String): kotlin.Unit
|
||||
|
||||
public final class Inv2</*0*/ T, /*1*/ K> {
|
||||
public constructor Inv2</*0*/ T, /*1*/ K>()
|
||||
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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(f: () -> String, g: suspend () -> String, h: suspend () -> String) {}
|
||||
|
||||
fun test(f: () -> String, g: suspend () -> String) {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(f, f, f)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(f, { "str" }, f)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(f, f, g)
|
||||
foo(f, g, g)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo(f: () -> String, g: suspend () -> String, h: suspend () -> String) {}
|
||||
|
||||
fun test(f: () -> String, g: suspend () -> String) {
|
||||
foo(f, f, f)
|
||||
foo(f, { "str" }, f)
|
||||
foo(f, f, g)
|
||||
foo(f, g, g)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ f: () -> kotlin.String, /*1*/ g: suspend () -> kotlin.String, /*2*/ h: suspend () -> kotlin.String): kotlin.Unit
|
||||
public fun test(/*0*/ f: () -> kotlin.String, /*1*/ g: suspend () -> kotlin.String): kotlin.Unit
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: -SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo1(f: suspend () -> String) {}
|
||||
fun foo2(f: suspend (Int) -> String) {}
|
||||
fun foo3(f: suspend () -> Unit) {}
|
||||
|
||||
fun test(
|
||||
f0: suspend () -> String,
|
||||
f1: () -> String,
|
||||
f2: (Int) -> String,
|
||||
f3: () -> Unit,
|
||||
) {
|
||||
foo1 { "str" }
|
||||
foo1(f0)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f1)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(f2)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo3<!>(f3)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f2)
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(f3)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: -SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo1(f: suspend () -> String) {}
|
||||
fun foo2(f: suspend (Int) -> String) {}
|
||||
fun foo3(f: suspend () -> Unit) {}
|
||||
|
||||
fun test(
|
||||
f0: suspend () -> String,
|
||||
f1: () -> String,
|
||||
f2: (Int) -> String,
|
||||
f3: () -> Unit,
|
||||
) {
|
||||
foo1 { "str" }
|
||||
foo1(f0)
|
||||
|
||||
foo1(<!TYPE_MISMATCH!>f1<!>)
|
||||
foo2(<!TYPE_MISMATCH!>f2<!>)
|
||||
foo3(<!TYPE_MISMATCH!>f3<!>)
|
||||
|
||||
foo1(<!TYPE_MISMATCH!>f2<!>)
|
||||
foo1(<!TYPE_MISMATCH!>f3<!>)
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
public fun foo1(/*0*/ f: suspend () -> kotlin.String): kotlin.Unit
|
||||
public fun foo2(/*0*/ f: suspend (kotlin.Int) -> kotlin.String): kotlin.Unit
|
||||
public fun foo3(/*0*/ f: suspend () -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(/*0*/ f0: suspend () -> kotlin.String, /*1*/ f1: () -> kotlin.String, /*2*/ f2: (kotlin.Int) -> kotlin.String, /*3*/ f3: () -> kotlin.Unit): kotlin.Unit
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -SuspendConversion
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_VARIABLE
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun useSuspendFn(sfn: suspend () -> Unit) = sfn
|
||||
|
||||
@@ -23076,6 +23076,39 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/suspendConversion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SuspendConversion extends AbstractDiagnosticsTestWithFirValidation {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSuspendConversion() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/suspendConversion"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("basicSuspendConversion.kt")
|
||||
public void testBasicSuspendConversion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicSuspendConversionGenerics.kt")
|
||||
public void testBasicSuspendConversionGenerics() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionGenerics.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("severalConversionsInOneCall.kt")
|
||||
public void testSeveralConversionsInOneCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionDisabled.kt")
|
||||
public void testSuspendConversionDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Generated
+33
@@ -22996,6 +22996,39 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/suspendConversion")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SuspendConversion extends AbstractDiagnosticsUsingJavacTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSuspendConversion() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/suspendConversion"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("basicSuspendConversion.kt")
|
||||
public void testBasicSuspendConversion() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("basicSuspendConversionGenerics.kt")
|
||||
public void testBasicSuspendConversionGenerics() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/basicSuspendConversionGenerics.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("severalConversionsInOneCall.kt")
|
||||
public void testSeveralConversionsInOneCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/severalConversionsInOneCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionDisabled.kt")
|
||||
public void testSuspendConversionDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/suspendConversion/suspendConversionDisabled.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/syntheticExtensions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -150,6 +150,7 @@ enum class LanguageFeature(
|
||||
SamConversionPerArgument(sinceVersion = KOTLIN_1_4),
|
||||
FunctionReferenceWithDefaultValueAsOtherType(sinceVersion = KOTLIN_1_4),
|
||||
NonStrictOnlyInputTypesChecks(sinceVersion = KOTLIN_1_4),
|
||||
SuspendConversion(sinceVersion = KOTLIN_1_4),
|
||||
|
||||
BooleanElvisBoundSmartCasts(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), // see KT-26357 for details
|
||||
NewDataFlowForTryExpressions(sinceVersion = KOTLIN_1_4, defaultState = State.DISABLED),
|
||||
|
||||
Reference in New Issue
Block a user