Skip to content

case classes, implementing the Universe *Extractor interfaces, and assertion failure #3137

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

Closed
scabug opened this issue Mar 3, 2010 · 6 comments
Assignees

Comments

@scabug
Copy link

scabug commented Mar 3, 2010

I have just finished an "EmptyUniverse" implementing the various scala.reflect.generic._ bits. There are a bunch of abstract extractor interfaces, which the compiler implements like so:

  case class AnnotationInfo(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)])
  object AnnotationInfo extends AnnotationInfoExtractor

Not sure I would have guessed to even try that as a means of using synthetic methods to implement an interface. Are we suggesting by virtue of embedding it in the reflection interface that it's a mechanism people can expect to keep working?

In any case, it does work if you mimic the compiler structure, having individual traits extending the generic traits, and then mixing them together in Universe. However if you try it directly in the class, like this:

class MyUniverse extends Universe {
 ...
  case class AnnotationInfo(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)])
  object AnnotationInfo extends AnnotationInfoExtractor
}

Then you get the assertion failure seen previously in #2130 and #2779, that a duplicated symbol exists.

[scalacfork] Exception in thread "main" java.lang.AssertionError: assertion failed: List(object AnnotationInfo, object AnnotationInfo)
[scalacfork] 	at scala.Predef$$.assert(Predef.scala:95)
[scalacfork] 	at scala.tools.nsc.symtab.Symbols$$Symbol.suchThat(Symbols.scala:1037)
[scalacfork] 	at scala.tools.nsc.symtab.Symbols$$Symbol.linkedModuleOfClass0(Symbols.scala:1223)

It trips the assertion even if I explicitly list generic.AnnotationInfos in the MyUniverse parents, so it's not a result of being indirectly inherited.

@scabug
Copy link
Author

scabug commented Mar 3, 2010

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

@scabug
Copy link
Author

scabug commented Mar 7, 2010

@ingoem said:
I guess this is for you, Gilles. Feel free to reassign it if you disagree.

@scabug
Copy link
Author

scabug commented Mar 13, 2010

Nate Nystrom (nystrom) said:
I think I have another instance of this bug. I've cut the code down as much as I could:

trait A {
  type C
  def C: Int => C
}

class B extends A {
  case class C(v: Int)
}

I get the following with scalac 2.8.0.Beta1-prerelease on Java 1.6.0_17-b04-248-10M3025 on OS X 10.6.2:

java.lang.AssertionError: assertion failed: List(object C, object C)
	at scala.tools.nsc.symtab.Symbols$$Symbol.suchThat(Symbols.scala:1058)
	at scala.tools.nsc.symtab.Symbols$$Symbol.linkedModuleOfClass0(Symbols.scala:1261)
	at scala.tools.nsc.symtab.Symbols$$Symbol.linkedModuleOfClass(Symbols.scala:1269)
	at scala.tools.nsc.symtab.Symbols$$Symbol.linkedClassOfClass(Symbols.scala:1291)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator$$$$anonfun$$addInnerClasses$$1.apply(GenJVM.scala:511)
	at scala.tools.nsc.backend.jvm.GenJVM$$BytecodeGenerator$$$$anonfun$$addInnerClasses$$1.apply(GenJVM.scala:509)
...

@scabug
Copy link
Author

scabug commented Mar 13, 2010

@paulp said:
I trimmed it just a bit further. This is enough:

trait A {
  val C: Any
}

class B extends A {
  class C
  object C
}

@scabug
Copy link
Author

scabug commented Apr 29, 2010

@dubochet said:
I don't think this is a bug for me. Martin, I suspect it is for you. Feel free to reassign it to scala_meeting if you want someone else to deal with it.

@scabug
Copy link
Author

scabug commented Feb 19, 2011

@paulp said:
(In r24307) Test case closes #3137, no review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants