[FE 1.0] Make "Unit conversions" accessible experimental feature
This commit is contained in:
+6
@@ -32690,6 +32690,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/chainedUnitSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49394.kt")
|
||||
public void testKt49394() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/kt49394.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noUnitConversionForGenericTypeFromArrow.kt")
|
||||
public void testNoUnitConversionForGenericTypeFromArrow() throws Exception {
|
||||
|
||||
+6
@@ -32690,6 +32690,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/chainedUnitSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49394.kt")
|
||||
public void testKt49394() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/kt49394.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noUnitConversionForGenericTypeFromArrow.kt")
|
||||
public void testNoUnitConversionForGenericTypeFromArrow() throws Exception {
|
||||
|
||||
+6
@@ -32690,6 +32690,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/chainedUnitSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49394.kt")
|
||||
public void testKt49394() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/kt49394.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noUnitConversionForGenericTypeFromArrow.kt")
|
||||
public void testNoUnitConversionForGenericTypeFromArrow() throws Exception {
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ object UnitConversionCallChecker : CallChecker {
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
if (resolvedCall !is NewResolvedCallImpl<*>) return
|
||||
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.UnitConversion)) return
|
||||
if (context.languageVersionSettings.supportsFeature(LanguageFeature.UnitConversionsOnArbitraryExpressions)) return
|
||||
|
||||
// lambdas are working since 1.0, callable references are handled as part of reference adaptation
|
||||
// => here we're checking only simple argument
|
||||
@@ -26,7 +26,7 @@ object UnitConversionCallChecker : CallChecker {
|
||||
context.trace.report(
|
||||
Errors.UNSUPPORTED_FEATURE.on(
|
||||
argumentWithUnitConversion.psiCallArgument.valueArgument.asElement(),
|
||||
LanguageFeature.UnitConversion to context.languageVersionSettings
|
||||
LanguageFeature.UnitConversionsOnArbitraryExpressions to context.languageVersionSettings
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion +SuspendConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion +SuspendConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun interface SuspendRunnable {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun interface KRunnable {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun interface KRunnable {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion +SuspendConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: suspend () -> Unit) {}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion +SuspendConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions +SuspendConversion
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: suspend () -> Unit) {}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
fun interface Run {
|
||||
fun run()
|
||||
}
|
||||
|
||||
fun handle(run: Run) {
|
||||
//...
|
||||
}
|
||||
|
||||
val x = {
|
||||
"STRING"
|
||||
}
|
||||
|
||||
fun test() {
|
||||
handle(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fun interface Run {
|
||||
fun run()
|
||||
}
|
||||
|
||||
fun handle(run: Run) {
|
||||
//...
|
||||
}
|
||||
|
||||
val x = {
|
||||
"STRING"
|
||||
}
|
||||
|
||||
fun test() {
|
||||
handle(<!UNSUPPORTED_FEATURE("The feature "unit conversions on arbitrary expressions" is experimental and should be enabled explicitly")!>x<!>)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public val x: () -> kotlin.String
|
||||
public fun handle(/*0*/ run: Run): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public fun interface Run {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: -UnitConversion
|
||||
// !LANGUAGE: -UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: () -> Unit) {}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: -UnitConversion
|
||||
// !LANGUAGE: -UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: () -> Unit) {}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: () -> Unit) {}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: () -> Unit) {}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: (Int, String) -> Unit) {}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// !LANGUAGE: +UnitConversion
|
||||
// !LANGUAGE: +UnitConversionsOnArbitraryExpressions
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
|
||||
fun foo(f: (Int, String) -> Unit) {}
|
||||
|
||||
Generated
+6
@@ -32780,6 +32780,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/chainedUnitSuspendConversion.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49394.kt")
|
||||
public void testKt49394() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unitConversion/kt49394.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("noUnitConversionForGenericTypeFromArrow.kt")
|
||||
public void testNoUnitConversionForGenericTypeFromArrow() throws Exception {
|
||||
|
||||
@@ -142,7 +142,6 @@ enum class LanguageFeature(
|
||||
SamConversionForKotlinFunctions(KOTLIN_1_4),
|
||||
SamConversionPerArgument(KOTLIN_1_4),
|
||||
FunctionReferenceWithDefaultValueAsOtherType(KOTLIN_1_4),
|
||||
UnitConversion(KOTLIN_1_4, defaultState = State.DISABLED),
|
||||
OverloadResolutionByLambdaReturnType(KOTLIN_1_4),
|
||||
ContractsOnCallsWithImplicitReceiver(KOTLIN_1_4),
|
||||
BooleanElvisBoundSmartCasts(KOTLIN_1_3, defaultState = State.DISABLED), // see KT-26357 for details
|
||||
@@ -299,6 +298,7 @@ enum class LanguageFeature(
|
||||
GenericInlineClassParameter(sinceVersion = null, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE),
|
||||
ValueClasses(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE),
|
||||
JavaSamConversionEqualsHashCode(sinceVersion = null, defaultState = State.DISABLED, kind = UNSTABLE_FEATURE),
|
||||
UnitConversionsOnArbitraryExpressions(sinceVersion = null, defaultState = State.DISABLED),
|
||||
;
|
||||
|
||||
val presentableName: String
|
||||
|
||||
+1
-1
@@ -343,7 +343,7 @@ class LldbTests {
|
||||
v()
|
||||
}
|
||||
""".feedOutput("kt42208-3.kt")
|
||||
val binary = arrayOf(kt42208One, kt42208Two, kt42208Three).binary("kt42208", "-g", "-XXLanguage:+UnitConversion")
|
||||
val binary = arrayOf(kt42208One, kt42208Two, kt42208Three).binary("kt42208", "-g", "-XXLanguage:+UnitConversionsOnArbitraryExpressions")
|
||||
"""
|
||||
> b kt42208-2.kt:5
|
||||
> ${lldbCommandRunOrContinue()}
|
||||
|
||||
Reference in New Issue
Block a user