Skip to content

Commit 8bb0ca7

Browse files
authored
Fix#12600: Handle ExprType during tab completion (#13368)
1 parent 62501c9 commit 8bb0ca7

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,8 @@ object Completion {
300300
case name: TermName if include(denot, name) => Some((denot, name))
301301
case _ => None
302302

303-
types.flatMap { tpe =>
303+
types.flatMap { tp =>
304+
val tpe = tp.widenExpr
304305
tpe.membersBasedOnFlags(required = ExtensionMethod, excluded = EmptyFlags)
305306
.collect { case DenotWithMatchingName(denot, name) => TermRef(tpe, denot.symbol) -> name }
306307
}

compiler/test/dotty/tools/repl/TabcompleteTests.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,10 @@ class TabcompleteTests extends ReplTest {
132132
@Test def i6415 = fromInitialState { implicit s =>
133133
assertEquals(List("Predef"), tabComplete("object Foo { opaque type T = Pre"))
134134
}
135+
136+
@Test def i12600 = fromInitialState { implicit s =>
137+
assertEquals(List("select", "show", "simplified"),
138+
tabComplete("import quoted.* ; def fooImpl(using Quotes): Expr[Int] = { import quotes.reflect.* ; TypeRepr.of[Int].s"))
139+
}
140+
135141
}

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,4 +842,19 @@ class CompletionTest {
842842
|object Main { "abc".xx${m1} }""".withSource
843843
.completion(m1, Set())
844844
}
845+
846+
@Test def i13365: Unit = {
847+
code"""|import scala.quoted._
848+
|
849+
|object Test {
850+
| def test(using Quotes)(str: String) = {
851+
| import quotes.reflect._
852+
| val msg = Expr(str)
853+
| val printHello = '{ print("sdsd") }
854+
| val tree = printHello.asTerm
855+
| tree.sh${m1}
856+
| }
857+
|}""".withSource
858+
.completion(m1, Set(("show",Method, "(using x$2: x$1.reflect.Printer[x$1.reflect.Tree]): String")))
859+
}
845860
}

0 commit comments

Comments
 (0)