Added tests for parameter names in function type from SAM-adapter + fixed KT-13861
#KT-13861 Fixed
This commit is contained in:
@@ -458,7 +458,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
testClass<AbstractParameterInfoTest>() {
|
||||
model("parameterInfo", recursive = true, excludeDirs = listOf("withLib/sharedLib"))
|
||||
model("parameterInfo", recursive = true, excludeDirs = listOf("withLib1/sharedLib", "withLib2/sharedLib", "withLib3/sharedLib"))
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinGotoTest>() {
|
||||
|
||||
+6
-1
@@ -355,7 +355,12 @@ abstract class KotlinParameterInfoWithCallHandlerBase<TArgumentList : KtElement,
|
||||
}
|
||||
|
||||
val candidates = callToUse.resolveCandidates(bindingContext, resolutionFacade)
|
||||
val resolvedCall = candidates.firstOrNull { descriptorsEqual(it.resultingDescriptor, overload) } ?: return null
|
||||
// First try to find strictly matching descriptor, then one with the same declaration.
|
||||
// The second way is needed for the case when the descriptor was invalidated and new one has been built.
|
||||
// See testLocalFunctionBug().
|
||||
val resolvedCall = candidates.singleOrNull { it.resultingDescriptor.original == overload.original }
|
||||
?: candidates.singleOrNull { descriptorsEqual(it.resultingDescriptor, overload) }
|
||||
?: return null
|
||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||
|
||||
fun argumentToParameter(argument: ValueArgument): ValueParameterDescriptor? {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public class JavaClass {
|
||||
public static void takeSAM(JavaSAM sam){}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public interface JavaSAM {
|
||||
public void foo(int number, String ss);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
|
||||
fun main() {
|
||||
p.JavaClass.takeSAM(<caret>)
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>sam: ((number: Int, ss: String!) -> Unit)!</highlight>), Disabled: false, Strikeout: false, Green: false
|
||||
Text: (<highlight>sam: JavaSAM!</highlight>), Disabled: false, Strikeout: false, Green: false*/
|
||||
@@ -0,0 +1,5 @@
|
||||
package p;
|
||||
|
||||
public interface JavaSAM {
|
||||
public void foo(int number, String ss);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package test
|
||||
|
||||
|
||||
fun main() {
|
||||
p.JavaSAM(<caret>)
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>function: (number: Int, ss: String!) -> Unit</highlight>), Disabled: false, Strikeout: false, Green: true
|
||||
*/
|
||||
@@ -32,13 +32,12 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.psiUtil.allChildren
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestMetadata
|
||||
import org.junit.Assert
|
||||
|
||||
abstract class AbstractParameterInfoTest : LightCodeInsightFixtureTestCase() {
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
val root = KotlinTestUtils.getTestsRoot(this.javaClass)
|
||||
if (root.endsWith("Lib")) {
|
||||
if (root.contains("Lib")) {
|
||||
return JdkAndMockLibraryProjectDescriptor(
|
||||
"$root/sharedLib", true, true, false, false
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ import java.util.regex.Pattern;
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInParameterInfo() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo"), Pattern.compile("^(.+)\\.kt$"), true, "withLib/sharedLib");
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo"), Pattern.compile("^(.+)\\.kt$"), true, "withLib1/sharedLib", "withLib2/sharedLib", "withLib3/sharedLib");
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/arrayAccess")
|
||||
@@ -368,17 +368,47 @@ public class ParameterInfoTestGenerated extends AbstractParameterInfoTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/withLib")
|
||||
@TestMetadata("idea/testData/parameterInfo/withLib1")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class WithLib extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInWithLib() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/withLib"), Pattern.compile("^(.+)\\.kt$"), true, "sharedLib");
|
||||
public static class WithLib1 extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInWithLib1() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/withLib1"), Pattern.compile("^(.+)\\.kt$"), true, "sharedLib");
|
||||
}
|
||||
|
||||
@TestMetadata("useJavaFromLib.kt")
|
||||
public void testUseJavaFromLib() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/withLib/useJavaFromLib.kt");
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/withLib1/useJavaFromLib.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/withLib2")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class WithLib2 extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInWithLib2() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/withLib2"), Pattern.compile("^(.+)\\.kt$"), true, "sharedLib");
|
||||
}
|
||||
|
||||
@TestMetadata("useJavaSAMFromLib.kt")
|
||||
public void testUseJavaSAMFromLib() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/withLib2/useJavaSAMFromLib.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/parameterInfo/withLib3")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class WithLib3 extends AbstractParameterInfoTest {
|
||||
public void testAllFilesPresentInWithLib3() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/parameterInfo/withLib3"), Pattern.compile("^(.+)\\.kt$"), true, "sharedLib");
|
||||
}
|
||||
|
||||
@TestMetadata("useJavaSAMFromLib.kt")
|
||||
public void testUseJavaSAMFromLib() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/parameterInfo/withLib3/useJavaSAMFromLib.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user