Aladdin - Scala Bugtracking
[#711] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Gilles Martin fixed 2006-08-21 15:49:25.0
subject Type refinement permitted in wrong case
code
abstract class Component

class Button extends Component {
  def sayHey: Unit = Console.println("Hey, I'm a button") }
  
abstract class Origin {
  val delegate: Component }

object main extends Origin with Application {
  val delegate: Component {
    def sayHey: Unit
  } = new Button
  delegate.sayHey
}
what happened
At run-time:
java.lang.ClassFormatError: Illegal class name "main$" in class file main$
        at java.lang.ClassLoader.defineClass1(Native Method)
        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$100(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        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.main(test.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:53)
        at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:96)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
what expected A compile-time error.
[back to overview]
Changes of this bug report
Martin  edited on  2006-08-21 17:47:56.0