Record special name lookup when trying use interface as a SAM

It was already working in JPS, because it see our synthetic classes
as subclasses for SAM's, but with non-JPS build we have to manually
tracking places that should be recompiled after SAM members are changed
This commit is contained in:
Denis Zharkov
2017-11-07 12:34:48 +03:00
parent ae6421476d
commit df533053f9
24 changed files with 193 additions and 8 deletions
@@ -0,0 +1,6 @@
package bar;
public class C {
public void foo(SAMInterface x) {}
public static void bar(SAMInterface x) {}
}
@@ -0,0 +1,5 @@
package bar;
public interface SAMInterface {
void apply(String x);
}
@@ -0,0 +1,12 @@
==== INITIAL BUILD ====
Compiling files:
src/usages.kt
Exit code: COMPILATION_ERROR
None of the following functions can be called with the arguments supplied:
public final fun foo(x: ((x: String!) -> Unit)!): Unit defined in bar.C
public open fun foo(x: SAMInterface!): Unit defined in bar.C
None of the following functions can be called with the arguments supplied:
public final fun bar(x: ((x: String!) -> Unit)!): Unit defined in bar.C
public open fun bar(x: SAMInterface!): Unit defined in bar.C
No value passed for parameter 'function'
@@ -0,0 +1,14 @@
package foo
/*p:bar(C)*/import bar.C
/*p:bar(SAMInterface)*/import bar.SAMInterface
/*p:foo*/fun foo(c: /*p:bar*/C) /*p:bar(SAMInterface)*/{
/*p:bar(C)*/c./*c:bar.C c:bar.SAMInterface(<SAM-CONSTRUCTOR>) c:bar.C(getFoo) c:bar.C(getFOO) p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/foo()
/*p:bar(C)*/c./*c:bar.C c:bar.SAMInterface(<SAM-CONSTRUCTOR>)*/foo /*p:kotlin(Function1) p:kotlin(String)*/{ }
/*p:bar p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/C./*c:bar.C c:bar.SAMInterface(<SAM-CONSTRUCTOR>)*/bar()
/*p:bar p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/C./*c:bar.C c:bar.SAMInterface(<SAM-CONSTRUCTOR>)*/bar /*p:kotlin(Function1) p:kotlin(String)*/{}
/*p:bar c:bar.SAMInterface(<SAM-CONSTRUCTOR>) p:foo p:kotlin p:kotlin.annotation p:kotlin.collections p:kotlin.ranges p:kotlin.sequences p:kotlin.text p:kotlin.io p:kotlin.comparisons p:java.lang p:kotlin.jvm*/SAMInterface()
/*p:bar c:bar.SAMInterface(<SAM-CONSTRUCTOR>)*/SAMInterface /*p:kotlin(Function1) p:kotlin(String)*/{}
}
@@ -0,0 +1,4 @@
public class JavaClass {
public void foo(SamInterface s) {}
public static void bar(SamInterface s) {}
}
@@ -0,0 +1,3 @@
public interface SamInterface {
Object run();
}
@@ -0,0 +1,4 @@
public interface SamInterface {
Object run();
Object walk();
}
@@ -0,0 +1,26 @@
================ Step #1 =================
Cleaning output files:
out/production/module/SamInterface.class
End of files
Exit code: NOTHING_DONE
------------------------------------------
Compiling files:
src/SamInterface.java
End of files
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/UsageWithMemberKt$usageWithMember$1.class
out/production/module/UsageWithMemberKt.class
out/production/module/UsageWithStaticKt$usageWithStatic$1.class
out/production/module/UsageWithStaticKt.class
End of files
Compiling files:
src/usageWithMember.kt
src/usageWithStatic.kt
End of files
Exit code: ABORT
------------------------------------------
COMPILATION FAILED
Type mismatch: inferred type is () -> String but SamInterface! was expected
Type mismatch: inferred type is () -> String but SamInterface! was expected
@@ -0,0 +1,3 @@
fun notUsage() {
JavaClass().hashCode()
}
@@ -0,0 +1,3 @@
fun usageWithMember() {
JavaClass().foo { "" }
}
@@ -0,0 +1,3 @@
fun usageWithStatic() {
JavaClass.bar { "" }
}
@@ -0,0 +1,4 @@
public class JavaClass {
public void foo(SamInterface s) {}
public static void bar(SamInterface s) {}
}
@@ -0,0 +1,3 @@
public interface SamInterface {
Object run();
}
@@ -0,0 +1,3 @@
public interface SamInterface {
String run();
}
@@ -0,0 +1,23 @@
================ Step #1 =================
Cleaning output files:
out/production/module/SamInterface.class
End of files
Exit code: NOTHING_DONE
------------------------------------------
Compiling files:
src/SamInterface.java
End of files
Cleaning output files:
out/production/module/META-INF/module.kotlin_module
out/production/module/UsageWithMemberKt$usageWithMember$1.class
out/production/module/UsageWithMemberKt.class
out/production/module/UsageWithStaticKt$usageWithStatic$1.class
out/production/module/UsageWithStaticKt.class
End of files
Compiling files:
src/usageWithMember.kt
src/usageWithStatic.kt
End of files
Exit code: OK
------------------------------------------
@@ -0,0 +1,3 @@
fun notUsage() {
JavaClass().hashCode()
}
@@ -0,0 +1,3 @@
fun usageWithMember() {
JavaClass().foo { "" }
}
@@ -0,0 +1,3 @@
fun usageWithStatic() {
JavaClass.bar { "" }
}