Skip to content

Commit c972766

Browse files
committed
apply typing in desugaring for precise annotation detection
1 parent c69eebd commit c972766

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,14 @@ object desugar {
256256
evidenceParamBuf.toList)
257257
end elimContextBounds
258258

259-
//TODO: this is a hack. Typing causes problems (e.g. scaladoc)
260259
def isPreciseAnnot(tree: untpd.Tree)(using Context): Boolean =
261260
tree match
262-
case Apply(Select(New(Ident(precise)), _), _) => precise.toString == "precise"
261+
case Apply(Select(New(clsSel), _), Nil) =>
262+
inContext(ctx.fresh.setReporter(Reporter.NoReporter).setExploreTyperState()) {
263+
try
264+
ctx.typer.typedExpr(clsSel).tpe.classSymbol == defn.PreciseAnnot
265+
catch case _ : Throwable => false
266+
}
263267
case _ => false
264268

265269
def addDefaultGetters(meth: DefDef)(using Context): Tree =

0 commit comments

Comments
 (0)