diff --git a/community-build/community-projects/shapeless b/community-build/community-projects/shapeless index bdf4e4470199..0360ab4adee1 160000 --- a/community-build/community-projects/shapeless +++ b/community-build/community-projects/shapeless @@ -1 +1 @@ -Subproject commit bdf4e4470199c049095b47f7835bffd8135d03ba +Subproject commit 0360ab4adee161815782c4eb55561d5c951f9e9f diff --git a/community-build/community-projects/upickle b/community-build/community-projects/upickle index 479a528deb1c..f21874cc62b1 160000 --- a/community-build/community-projects/upickle +++ b/community-build/community-projects/upickle @@ -1 +1 @@ -Subproject commit 479a528deb1c6fd830b9638047341ee2013e1806 +Subproject commit f21874cc62b12bfab54fc6794eafdcc7b2cf2d07 diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index adb2194c2b1d..8c942f0216d1 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -1807,7 +1807,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler given AnnotatedTypeMethods: AnnotatedTypeMethods with extension (self: AnnotatedType): def underlying: TypeRepr = self.underlying.stripTypeVar - def annot: Term = self.annot.tree + def annotation: Term = self.annot.tree end extension end AnnotatedTypeMethods @@ -2304,8 +2304,14 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def tree: Tree = FromSymbol.definitionFromSym(self) - def annots: List[Term] = - self.annotations.flatMap { + def hasAnnotation(annotSym: Symbol): Boolean = + self.denot.hasAnnotation(annotSym) + + def getAnnotation(annotSym: Symbol): Option[Term] = + self.denot.getAnnotation(annotSym).map(_.tree) + + def annotations: List[Term] = + self.denot.annotations.flatMap { case _: dotc.core.Annotations.BodyAnnotation => Nil case annot => annot.tree :: Nil } diff --git a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala index 92d37e12ed89..e751cd352d95 100644 --- a/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala +++ b/compiler/src/scala/quoted/runtime/impl/printers/SourceCode.scala @@ -370,7 +370,7 @@ object SourceCode { this += "throw " printTree(expr) - case Apply(fn, args) if fn.symbol == Symbol.requiredMethod("scala.internal.Quoted.exprQuote") => + case Apply(fn, args) if fn.symbol == Symbol.requiredMethod("scala.quoted.runtime.quote") => args.head match { case Block(stats, expr) => this += "'{" @@ -385,12 +385,7 @@ object SourceCode { this += "}" } - case TypeApply(fn, args) if fn.symbol == Symbol.requiredMethod("scala.internal.Quoted.typeQuote") => - this += "'[" - printTypeTree(args.head) - this += "]" - - case Apply(fn, arg :: Nil) if fn.symbol == Symbol.requiredMethod("scala.internal.Quoted.exprSplice") => + case Apply(fn, arg :: Nil) if fn.symbol == Symbol.requiredMethod("scala.quoted.runtime.splice") => this += "${" printTree(arg) this += "}" @@ -594,8 +589,9 @@ object SourceCode { private def printFlatBlock(stats: List[Statement], expr: Term)(using elideThis: Option[Symbol]): this.type = { val (stats1, expr1) = flatBlock(stats, expr) + val splicedTypeAnnot = Symbol.requiredClass("scala.quoted.runtime.SplicedType").primaryConstructor val stats2 = stats1.filter { - case tree: TypeDef => !tree.symbol.annots.exists(_.symbol.maybeOwner == Symbol.requiredClass("scala.internal.Quoted.quoteTypeTag")) + case tree: TypeDef => !tree.symbol.hasAnnotation(splicedTypeAnnot) case _ => true } if (stats2.isEmpty) { @@ -1271,7 +1267,7 @@ object SourceCode { } private def printDefAnnotations(definition: Definition)(using elideThis: Option[Symbol]): this.type = { - val annots = definition.symbol.annots.filter { + val annots = definition.symbol.annotations.filter { case Annotation(annot, _) => val sym = annot.tpe.typeSymbol sym != Symbol.requiredClass("scala.forceInline") && diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index 4765af3d1b33..db59e0017742 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -2356,7 +2356,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => trait AnnotatedTypeMethods: extension (self: AnnotatedType): def underlying: TypeRepr - def annot: Term + def annotation: Term end extension end AnnotatedTypeMethods @@ -3083,8 +3083,14 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => */ def tree: Tree + /** Is the annotation defined with `annotSym` attached to this symbol? */ + def hasAnnotation(annotSym: Symbol): Boolean + + /** Get the annotation defined with `annotSym` attached to this symbol */ + def getAnnotation(annotSym: Symbol): Option[Term] + /** Annotations attached to this symbol */ - def annots: List[Term] + def annotations: List[Term] /** Does this symbol come from a currently compiled source file? */ def isDefinedInCurrentRun: Boolean diff --git a/scala3doc/src/dotty/dokka/tasty/BasicSupport.scala b/scala3doc/src/dotty/dokka/tasty/BasicSupport.scala index fd4293430c29..5444e4dcd1e5 100644 --- a/scala3doc/src/dotty/dokka/tasty/BasicSupport.scala +++ b/scala3doc/src/dotty/dokka/tasty/BasicSupport.scala @@ -45,6 +45,6 @@ trait BasicSupport: path.map(TastyDocumentableSource(_, sym.pos.startLine)) def getAnnotations(): List[Annotation] = - sym.annots.filterNot(_.symbol.packageName.startsWith("scala.annotation.internal")).map(parseAnnotation).reverse + sym.annotations.filterNot(_.symbol.packageName.startsWith("scala.annotation.internal")).map(parseAnnotation).reverse