You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code above compiles fine, but throws this exception when we run it:
java.lang.ClassFormatError:Duplicate method name&signature in classfileMain$$$$anon$$2$$Foo$$$$anon$$1
at java.lang.ClassLoader.defineClass1(NativeMethod)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$$000(URLClassLoader.java:56)
at java.net.URLClassLoader$$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(NativeMethod)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at Main$$$$anon$$2$$Foo$$class.withA((virtual file):7)
at Main$$$$anon$$2$$Bar.withA((virtual file):12)
at Main$$$$anon$$2.<init>((virtual file):14)
at Main$$.main((virtual file):4)
at Main.main((virtual file))
The generated class Test$$Foo$$$$anon$$1 looks very sucpicious when printed after cleanup.
@dubochet said:
I confirmed this issue with r15501. There is definitely something fishy with the way Scalac creates accessors and/or bridges in that case.
@odersky said:
I could fix this (in r15656) but the fix breaks binary compatibility of all classes that use traits with fields. I therefore postpone the fix to 2.8.0. But it can be tested already now with -Xexperimental.
Btw, the fix can and should be generalized so as to also allow super calls on trait fields. Should be relatively straightforward given the technique (rename trait val fields in addition to trait val setters).
The code above compiles fine, but throws this exception when we run it:
The generated class
Test$$Foo$$$$anon$$1
looks very sucpicious when printed after cleanup.The text was updated successfully, but these errors were encountered: