diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.kt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.kt new file mode 100644 index 00000000000..60f68f3ce1b --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.kt @@ -0,0 +1,10 @@ +// FULL_JDK + +fun foo(x: Comparator) {} + + +fun main() { + foo { x, y -> + x.length - y.length + } +} diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.txt new file mode 100644 index 00000000000..716965de6a4 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.txt @@ -0,0 +1,9 @@ +FILE: samForComparator.kt + public final fun foo(x: R|kotlin/Comparator|): R|kotlin/Unit| { + } + public final fun main(): R|kotlin/Unit| { + R|/foo|( = foo@fun (x: R|ft!|, y: R|ft!|): R|kotlin/Int| { + ^ R|/x|.R|kotlin/CharSequence.length|.R|kotlin/Int.minus|(R|/y|.R|kotlin/CharSequence.length|) + } + ) + } diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index 1f786f88b9a..a867f43990c 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -243,6 +243,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/runOnIntegerLiteral.kt"); } + @TestMetadata("samForComparator.kt") + public void testSamForComparator() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/samForComparator.kt"); + } + @TestMetadata("simpleLazy.kt") public void testSimpleLazy() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/simpleLazy.kt"); diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt index d616f0cb1b6..71cf35fa1d5 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/SamResolution.kt @@ -53,7 +53,7 @@ class FirSamResolverImpl( override fun getFunctionTypeForPossibleSamType(type: ConeKotlinType): ConeKotlinType? { return when (type) { - is ConeClassLikeType -> getFunctionTypeForPossibleSamType(type) + is ConeClassLikeType -> getFunctionTypeForPossibleSamType(type.fullyExpandedType(firSession)) is ConeFlexibleType -> ConeFlexibleType( getFunctionTypeForPossibleSamType(type.lowerBound) ?: return null, getFunctionTypeForPossibleSamType(type.upperBound) ?: return null,