-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compiler crash with annotation on main method #22364
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
Comments
Not a crash anymore (probably following my fixes for default arguments):
But it should also not be an error. |
The essential ingredients here seem to be def id[T](x: T): T = x
class ann(x: Int) extends annotation.Annotation
@ann(id(22)) @main def main = () Which becomes: sbt:scala3> scalac -Xprint:typer tests/pos/22364.scala
...
-- Error: tests/pos/22364.scala:5:5 --------------------------------------------
5 |@ann(id(22)) @main def main = ()
| ^^
| cannot infer type; expected type <?> is not fully defined
[[syntax trees at end of typer]] // tests/pos/22364.scala
package <empty> {
class ann(x: Int) extends annotation.Annotation() {
private[this] val x: Int
}
final lazy module val 22364$package: 22364$package = new 22364$package()
final module class 22364$package() extends Object() {
this: 22364$package.type =>
def id[T >: Nothing <: Any](x: T): T = x
@main @ann(id[Int](22)) def main: Unit = ()
}
final class main() extends Object() {
@ann(
id[<error cannot infer type; expected type <?> is not fully defined>](22))
<static> def main(args: Array[String]): Unit =
try main catch
{
case error @ _:scala.util.CommandLineParser.ParseError =>
scala.util.CommandLineParser.showError(error)
}
}
} The same example without def id[T](x: T): T = x
class ann(x: Int) extends annotation.Annotation
@ann(id(22)) @ann(id(22)) def main = () |
The root problem is how we copy annotations when we generate the scala3/compiler/src/dotty/tools/dotc/ast/MainProxies.scala Lines 101 to 111 in 049308f
This logic was introduced in #13858. |
The text was updated successfully, but these errors were encountered: