Add more tests for RedundantSamConstructorInspection
- All those tests already pass, they are needed to fix the behaviour of the inspection before the changes
This commit is contained in:
committed by
Roman Golyshev
parent
e8524137c3
commit
3122760c49
+8
@@ -0,0 +1,8 @@
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:+NewInference -XXLanguage:+SamConversionForKotlinFunctions -XXLanguage:+FunctionalInterfaceConversion -XXLanguage:-SamConversionPerArgument
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(r1: Runnable, r2: Runnable) {}
|
||||
|
||||
fun usage(r1: Runnable) {
|
||||
test(r1, Runnable<caret> {})
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:+NewInference -XXLanguage:+SamConversionForKotlinFunctions -XXLanguage:+FunctionalInterfaceConversion -XXLanguage:-SamConversionPerArgument
|
||||
// PROBLEM: none
|
||||
|
||||
fun interface KtRunnable {
|
||||
fun run()
|
||||
}
|
||||
|
||||
fun test(r1: KtRunnable, r2: KtRunnable) {}
|
||||
|
||||
fun usage(r1: KtRunnable) {
|
||||
test(r1, KtRunnable<caret> {})
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// COMPILER_ARGUMENTS: -XXLanguage:+NewInference -XXLanguage:+SamConversionForKotlinFunctions -XXLanguage:+FunctionalInterfaceConversion -XXLanguage:-SamConversionPerArgument
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(r1: Runnable, r2: Runnable) {}
|
||||
|
||||
fun usage() {
|
||||
test(Runnable { return@Runnable }, Runnable<caret> {})
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(r: Runnable) {}
|
||||
|
||||
fun usage() {
|
||||
test(Runnable<caret> { return@Runnable })
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(r: Runnable) {}
|
||||
|
||||
fun usage() {
|
||||
test(Runnable<caret> a@{ return@a })
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public interface JavaTest {
|
||||
interface FunInterface1 {
|
||||
void test();
|
||||
}
|
||||
|
||||
interface FunInterface2 {
|
||||
int test();
|
||||
}
|
||||
|
||||
void foo(FunInterface1 f1);
|
||||
void foo(FunInterface2 f2);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun usage(javaTest: JavaTest) {
|
||||
javaTest.foo(JavaTest.FunInterface1<caret> { 10 }) // foo call will be ambiguous without SAM constructor
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public interface JavaTest {
|
||||
interface FunInterface1 {
|
||||
void test();
|
||||
}
|
||||
|
||||
void foo(FunInterface1 f1);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun JavaTest.usage() {
|
||||
fun foo(a: () -> Unit) {}
|
||||
|
||||
foo(JavaTest.FunInterface1<caret> { 10 }) // local foo will be used without SAM constructor
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public interface Interfaces {
|
||||
interface FunInterface1 {
|
||||
void test();
|
||||
}
|
||||
|
||||
interface FunInterface2 {
|
||||
void test();
|
||||
}
|
||||
|
||||
interface InterfaceWithMethod1 {
|
||||
void foo(FunInterface1 f1);
|
||||
}
|
||||
|
||||
interface InterfaceWithMethod2 {
|
||||
void foo(FunInterface2 f1);
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// PROBLEM: none
|
||||
|
||||
fun <T, R> with(t: T, action: T.() -> R) = t.action()
|
||||
|
||||
private fun usage(int1: Interfaces.InterfaceWithMethod1, int2: Interfaces.InterfaceWithMethod2) {
|
||||
with(int1) {
|
||||
with(int2) {
|
||||
foo(Interfaces.FunInterface1<caret> { }) // removing SAM constructor will change resolution to InterfaceWithMethod2::foo
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -7866,11 +7866,51 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/inspectionsLocal/redundantSamConstructor"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("conversionPerArgumentDisabled1.kt")
|
||||
public void testConversionPerArgumentDisabled1() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/conversionPerArgumentDisabled1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conversionPerArgumentDisabled2.kt")
|
||||
public void testConversionPerArgumentDisabled2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/conversionPerArgumentDisabled2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conversionPerArgumentDisabled3.kt")
|
||||
public void testConversionPerArgumentDisabled3() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/conversionPerArgumentDisabled3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("labeledReturn1.kt")
|
||||
public void testLabeledReturn1() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/labeledReturn1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("labeledReturn2.kt")
|
||||
public void testLabeledReturn2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/labeledReturn2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedInterface.kt")
|
||||
public void testNestedInterface() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolutionAmbiguity1.kt")
|
||||
public void testResolutionAmbiguity1() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/resolutionAmbiguity1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolutionAmbiguity2.kt")
|
||||
public void testResolutionAmbiguity2() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/resolutionAmbiguity2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolutionAmbiguity3.kt")
|
||||
public void testResolutionAmbiguity3() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/resolutionAmbiguity3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/redundantSamConstructor/simple.kt");
|
||||
|
||||
Reference in New Issue
Block a user