Skip to content

crash with compilable code: "java.lang.IllegalArgumentException: requirement failed" #2032

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
helloqirun opened this issue Feb 26, 2017 · 2 comments

Comments

@helloqirun
Copy link

scalac can compile but dotc crashes.

$ cat abc.scala

class foo(annotation: Any) extends annotation.StaticAnnotation
@foo(new AnyRef {}) trait A

$ dotc abc.scala

-- [E008] Member Not Found Error: abc.scala ------------------------------------
1 |class foo(annotation: Any) extends annotation.StaticAnnotation
  |                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |                type `StaticAnnotation` is not a member of Any(annotation)

exception occurred while typechecking abc.scala

exception occurred while compiling abc.scala
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed
	at scala.Predef$.require(Predef.scala:207)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.enterNoReplace(SymDenotations.scala:1538)
	at dotty.tools.dotc.core.SymDenotations$ClassDenotation.enter(SymDenotations.scala:1528)
	at dotty.tools.dotc.typer.NamerContextOps$class.enter(Namer.scala:36)
	at dotty.tools.dotc.core.Contexts$Context.enter(Contexts.scala:57)
	at dotty.tools.dotc.typer.Namer.enterSymbol(Namer.scala:339)
	at dotty.tools.dotc.typer.Namer.dotty$tools$dotc$typer$Namer$$recur$1(Namer.scala:437)
<snipped>
@odersky
Copy link
Contributor

odersky commented Feb 27, 2017

This also does the trick:

class foo(annotation: Any)
@foo(new AnyRef {}) trait A

The problem is a double definition of the class $anon that's defined in the new AnyRef {} argument. It seems to come up if foo is not an annotation.

@smarter
Copy link
Member

smarter commented Jan 28, 2019

Already fixed, regression test in #5800.

@smarter smarter closed this as completed Jan 28, 2019
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

3 participants