Skip to content

Commit 74f78a1

Browse files
authored
Fix completions for Quotes (#23619)
Some denotation were not collected because they were `UniqueRefDenotation` and we matched for `SymDenotation`
1 parent 4b543e8 commit 74f78a1

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,8 +615,9 @@ object Completion:
615615

616616
// 1. The extension method is visible under a simple name, by being defined or inherited or imported in a scope enclosing the reference.
617617
val extMethodsInScope = scopeCompletions.names.toList.flatMap:
618-
case (name, denots) => denots.collect:
619-
case d: SymDenotation if d.isTerm && d.termRef.symbol.is(Extension) => (d.termRef, name.asTermName)
618+
case (name, denots) =>
619+
denots.collect:
620+
case d if d.isTerm && d.symbol.is(Extension) => (d.symbol.termRef, name.asTermName)
620621

621622
// 2. The extension method is a member of some given instance that is visible at the point of the reference.
622623
val givensInScope = ctx.implicits.eligible(defn.AnyType).map(_.implicitRef.underlyingRef)

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,3 +2275,16 @@ class CompletionSuite extends BaseCompletionSuite:
22752275
|""".stripMargin,
22762276
"test: Int"
22772277
)
2278+
2279+
@Test def `macros` =
2280+
check(
2281+
"""
2282+
|object Macro:
2283+
| import scala.quoted.*
2284+
| def dbgImpl[A](a: Expr[A])(using Quotes): Expr[A] =
2285+
| import quotes.reflect.*
2286+
| a.asTer@@
2287+
|
2288+
|""".stripMargin,
2289+
"asTerm: Term"
2290+
)

0 commit comments

Comments
 (0)