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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user