[FIR] Fix building callable reference adaptation against flexible types
#KT-45052 Fixed
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
|||||||
|
FILE: referenceToJavaStdlib.kt
|
||||||
|
public final fun detectDirsWithTestsMapFileOnly(file: R|java/io/File|): R|kotlin/collections/List<kotlin/String>| {
|
||||||
|
Q|java/nio/file/Files|.R|java/nio/file/Files.walk|(R|<local>/file|.R|java/io/File.toPath|()).R|SubstitutionOverride<java/util/stream/Stream.filter: R|ft<@FlexibleNullability java/util/stream/Stream<ft<@FlexibleNullability java/nio/file/Path, @FlexibleNullability java/nio/file/Path?>!>, java/util/stream/Stream<ft<@FlexibleNullability java/nio/file/Path, @FlexibleNullability java/nio/file/Path?>!>?>!|>|(Q|java/nio/file/Files|::R|java/nio/file/Files.isRegularFile|)
|
||||||
|
}
|
||||||
|
public abstract interface A : R|kotlin/Any| {
|
||||||
|
}
|
||||||
|
public final fun foo(x: R|A|, vararg strings: R|kotlin/Array<out kotlin/String>|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
public final fun takeFunWithA(func: R|(A) -> kotlin/Unit|): R|kotlin/Unit| {
|
||||||
|
}
|
||||||
|
public final fun test(): R|kotlin/Unit| {
|
||||||
|
R|/takeFunWithA|(::R|/foo|)
|
||||||
|
}
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
// ISSUE: KT-45052
|
||||||
|
// FULL_JDK
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
|
||||||
|
fun detectDirsWithTestsMapFileOnly(file: File): List<String> {
|
||||||
|
Files.walk(file.toPath()).filter(Files::isRegularFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
interface A
|
||||||
|
fun foo(x: A, vararg strings: String) {}
|
||||||
|
fun takeFunWithA(func: (A) -> Unit) {}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
takeFunWithA(::foo)
|
||||||
|
}
|
||||||
+6
@@ -4177,6 +4177,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/properties.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/properties.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("referenceToJavaStdlib.kt")
|
||||||
|
public void testReferenceToJavaStdlib() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sam.kt")
|
@TestMetadata("sam.kt")
|
||||||
public void testSam() throws Exception {
|
public void testSam() throws Exception {
|
||||||
|
|||||||
+6
@@ -4231,6 +4231,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/properties.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/properties.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("referenceToJavaStdlib.kt")
|
||||||
|
public void testReferenceToJavaStdlib() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/callableReferences/referenceToJavaStdlib.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("sam.kt")
|
@TestMetadata("sam.kt")
|
||||||
public void testSam() throws Exception {
|
public void testSam() throws Exception {
|
||||||
|
|||||||
+6
-2
@@ -97,8 +97,12 @@ private fun buildReflectionType(
|
|||||||
is FirFunction -> {
|
is FirFunction -> {
|
||||||
val unboundReferenceTarget = if (receiverType != null) 1 else 0
|
val unboundReferenceTarget = if (receiverType != null) 1 else 0
|
||||||
val callableReferenceAdaptation =
|
val callableReferenceAdaptation =
|
||||||
context.bodyResolveComponents
|
context.bodyResolveComponents.getCallableReferenceAdaptation(
|
||||||
.getCallableReferenceAdaptation(context.session, fir, candidate.callInfo.expectedType, unboundReferenceTarget)
|
context.session,
|
||||||
|
fir,
|
||||||
|
candidate.callInfo.expectedType?.lowerBoundIfFlexible(),
|
||||||
|
unboundReferenceTarget
|
||||||
|
)
|
||||||
|
|
||||||
val parameters = mutableListOf<ConeKotlinType>()
|
val parameters = mutableListOf<ConeKotlinType>()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user