-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Compiler version
Scala 3.4.0-RC1-bin-20231105-ef97ee2-NIGHTLY
Minimized code
import scala.annotation.MacroAnnotation
import scala.quoted.*
class annotation extends MacroAnnotation:
def transform(using Quotes)(tree: quotes.reflect.Definition) =
import quotes.reflect.*
tree match
case ClassDef(name, constructor, parents, self, body) =>
val classParents = List(TypeTree.of[Object])
val classSymbol = Symbol.newClass(tree.symbol, "GeneratedClass", classParents map { _.tpe }, _ => List.empty, None)
val classTree = ClassDef(classSymbol, classParents, List.empty)
List(ClassDef.copy(tree)(name, constructor, parents, self, body :+ classTree))
@annotation class Test
Output
[error] ## Exception when compiling 2 sources
[error] java.lang.RuntimeException: Failed to find name hashes for Test.GeneratedClass
[error] scala.sys.package$.error(package.scala:30)
[error] sbt.internal.inc.AnalysisCallback.nameHashesForCompanions(Incremental.scala:962)
[error] sbt.internal.inc.AnalysisCallback.analyzeClass(Incremental.scala:969)
[error] sbt.internal.inc.AnalysisCallback.$anonfun$addProductsAndDeps$4(Incremental.scala:992)
[error] scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:286)
[error] scala.collection.mutable.HashSet.foreach(HashSet.scala:79)
[error] scala.collection.TraversableLike.map(TraversableLike.scala:286)
...
Expectation
No error is thrown
c.c. sbt/sbt#7157
jackcviers and jamesward