Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.3.6
-
None
-
None
-
OSX 10.9, Java 1.7_67
Description
The following code:
trait HiSupport { def sayHi(String msg = "hi") { println msg } } class A implements HiSupport { } new A().sayHi()
Produces incorrect results. The trait method is called without any dispatching complaints, however it just ignores the default argument.
If default arguments are not supported, it seems like it should be a compile failure or at least a failure during dispatch.
If the trait method has multiple arguments, the method dispatch does result in a failure:
trait HiSupport { def sayHi(String name, String msg = "hi") { println msg + name } } class A implements HiSupport { } new A().sayHi("Bob")
groovy.lang.MissingMethodException: No signature of method: A.sayHi() is applicable for argument types: (java.lang.String) values: [Bob] Possible solutions: sayHi(java.lang.String, java.lang.String), wait(), any(), each(groovy.lang.Closure), asType(java.lang.Class), wait(long) at ConsoleScript50.run(ConsoleScript50:9)