diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java index 98439d4b7b3..ec4b76002e8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/results/ResolutionResultsHandler.java @@ -19,6 +19,8 @@ package org.jetbrains.kotlin.resolve.calls.results; import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; +import org.jetbrains.kotlin.config.LanguageFeature; +import org.jetbrains.kotlin.config.LanguageVersionSettings; import org.jetbrains.kotlin.descriptors.CallableDescriptor; import org.jetbrains.kotlin.resolve.BindingTrace; import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; @@ -26,11 +28,9 @@ import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext; import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode; import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall; import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy; +import org.jetbrains.kotlin.resolve.calls.tower.TowerUtilsKt; -import java.util.Collection; -import java.util.EnumSet; -import java.util.LinkedHashSet; -import java.util.Set; +import java.util.*; import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*; @@ -49,7 +49,8 @@ public class ResolutionResultsHandler { public OverloadResolutionResultsImpl computeResultAndReportErrors( @NotNull CallResolutionContext context, @NotNull TracingStrategy tracing, - @NotNull Collection> candidates + @NotNull Collection> candidates, + @NotNull LanguageVersionSettings languageVersionSettings ) { Set> successfulCandidates = Sets.newLinkedHashSet(); Set> failedCandidates = Sets.newLinkedHashSet(); @@ -74,10 +75,11 @@ public class ResolutionResultsHandler { // TODO : maybe it's better to filter overrides out first, and only then look for the maximally specific if (!successfulCandidates.isEmpty() || !incompleteCandidates.isEmpty()) { - return computeSuccessfulResult(context, tracing, successfulCandidates, incompleteCandidates, context.checkArguments); + return computeSuccessfulResult( + context, tracing, successfulCandidates, incompleteCandidates, context.checkArguments, languageVersionSettings); } else if (!failedCandidates.isEmpty()) { - return computeFailedResult(tracing, context.trace, failedCandidates, context.checkArguments); + return computeFailedResult(tracing, context.trace, failedCandidates, context.checkArguments, languageVersionSettings); } if (!candidatesWithWrongReceiver.isEmpty()) { tracing.unresolvedReferenceWrongReceiver(context.trace, candidatesWithWrongReceiver); @@ -93,13 +95,14 @@ public class ResolutionResultsHandler { @NotNull TracingStrategy tracing, @NotNull Set> successfulCandidates, @NotNull Set> incompleteCandidates, - @NotNull CheckArgumentTypesMode checkArgumentsMode + @NotNull CheckArgumentTypesMode checkArgumentsMode, + @NotNull LanguageVersionSettings languageVersionSettings ) { Set> successfulAndIncomplete = Sets.newLinkedHashSet(); successfulAndIncomplete.addAll(successfulCandidates); successfulAndIncomplete.addAll(incompleteCandidates); OverloadResolutionResultsImpl results = chooseAndReportMaximallySpecific( - successfulAndIncomplete, true, context.isDebuggerContext, checkArgumentsMode); + successfulAndIncomplete, true, context.isDebuggerContext, checkArgumentsMode, languageVersionSettings); if (results.isSingleResult()) { MutableResolvedCall resultingCall = results.getResultingCall(); resultingCall.getTrace().moveAllMyDataTo(context.trace); @@ -133,7 +136,8 @@ public class ResolutionResultsHandler { @NotNull TracingStrategy tracing, @NotNull BindingTrace trace, @NotNull Set> failedCandidates, - @NotNull CheckArgumentTypesMode checkArgumentsMode + @NotNull CheckArgumentTypesMode checkArgumentsMode, + @NotNull LanguageVersionSettings languageVersionSettings ) { if (failedCandidates.size() == 1) { return recordFailedInfo(tracing, trace, failedCandidates); @@ -152,7 +156,8 @@ public class ResolutionResultsHandler { OverloadingConflictResolver> myResolver = (OverloadingConflictResolver) overloadingConflictResolver; return recordFailedInfo(tracing, trace, myResolver.filterOutEquivalentCalls(new LinkedHashSet>(thisLevel))); } - OverloadResolutionResultsImpl results = chooseAndReportMaximallySpecific(thisLevel, false, false, checkArgumentsMode); + OverloadResolutionResultsImpl results = chooseAndReportMaximallySpecific( + thisLevel, false, false, checkArgumentsMode, languageVersionSettings); return recordFailedInfo(tracing, trace, results.getResultingCalls()); } } @@ -188,12 +193,27 @@ public class ResolutionResultsHandler { @NotNull Set> candidates, boolean discriminateGenerics, boolean isDebuggerContext, - @NotNull CheckArgumentTypesMode checkArgumentsMode + @NotNull CheckArgumentTypesMode checkArgumentsMode, + @NotNull LanguageVersionSettings languageVersionSettings ) { OverloadingConflictResolver> myResolver = (OverloadingConflictResolver) overloadingConflictResolver; + Set> refinedCandidates = candidates; + if (!languageVersionSettings.supportsFeature(LanguageFeature.RefinedSamAdaptersPriority)) { + Set> nonSynthesized = new HashSet>(); + for (MutableResolvedCall candidate : candidates) { + if (!TowerUtilsKt.isSynthesized(candidate.getCandidateDescriptor())) { + nonSynthesized.add(candidate); + } + } + + if (!nonSynthesized.isEmpty()) { + refinedCandidates = nonSynthesized; + } + } + Set> specificCalls = - myResolver.chooseMaximallySpecificCandidates(candidates, checkArgumentsMode, discriminateGenerics, isDebuggerContext); + myResolver.chooseMaximallySpecificCandidates(refinedCandidates, checkArgumentsMode, discriminateGenerics, isDebuggerContext); if (specificCalls.size() == 1) { return OverloadResolutionResultsImpl.success(specificCalls.iterator().next()); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt index 93a5e5e711d..9f875fe713f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt @@ -191,7 +191,7 @@ class NewResolutionOldInference( } } - val overloadResults = convertToOverloadResults(candidates, tracing, context) + val overloadResults = convertToOverloadResults(candidates, tracing, context, languageVersionSettings) coroutineInferenceSupport.checkCoroutineCalls(context, tracing, overloadResults) return overloadResults } @@ -227,7 +227,7 @@ class NewResolutionOldInference( val processedCandidates = towerResolver.runWithEmptyTowerData(KnownResultProcessor(resolvedCandidates), TowerResolver.SuccessfulResultCollector { it.candidateStatus }, useOrder = true) - return convertToOverloadResults(processedCandidates, tracing, basicCallContext) + return convertToOverloadResults(processedCandidates, tracing, basicCallContext, languageVersionSettings) } private fun allCandidatesResult(allCandidates: Collection>) @@ -238,7 +238,8 @@ class NewResolutionOldInference( private fun convertToOverloadResults( candidates: Collection>, tracing: TracingStrategy, - basicCallContext: BasicCallResolutionContext + basicCallContext: BasicCallResolutionContext, + languageVersionSettings: LanguageVersionSettings ): OverloadResolutionResultsImpl { val resolvedCalls = candidates.mapNotNull { val (status, resolvedCall) = it @@ -274,7 +275,7 @@ class NewResolutionOldInference( resolvedCall } - return resolutionResultsHandler.computeResultAndReportErrors(basicCallContext, tracing, resolvedCalls) + return resolutionResultsHandler.computeResultAndReportErrors(basicCallContext, tracing, resolvedCalls, languageVersionSettings) } // true if we found something diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.kt new file mode 100644 index 00000000000..252f80e68b7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.kt @@ -0,0 +1,37 @@ +// !LANGUAGE: -RefinedSamAdaptersPriority +// !CHECK_TYPE +// FILE: A.java +public class A { + public static int foo(Runnable r) { return 0; } + public static String foo(Object r) { return null;} + + public static int bar(Runnable r) { return 1; } + public static String bar(CharSequence r) { return null; } +} + +// FILE: 1.kt +fun fn() {} +fun x(r: Runnable) { + A.foo(::fn) checkType { _() } + A.foo {} checkType { _() } + + A.foo(null) checkType { _() } + A.foo(Runnable { }) checkType { _() } + A.foo(r) checkType { _() } + + A.foo(123) checkType { _() } + A.foo("") checkType { _() } + + A.bar(::fn) checkType { _() } + A.bar {} checkType { _() } + + A.bar(r) checkType { _() } + + A.bar(null) + + A.bar(null as Runnable?) checkType { _() } + A.bar(null as CharSequence?) checkType { _() } + + A.bar("") checkType { _() } + A.bar(123) +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.txt new file mode 100644 index 00000000000..91eb6e2de87 --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.txt @@ -0,0 +1,19 @@ +package + +public fun fn(): kotlin.Unit +public fun x(/*0*/ r: java.lang.Runnable): kotlin.Unit + +public open class A { + public constructor A() + 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 + + // Static members + public final /*synthesized*/ fun bar(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int + public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int + public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String! + public final /*synthesized*/ fun foo(/*0*/ r: (() -> kotlin.Unit)!): kotlin.Int + public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int + public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String! +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.kt b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.kt new file mode 100644 index 00000000000..ab1e12fb88d --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.kt @@ -0,0 +1,37 @@ +// !LANGUAGE: -RefinedSamAdaptersPriority +// !CHECK_TYPE +// FILE: A.java +public class A { + public int foo(Runnable r) { return 0; } + public String foo(Object r) { return null;} + + public int bar(Runnable r) { return 1; } + public String bar(CharSequence r) { return null; } +} + +// FILE: 1.kt +fun fn() {} +fun x(a: A, r: Runnable) { + a.foo(::fn) checkType { _() } + a.foo {} checkType { _() } + + a.foo(null) checkType { _() } + a.foo(Runnable { }) checkType { _() } + a.foo(r) checkType { _() } + + a.foo(123) checkType { _() } + a.foo("") checkType { _() } + + a.bar(::fn) checkType { _() } + a.bar {} checkType { _() } + + a.bar(r) checkType { _() } + + a.bar(null) + + a.bar(null as Runnable?) checkType { _() } + a.bar(null as CharSequence?) checkType { _() } + + a.bar("") checkType { _() } + a.bar(123) +} diff --git a/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.txt b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.txt new file mode 100644 index 00000000000..c6b3ca874bd --- /dev/null +++ b/compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.txt @@ -0,0 +1,15 @@ +package + +public fun fn(): kotlin.Unit +public fun x(/*0*/ a: A, /*1*/ r: java.lang.Runnable): kotlin.Unit + +public open class A { + public constructor A() + public open fun bar(/*0*/ r: java.lang.Runnable!): kotlin.Int + public open fun bar(/*0*/ r: kotlin.CharSequence!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ r: java.lang.Runnable!): kotlin.Int + public open fun foo(/*0*/ r: kotlin.Any!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt new file mode 100644 index 00000000000..d86d1794c73 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt @@ -0,0 +1,24 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +// FILE: Foo.java +import kotlin.Unit; +import kotlin.jvm.functions.Function1; + +class Foo { + interface FObject { + void invoke(T i); + } + + public String foo(FObject f) { return ""; } + public int foo(Function1 f) { return 1; } + + public String bar(FObject f) { return ""; } + public int bar(Function1 f) { return 1; } +} + +// FILE: 1.kt +fun test() { + Foo().foo {} checkType { _() } + Foo().bar {} checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.txt new file mode 100644 index 00000000000..b0dfa3e686a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.txt @@ -0,0 +1,24 @@ +package + +public fun test(): kotlin.Unit + +public/*package*/ open class Foo { + public/*package*/ constructor Foo() + public open fun bar(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int + public open fun bar(/*0*/ f: Foo.FObject!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int + public open fun foo(/*0*/ f: Foo.FObject!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ interface FObject { + 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 operator fun invoke(/*0*/ i: T!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public/*package*/ final /*synthesized*/ fun FObject(/*0*/ function: (i: T!) -> kotlin.Unit): Foo.FObject +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt new file mode 100644 index 00000000000..cd4629374b3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: -RefinedSamAdaptersPriority +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +// FILE: Foo.java +import kotlin.Unit; +import kotlin.jvm.functions.Function1; + +class Foo { + interface FObject { + void invoke(T i); + } + + public String foo(FObject f) { return ""; } + public int foo(Function1 f) { return 1; } + + public String bar(FObject f) { return ""; } + public int bar(Function1 f) { return 1; } +} + +// FILE: 1.kt +fun test() { + Foo().foo {} checkType { _() } + Foo().bar {} checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.txt new file mode 100644 index 00000000000..b0dfa3e686a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.txt @@ -0,0 +1,24 @@ +package + +public fun test(): kotlin.Unit + +public/*package*/ open class Foo { + public/*package*/ constructor Foo() + public open fun bar(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int + public open fun bar(/*0*/ f: Foo.FObject!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun foo(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int + public open fun foo(/*0*/ f: Foo.FObject!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ interface FObject { + 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 operator fun invoke(/*0*/ i: T!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public/*package*/ final /*synthesized*/ fun FObject(/*0*/ function: (i: T!) -> kotlin.Unit): Foo.FObject +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.kt new file mode 100644 index 00000000000..59d45e72309 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.kt @@ -0,0 +1,20 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +// FILE: Foo.java +import kotlin.Unit; +import kotlin.jvm.functions.Function1; + +public class Foo { + interface FObject { + void invoke(Object i); + } + + public String test(FObject f) { return ""; } + public int test(Function1 f) { return 1; } +} + +// FILE: 1.kt +fun bar() { + Foo().test {} checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.txt new file mode 100644 index 00000000000..19495886a30 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.txt @@ -0,0 +1,22 @@ +package + +public fun bar(): kotlin.Unit + +public open class Foo { + public constructor Foo() + 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 fun test(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int + public open fun test(/*0*/ f: Foo.FObject!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ interface FObject { + 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 operator fun invoke(/*0*/ i: kotlin.Any!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public/*package*/ final /*synthesized*/ fun FObject(/*0*/ function: (i: kotlin.Any!) -> kotlin.Unit): Foo.FObject +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt new file mode 100644 index 00000000000..e6f9fb6d2e9 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt @@ -0,0 +1,21 @@ +// !LANGUAGE: -RefinedSamAdaptersPriority +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !CHECK_TYPE + +// FILE: Foo.java +import kotlin.Unit; +import kotlin.jvm.functions.Function1; + +public class Foo { + interface FObject { + void invoke(Object i); + } + + public String test(FObject f) { return ""; } + public int test(Function1 f) { return 1; } +} + +// FILE: 1.kt +fun bar() { + Foo().test {} checkType { _() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.txt new file mode 100644 index 00000000000..19495886a30 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.txt @@ -0,0 +1,22 @@ +package + +public fun bar(): kotlin.Unit + +public open class Foo { + public constructor Foo() + 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 fun test(/*0*/ f: ((kotlin.Int!) -> kotlin.Unit!)!): kotlin.Int + public open fun test(/*0*/ f: Foo.FObject!): kotlin.String! + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public/*package*/ interface FObject { + 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 operator fun invoke(/*0*/ i: kotlin.Any!): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public/*package*/ final /*synthesized*/ fun FObject(/*0*/ function: (i: kotlin.Any!) -> kotlin.Unit): Foo.FObject +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 2ad007daa81..8c99cfc5fb1 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -21414,6 +21414,18 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("overloadResolutionStaticWithoutRefinedSams.kt") + public void testOverloadResolutionStaticWithoutRefinedSams() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionStaticWithoutRefinedSams.kt"); + doTest(fileName); + } + + @TestMetadata("overloadResolutionWithoutRefinedSams.kt") + public void testOverloadResolutionWithoutRefinedSams() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/overloadResolutionWithoutRefinedSams.kt"); + doTest(fileName); + } + @TestMetadata("PackageLocal.kt") public void testPackageLocal() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/syntheticExtensions/samAdapters/PackageLocal.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index f39af6c35f1..7ff70ff41b5 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1195,6 +1195,30 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samConstructorVsFun.kt"); doTest(fileName); } + + @TestMetadata("samOverloadsWithGenerics.kt") + public void testSamOverloadsWithGenerics() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenerics.kt"); + doTest(fileName); + } + + @TestMetadata("samOverloadsWithGenericsWithoutRefinedSams.kt") + public void testSamOverloadsWithGenericsWithoutRefinedSams() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithGenericsWithoutRefinedSams.kt"); + doTest(fileName); + } + + @TestMetadata("samOverloadsWithKtFunction.kt") + public void testSamOverloadsWithKtFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunction.kt"); + doTest(fileName); + } + + @TestMetadata("samOverloadsWithKtFunctionWithoutRefinedSams.kt") + public void testSamOverloadsWithKtFunctionWithoutRefinedSams() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/resolve/samOverloadsWithKtFunctionWithoutRefinedSams.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/testsWithStdLib/smartcasts") diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index d5d4b21e3f0..1e95aef1a57 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -38,6 +38,7 @@ enum class LanguageFeature(val sinceVersion: LanguageVersion?) { OperatorRem(KOTLIN_1_1), OperatorProvideDelegate(KOTLIN_1_1), ShortSyntaxForPropertyGetters(KOTLIN_1_1), + RefinedSamAdaptersPriority(KOTLIN_1_1), // Experimental features MultiPlatformProjects(null),