Skip to content
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

Compiler crash with annotation on main method #22364

Open
lrytz opened this issue Jan 14, 2025 · 0 comments
Open

Compiler crash with annotation on main method #22364

lrytz opened this issue Jan 14, 2025 · 0 comments

Comments

@lrytz
Copy link
Member

lrytz commented Jan 14, 2025

//> using scala 3.6.2

import util.chaining.*

class ann(x: Int = 1, y: Int) extends annotation.Annotation

@ann(y = 22.tap(println)) @main def main = ()
Error: scala.MatchError: Block(List(ValDef(y$1,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)],Apply(TypeApply(Select(Apply(TypeApply(TypedSplice(Ident(scalaUtilChainingOps)),List(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)])),List(Literal(Constant(22)))),tap),List(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)])),List(Block(List(DefDef($anonfun,List(List(ValDef(x,TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any)],EmptyTree))),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Unit)],Apply(TypedSplice(Ident(println)),List(TypedSplice(Ident(x)))))),Closure(List(),TypedSplice(Ident($anonfun)),EmptyTree))))), ValDef(x$1,TypeTree[AnnotatedType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int),ConcreteAnnotation(Apply(Select(New(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class unchecked)),class uncheckedVariance)]),<init>),List())))],Select(TypedSplice(Ident(ann)),$lessinit$greater$default$1))),Apply(Select(New(TypedSplice(Ident(ann))),<init>),List(TypedSplice(Ident(x$1)), NamedArg(y,TypedSplice(Ident(y$1)))))) (of class dotty.tools.dotc.ast.Trees$Block)
	at dotty.tools.dotc.typer.Namer.typedAheadAnnotationClass(Namer.scala:1774)
	at dotty.tools.dotc.typer.Namer$Completer.addAnnotations$$anonfun$1(Namer.scala:883)
@lrytz lrytz added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 14, 2025
@Gedochao Gedochao added area:annotations and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants