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 b541f1d1692..6a622076440 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -12448,6 +12448,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/sam"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("contravariantSamConvertedFunctionFromAnotherModule.kt") + public void testContravariantSamConvertedFunctionFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/sam/contravariantSamConvertedFunctionFromAnotherModule.kt"); + } + @TestMetadata("enhancedSamConstructor.kt") public void testEnhancedSamConstructor() throws Exception { runTest("compiler/testData/diagnostics/tests/j+k/sam/enhancedSamConstructor.kt"); 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 6665b4c8d44..26098f933aa 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 @@ -119,8 +119,10 @@ fun ConstraintSystemOperation.checkCallableReference( addSubtypeConstraint(toFreshSubstitutor.safeSubstitute(reflectionCandidateType), expectedType, position) } - addReceiverConstraint(toFreshSubstitutor, dispatchReceiver, candidateDescriptor.dispatchReceiverParameter, position) - addReceiverConstraint(toFreshSubstitutor, extensionReceiver, candidateDescriptor.extensionReceiverParameter, position) + if (!ErrorUtils.isError(candidateDescriptor)) { + addReceiverConstraint(toFreshSubstitutor, dispatchReceiver, candidateDescriptor.dispatchReceiverParameter, position) + addReceiverConstraint(toFreshSubstitutor, extensionReceiver, candidateDescriptor.extensionReceiverParameter, position) + } val invisibleMember = Visibilities.findInvisibleMember( dispatchReceiver?.asReceiverValueForVisibilityChecks, diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt new file mode 100644 index 00000000000..179dee8495c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt @@ -0,0 +1,13 @@ +// !LANGUAGE: +NewInference + +interface Inv +class Impl : Inv + +class Scope(private val implClass: j.Class) { + fun foo(c: Collection) { + val hm = c.asSequence() + .filter(implClass::isInstance) + .map(implClass::cast) + .toSet() + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.txt new file mode 100644 index 00000000000..463ac36505d --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.txt @@ -0,0 +1,23 @@ +package + +public final class Impl : Inv { + public constructor Impl() + 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 +} + +public interface Inv { + 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 +} + +public final class Scope { + public constructor Scope(/*0*/ implClass: [ERROR : j.Class]) + private final val implClass: [ERROR : j.Class] + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ c: kotlin.collections.Collection): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 399bd766a19..f5414773990 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -12455,6 +12455,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/sam"), Pattern.compile("^(.*)\\.kts?$"), TargetBackend.ANY, true); } + @TestMetadata("contravariantSamConvertedFunctionFromAnotherModule.kt") + public void testContravariantSamConvertedFunctionFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/sam/contravariantSamConvertedFunctionFromAnotherModule.kt"); + } + @TestMetadata("enhancedSamConstructor.kt") public void testEnhancedSamConstructor() throws Exception { runTest("compiler/testData/diagnostics/tests/j+k/sam/enhancedSamConstructor.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index a507200184d..ffe093c7e95 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1784,6 +1784,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/bigArity.kt"); } + @TestMetadata("callableReferenceOnUnresolvedLHS.kt") + public void testCallableReferenceOnUnresolvedLHS() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt"); + } + @TestMetadata("property.kt") public void testProperty_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 3c95282163b..9e3a972cd7c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1784,6 +1784,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/bigArity.kt"); } + @TestMetadata("callableReferenceOnUnresolvedLHS.kt") + public void testCallableReferenceOnUnresolvedLHS() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/callableReferenceOnUnresolvedLHS.kt"); + } + @TestMetadata("property.kt") public void testProperty_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/diagnostics/testsWithStdLib/coroutines/callableReference/property.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index dd556a98a8d..a291c144a0c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -12450,6 +12450,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/sam"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } + @TestMetadata("contravariantSamConvertedFunctionFromAnotherModule.kt") + public void testContravariantSamConvertedFunctionFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/sam/contravariantSamConvertedFunctionFromAnotherModule.kt"); + } + @TestMetadata("enhancedSamConstructor.kt") public void testEnhancedSamConstructor() throws Exception { runTest("compiler/testData/diagnostics/tests/j+k/sam/enhancedSamConstructor.kt");