Details
-
Bug
-
Status: In Progress
-
Minor
-
Resolution: Unresolved
-
3.0.8, 4.0.0-alpha-3
-
None
-
None
Description
I have the following Groovy program.
public class Main { public static void main(String[] args) { new Foo<B>().foo(new B()).m() } } class A{} class B extends A{ void m() {} } @groovy.transform.TypeChecked class Foo<T extends A> { T foo(T x) { x = new A(); // does not catch the error; } }
Actual Behavior
Runtime error.
Caught: groovy.lang.MissingMethodException: No signature of method: A.m() is applicable for argument types: () values: [] Possible solutions: is(java.lang.Object), NV([Ljava.lang.Object;), any(), dump(), any(groovy.lang.Closure), tap(groovy.lang.Closure) groovy.lang.MissingMethodException: No signature of method: A.m() is applicable for argument types: () values: [] Possible solutions: is(java.lang.Object), NV([Ljava.lang.Object;), any(), dump(), any(groovy.lang.Closure), tap(groovy.lang.Closure) at Main.main(Main.groovy:3) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Expected Behavior
groovyc should reject the program with a compile-time error.
Affected Version
This programs have been tested with the compiler from the master (commit: 05a39632565bee88949c8db9d56b9f9598321fc2), 4.0.0-alpha-3, and 3.0.8.
Attachments
Issue Links
- relates to
-
GROOVY-7720 Type incompatibility of generic placeholders not detected on assignment
- Reopened