New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicate method name&signature with singleton type parameters over constant types #8323

Closed
scabug opened this Issue Feb 22, 2014 · 12 comments

Comments

Projects
None yet
5 participants
@scabug

scabug commented Feb 22, 2014

object Test {
  final val a = "Bippy"
  final val b = "Dingo"
  def f(x: a.type) = x
  def f(x: b.type) = x
  def main(args: Array[String]): Unit = ()
}
// Exception in thread "main" java.lang.ClassFormatError: Duplicate method name&signature in class file Test
//   at java.lang.ClassLoader.defineClass1(Native Method)
//   at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
//   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
//   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Feb 22, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8323?orig=1
Reporter: @paulp
Affected Versions: 2.10.3

scabug commented Feb 22, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8323?orig=1
Reporter: @paulp
Affected Versions: 2.10.3

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Feb 22, 2014

@retronym said:

[[syntax trees at end of              constructors]] // test1.scala
package <empty> {
  object Test extends Object {
    final <stable> <accessor> def a(): String("Bippy") = "Bippy";
    final <stable> <accessor> def b(): String("Dingo") = "Dingo";
    def f(x: String("Bippy")): String = "Bippy";
    def f(x: String("Dingo")): String = "Dingo";
    def main(args: Array[String]): Unit = ();
    def <init>(): Test.type = {
      Test.super.<init>();
      ()
    }
  }
}

scabug commented Feb 22, 2014

@retronym said:

[[syntax trees at end of              constructors]] // test1.scala
package <empty> {
  object Test extends Object {
    final <stable> <accessor> def a(): String("Bippy") = "Bippy";
    final <stable> <accessor> def b(): String("Dingo") = "Dingo";
    def f(x: String("Bippy")): String = "Bippy";
    def f(x: String("Dingo")): String = "Dingo";
    def main(args: Array[String]): Unit = ();
    def <init>(): Test.type = {
      Test.super.<init>();
      ()
    }
  }
}
@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug May 11, 2014

@retronym said:
/cc [~folone]

scabug commented May 11, 2014

@retronym said:
/cc [~folone]

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Jun 11, 2014

@retronym said:
More examples from duplicates:

object Foo extends (() => Int) {
  def apply(): Int = 1
  final override val toString = "Foo";
  def main(args: Array[String]): Unit = println(this)
}
trait Node { // must be a trait
  def isLeaf: Boolean = ???
}
 
object MyLeaf extends Node {
  override final val isLeaf = true // must be override final val
  // mixin erroneously generates two methods in the object: forwarder and the actual method
  /** (un-mangled from a repl session)
  object MyLeaf extends Object with Node {
    def isLeaf(): Boolean = Node$class.isLeaf(MyLeaf.this);
    final override <stable> <accessor> def isLeaf(): Boolean(true) = true;
  */
}

scabug commented Jun 11, 2014

@retronym said:
More examples from duplicates:

object Foo extends (() => Int) {
  def apply(): Int = 1
  final override val toString = "Foo";
  def main(args: Array[String]): Unit = println(this)
}
trait Node { // must be a trait
  def isLeaf: Boolean = ???
}
 
object MyLeaf extends Node {
  override final val isLeaf = true // must be override final val
  // mixin erroneously generates two methods in the object: forwarder and the actual method
  /** (un-mangled from a repl session)
  object MyLeaf extends Object with Node {
    def isLeaf(): Boolean = Node$class.isLeaf(MyLeaf.this);
    final override <stable> <accessor> def isLeaf(): Boolean(true) = true;
  */
}
@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug commented Jun 20, 2014

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Aug 5, 2014

@gkossakowski said:
The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

scabug commented Aug 5, 2014

@gkossakowski said:
The 2.11.2 is out so I'm rescheduling the issue for 2.11.3.

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Nov 4, 2014

@retronym said:
Updating fix-by version to 2.11.5.

scabug commented Nov 4, 2014

@retronym said:
Updating fix-by version to 2.11.5.

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Jul 26, 2016

@milessabin said:
This doesn't belong in Backlog ... it's fixed on my SIP-23 branch. Punt it to 2.12.1 if you like.

scabug commented Jul 26, 2016

@milessabin said:
This doesn't belong in Backlog ... it's fixed on my SIP-23 branch. Punt it to 2.12.1 if you like.

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug commented Aug 12, 2016

@scabug

This comment has been minimized.

Show comment
Hide comment
@scabug

scabug Dec 4, 2016

Jeff Shaw (shawjef3) said:
Possible duplicate?

trait HasX {

  val x = new AnyRef

}

object Bad0 extends HasX {

  override object x extends AnyRef

  def main(args: Array[String]): Unit = {
    println(x)
  }

}

yields

2.12.0

Exception in thread "main" java.lang.AbstractMethodError: Bad0$.HasX$_setter_$x_$eq(Ljava/lang/Object;)V
	at HasX.$init$(Bad0.scala:3)
	at Bad0$.<init>(Bad0.scala:7)
	at Bad0$.<clinit>(Bad0.scala)
	at Bad0.main(Bad0.scala)

2.11.8

[error] (run-main-4) java.lang.ClassFormatError: Duplicate method name&signature in class file Bad0$
java.lang.ClassFormatError: Duplicate method name&signature in class file Bad0$
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at Bad0.main(Bad0.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)

2.10.6

java.lang.ClassFormatError: Duplicate method name&signature in class file Bad0$
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at Bad0.main(Bad0.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)

scabug commented Dec 4, 2016

Jeff Shaw (shawjef3) said:
Possible duplicate?

trait HasX {

  val x = new AnyRef

}

object Bad0 extends HasX {

  override object x extends AnyRef

  def main(args: Array[String]): Unit = {
    println(x)
  }

}

yields

2.12.0

Exception in thread "main" java.lang.AbstractMethodError: Bad0$.HasX$_setter_$x_$eq(Ljava/lang/Object;)V
	at HasX.$init$(Bad0.scala:3)
	at Bad0$.<init>(Bad0.scala:7)
	at Bad0$.<clinit>(Bad0.scala)
	at Bad0.main(Bad0.scala)

2.11.8

[error] (run-main-4) java.lang.ClassFormatError: Duplicate method name&signature in class file Bad0$
java.lang.ClassFormatError: Duplicate method name&signature in class file Bad0$
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at Bad0.main(Bad0.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)

2.10.6

java.lang.ClassFormatError: Duplicate method name&signature in class file Bad0$
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:760)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at Bad0.main(Bad0.scala)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
@lrytz

This comment has been minimized.

Show comment
Hide comment
@lrytz
Member

lrytz commented Mar 1, 2018

Fixed in scala/scala#5310

@lrytz lrytz closed this Mar 1, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment