Allow Result as a return type if one enabled inline classes explicitly
#KT-38042 Fixed
This commit is contained in:
+1
-1
@@ -22,7 +22,7 @@ class ResultClassInReturnTypeChecker : DeclarationChecker {
|
||||
val languageVersionSettings = context.languageVersionSettings
|
||||
if (
|
||||
languageVersionSettings.getFlag(AnalysisFlags.allowResultReturnType) ||
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.InlineClasses) &&
|
||||
languageVersionSettings.getFeatureSupport(LanguageFeature.InlineClasses) == LanguageFeature.State.ENABLED &&
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.AllowResultInReturnType)
|
||||
) return
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
fun foo() = Result.success(42)
|
||||
@@ -0,0 +1,5 @@
|
||||
$TESTDATA_DIR$/resultInReturnType.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-language-version
|
||||
1.4
|
||||
@@ -0,0 +1,4 @@
|
||||
compiler/testData/cli/jvm/resultInReturnType.kt:1:5: error: 'kotlin.Result' cannot be used as a return type
|
||||
fun foo() = Result.success(42)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
@@ -0,0 +1,4 @@
|
||||
$TESTDATA_DIR$/resultInReturnType.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-Xinline-classes
|
||||
@@ -0,0 +1 @@
|
||||
OK
|
||||
@@ -0,0 +1,4 @@
|
||||
$TESTDATA_DIR$/resultInReturnType.kt
|
||||
-d
|
||||
$TEMP_DIR$
|
||||
-XXLanguage\:+InlineClasses
|
||||
@@ -0,0 +1,10 @@
|
||||
warning: ATTENTION!
|
||||
This build uses unsafe internal compiler arguments:
|
||||
|
||||
-XXLanguage:+InlineClasses
|
||||
|
||||
This mode is not recommended for production use,
|
||||
as no stability/compatibility guarantees are given on
|
||||
compiler or generated code. Use it at your own risk!
|
||||
|
||||
OK
|
||||
@@ -615,6 +615,21 @@ public class CliTestGenerated extends AbstractCliTest {
|
||||
runTest("compiler/testData/cli/jvm/releaseCoroutinesApiVersion1.2.args");
|
||||
}
|
||||
|
||||
@TestMetadata("resultInReturnTypeUnsupportedByDefault14.args")
|
||||
public void testResultInReturnTypeUnsupportedByDefault14() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/resultInReturnTypeUnsupportedByDefault14.args");
|
||||
}
|
||||
|
||||
@TestMetadata("resultInReturnTypeWithEnabledInlineClasses.args")
|
||||
public void testResultInReturnTypeWithEnabledInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/resultInReturnTypeWithEnabledInlineClasses.args");
|
||||
}
|
||||
|
||||
@TestMetadata("resultInReturnTypeWithEnabledInlineClassesXX.args")
|
||||
public void testResultInReturnTypeWithEnabledInlineClassesXX() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/resultInReturnTypeWithEnabledInlineClassesXX.args");
|
||||
}
|
||||
|
||||
@TestMetadata("returnAsWhenKey.args")
|
||||
public void testReturnAsWhenKey() throws Exception {
|
||||
runTest("compiler/testData/cli/jvm/returnAsWhenKey.args");
|
||||
|
||||
Reference in New Issue
Block a user