diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt index 85e21b51dda..874993309fe 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/CommonCompilerArguments.kt @@ -336,6 +336,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() { if (newInference) { put(LanguageFeature.NewInference, LanguageFeature.State.ENABLED) put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED) + put(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType, LanguageFeature.State.ENABLED) } if (inlineClasses) { @@ -382,19 +383,30 @@ abstract class CommonCompilerArguments : CommonToolArguments() { val featuresThatForcePreReleaseBinaries = mutableListOf() var standaloneSamConversionFeaturePassedExplicitly = false + var functionReferenceWithDefaultValueFeaturePassedExplicitly = false for ((feature, state) in internalArguments.filterIsInstance()) { put(feature, state) if (state == LanguageFeature.State.ENABLED && feature.forcesPreReleaseBinariesIfEnabled()) { featuresThatForcePreReleaseBinaries += feature } - if (feature == LanguageFeature.SamConversionPerArgument) { - standaloneSamConversionFeaturePassedExplicitly = true + when (feature) { + LanguageFeature.SamConversionPerArgument -> + standaloneSamConversionFeaturePassedExplicitly = true + + LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType -> + functionReferenceWithDefaultValueFeaturePassedExplicitly = true + + else -> {} } } - if (!standaloneSamConversionFeaturePassedExplicitly && this[LanguageFeature.NewInference] == LanguageFeature.State.ENABLED) { - put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED) + if (this[LanguageFeature.NewInference] == LanguageFeature.State.ENABLED) { + if (!standaloneSamConversionFeaturePassedExplicitly) + put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED) + + if (!functionReferenceWithDefaultValueFeaturePassedExplicitly) + put(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType, LanguageFeature.State.ENABLED) } if (featuresThatForcePreReleaseBinaries.isNotEmpty()) { diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index e4e97d55ae7..deb62c9cd40 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -1707,6 +1707,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.kt"); } + @TestMetadata("functionReferenceWithDefaultValueAsOtherFunctionType.kt") + public void testFunctionReferenceWithDefaultValueAsOtherFunctionType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.kt"); + } + + @TestMetadata("functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt") + public void testFunctionReferenceWithDefaultValueAsOtherFunctionType_enabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt"); + } + @TestMetadata("kt15439_completeCall.kt") public void testKt15439_completeCall() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/kt15439_completeCall.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index c94747ba02d..bdbf9224a44 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -5,10 +5,10 @@ package org.jetbrains.kotlin.resolve.calls -import com.intellij.psi.util.PsiUtil import org.jetbrains.kotlin.builtins.UnsignedTypes import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor import org.jetbrains.kotlin.builtins.isExtensionFunctionType +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.diagnostics.Errors.* import org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.INVOKE_ON_FUNCTION_TYPE @@ -148,6 +148,21 @@ class DiagnosticReporterByTrackingStrategy( } } } + + CallableReferencesDefaultArgumentUsed::class.java -> { + require(diagnostic is CallableReferencesDefaultArgumentUsed) { + "diagnostic ($diagnostic) should have type CallableReferencesDefaultArgumentUsed" + } + + diagnostic.argument.psiExpression?.let { + trace.report( + UNSUPPORTED_FEATURE.on( + it, LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType to context.languageVersionSettings + ) + ) + } + + } } } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt index 4d5c2feaf04..6c6055669aa 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolution.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.resolve.calls.components import org.jetbrains.kotlin.builtins.* +import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.resolve.calls.components.CreateFreshVariablesSubstitutor.createToFreshVariableSubstitutorAndAddInitialConstraints @@ -180,7 +181,9 @@ class CallableReferencesCandidateFactory( expectedType ) - if (defaults != 0) { + if (defaults != 0 && + !callComponents.languageVersionSettings.supportsFeature(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType) + ) { diagnostics.add(CallableReferencesDefaultArgumentUsed(argument, candidateDescriptor, defaults)) } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt index 4dd6f29c9c6..5224e3ba0da 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/CallableReferenceResolver.kt @@ -92,6 +92,7 @@ class CallableReferenceResolver( ) } diagnosticsHolder.addDiagnosticIfNotNull(diagnostic) + chosenCandidate.diagnostics.forEach { diagnosticsHolder.addDiagnostic(it) } chosenCandidate.freshSubstitutor = toFreshSubstitutor } else { if (candidates.isEmpty()) { diff --git a/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.args b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.args new file mode 100644 index 00000000000..f14133c65bc --- /dev/null +++ b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.args @@ -0,0 +1,4 @@ +$TESTDATA_DIR$/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.kt +-d +$TEMP_DIR$ +-Xnew-inference diff --git a/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.kt b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.kt new file mode 100644 index 00000000000..b4acfc32e15 --- /dev/null +++ b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.kt @@ -0,0 +1,11 @@ +fun foo(a: String, b: Int = 5): String { + return a + b +} + +fun bar1(body: (String) -> String): String { + return body("something") +} + +fun test() { + bar1(::foo) +} \ No newline at end of file diff --git a/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.out b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.out @@ -0,0 +1 @@ +OK diff --git a/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.args b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.args new file mode 100644 index 00000000000..4a72393beeb --- /dev/null +++ b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.args @@ -0,0 +1,4 @@ +$TESTDATA_DIR$/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.kt +-d +$TEMP_DIR$ +-XXLanguage\:+NewInference diff --git a/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.out b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.out new file mode 100644 index 00000000000..b44197449b5 --- /dev/null +++ b/compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.out @@ -0,0 +1,10 @@ +warning: ATTENTION! +This build uses unsafe internal compiler arguments: + +-XXLanguage:+NewInference + +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 diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/bothWithCoercionToUnit.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/bothWithCoercionToUnit.kt index 82c6d06c02f..fd5afad05b2 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/bothWithCoercionToUnit.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/bothWithCoercionToUnit.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS fun foo(s: String = "kotlin", vararg t: String): Boolean { diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/boundReferences.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/boundReferences.kt index b44a2b7bc7a..c30f407e606 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/boundReferences.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/boundReferences.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultAfterVararg.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultAfterVararg.kt index 792216093fb..697d88f45f6 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultAfterVararg.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultAfterVararg.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS fun foo(vararg a: String, result: String = "OK"): String = diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt index a6648bab608..ee45f6c8e61 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/defaultWithGenericExpectedType.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType fun foo(x: String, y: Char = 'K'): String = x + y diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/emptyVarargAndDefault.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/emptyVarargAndDefault.kt index 22b96b5499b..aada1aa80e0 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/emptyVarargAndDefault.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/emptyVarargAndDefault.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS fun foo(x: String = "O", vararg y: String): String = diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/inline.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/inline.kt index 43de3a090f0..984258659a1 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/inline.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/inline.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS, JVM_IR fun foo(vararg l: Long, s: String = "OK"): String = diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/innerConstructorWithVararg.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/innerConstructorWithVararg.kt index 60ebd69a2f6..6491101a879 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/innerConstructorWithVararg.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/innerConstructorWithVararg.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/localFunctionWithDefault.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/localFunctionWithDefault.kt index c86b24af117..6adb4a8a6fd 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/localFunctionWithDefault.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/localFunctionWithDefault.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS fun call0(f: (String) -> String, x: String): String = f(x) diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/manyDefaultsAndVararg.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/manyDefaultsAndVararg.kt index ae75fe0a30a..ad46bfefb12 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/manyDefaultsAndVararg.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/manyDefaultsAndVararg.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS // WITH_RUNTIME diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/simpleDefaultArgument.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/simpleDefaultArgument.kt index 57675d92589..4e763bea348 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/simpleDefaultArgument.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/simpleDefaultArgument.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType fun foo(x: String, y: String = "K"): String = x + y diff --git a/compiler/testData/codegen/box/callableReference/varargAndDefaults/varargWithDefaultValue.kt b/compiler/testData/codegen/box/callableReference/varargAndDefaults/varargWithDefaultValue.kt index 0d5087eddb6..3dbc337356b 100644 --- a/compiler/testData/codegen/box/callableReference/varargAndDefaults/varargWithDefaultValue.kt +++ b/compiler/testData/codegen/box/callableReference/varargAndDefaults/varargWithDefaultValue.kt @@ -1,4 +1,4 @@ -// !LANGUAGE: +NewInference +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType // IGNORE_BACKEND: JS fun foo(x: Int, s: Int, vararg y: CharSequence = arrayOf("Aaa")): String = diff --git a/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.kt b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.kt new file mode 100644 index 00000000000..22e22b9cdb2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.kt @@ -0,0 +1,18 @@ +// !WITH_NEW_INFERENCE + +fun foo(a: String, b: Int = 5): String { + return a + b +} + +fun bar1(body: (String) -> String): String { + return body("something") +} + +fun bar2(body: (String, Int) -> String): String { + return body("something", 0) +} + +fun test() { + bar1(::foo) + bar2(::foo) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.txt b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.txt new file mode 100644 index 00000000000..46f7a1edebc --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.txt @@ -0,0 +1,6 @@ +package + +public fun bar1(/*0*/ body: (kotlin.String) -> kotlin.String): kotlin.String +public fun bar2(/*0*/ body: (kotlin.String, kotlin.Int) -> kotlin.String): kotlin.String +public fun foo(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int = ...): kotlin.String +public fun test(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt new file mode 100644 index 00000000000..a4caa63e3d4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +NewInference +FunctionReferenceWithDefaultValueAsOtherType + +fun foo(a: String, b: Int = 5): String { + return a + b +} + +fun bar1(body: (String) -> String): String { + return body("something") +} + +fun bar2(body: (String, Int) -> String): String { + return body("something", 0) +} + +fun test() { + bar1(::foo) + bar2(::foo) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.txt b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.txt new file mode 100644 index 00000000000..46f7a1edebc --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.txt @@ -0,0 +1,6 @@ +package + +public fun bar1(/*0*/ body: (kotlin.String) -> kotlin.String): kotlin.String +public fun bar2(/*0*/ body: (kotlin.String, kotlin.Int) -> kotlin.String): kotlin.String +public fun foo(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int = ...): kotlin.String +public fun test(): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 23803e81e85..209d26bb10e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1714,6 +1714,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.kt"); } + @TestMetadata("functionReferenceWithDefaultValueAsOtherFunctionType.kt") + public void testFunctionReferenceWithDefaultValueAsOtherFunctionType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.kt"); + } + + @TestMetadata("functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt") + public void testFunctionReferenceWithDefaultValueAsOtherFunctionType_enabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt"); + } + @TestMetadata("kt15439_completeCall.kt") public void testKt15439_completeCall() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/kt15439_completeCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 1234fc3147a..d2e391a285a 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1709,6 +1709,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/callableReference/expectedTypeAsSubtypeOfFunctionType.kt"); } + @TestMetadata("functionReferenceWithDefaultValueAsOtherFunctionType.kt") + public void testFunctionReferenceWithDefaultValueAsOtherFunctionType() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType.kt"); + } + + @TestMetadata("functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt") + public void testFunctionReferenceWithDefaultValueAsOtherFunctionType_enabled() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/functionReferenceWithDefaultValueAsOtherFunctionType_enabled.kt"); + } + @TestMetadata("kt15439_completeCall.kt") public void testKt15439_completeCall() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/kt15439_completeCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java index 3e716bb0bc8..d0627e2f4c0 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -266,6 +266,16 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/flagAllowingResultAsReturnType.args"); } + @TestMetadata("functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.args") + public void testFunctionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference() throws Exception { + runTest("compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithNewInference.args"); + } + + @TestMetadata("functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.args") + public void testFunctionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference() throws Exception { + runTest("compiler/testData/cli/jvm/functionReferenceWithDefaultValuesFeatureIsEnabledWithXXNewInference.args"); + } + @TestMetadata("help.args") public void testHelp() throws Exception { runTest("compiler/testData/cli/jvm/help.args"); diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 47b2a554723..677fc7a06b6 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -123,15 +123,14 @@ enum class LanguageFeature( MultiPlatformProjects(sinceVersion = null, defaultState = State.DISABLED), NewInference(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), - // This feature can be enabled only along with new inference, see KT-26357 for details - BooleanElvisBoundSmartCasts(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), - + // In the next block, features can be enabled only along with new inference + BooleanElvisBoundSmartCasts(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), // see KT-26357 for details SamConversionForKotlinFunctions(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), - SamConversionPerArgument(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), - - // can be used only with NewInference feature NewDataFlowForTryExpressions(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), + FunctionReferenceWithDefaultValueAsOtherType(sinceVersion = KOTLIN_1_3, defaultState = State.DISABLED), + // ------ + // Next features can be enabled regardless of new inference InlineClasses(sinceVersion = KOTLIN_1_3, defaultState = State.ENABLED_WITH_WARNING, kind = UNSTABLE_FEATURE),