Skip to content

Commit

Permalink
Handle ExprType during tab completion
Browse files Browse the repository at this point in the history
  • Loading branch information
griggt committed Aug 24, 2021
1 parent ea63740 commit 8fa4216
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/interactive/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ object Completion {
case name: TermName if include(denot, name) => Some((denot, name))
case _ => None

types.flatMap { tpe =>
types.flatMap { tp =>
val tpe = tp.widenExpr
tpe.membersBasedOnFlags(required = ExtensionMethod, excluded = EmptyFlags)
.collect { case DenotWithMatchingName(denot, name) => TermRef(tpe, denot.symbol) -> name }
}
Expand Down
6 changes: 6 additions & 0 deletions compiler/test/dotty/tools/repl/TabcompleteTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,10 @@ class TabcompleteTests extends ReplTest {
@Test def i6415 = fromInitialState { implicit s =>
assertEquals(List("Predef"), tabComplete("object Foo { opaque type T = Pre"))
}

@Test def i12600 = fromInitialState { implicit s =>
assertEquals(List("select", "show", "simplified"),
tabComplete("import quoted.* ; def fooImpl(using Quotes): Expr[Int] = { import quotes.reflect.* ; TypeRepr.of[Int].s"))
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -842,4 +842,19 @@ class CompletionTest {
|object Main { "abc".xx${m1} }""".withSource
.completion(m1, Set())
}

@Test def i13365: Unit = {
code"""|import scala.quoted._
|
|object Test {
| def test(using Quotes)(str: String) = {
| import quotes.reflect._
| val msg = Expr(str)
| val printHello = '{ print("sdsd") }
| val tree = printHello.asTerm
| tree.sh${m1}@@ // doesn't work
| }
|}""".withSource
.completion(m1, Set(("show",Method, "(using x$2: x$1.reflect.Printer[x$1.reflect.Tree]): String")))
}
}

0 comments on commit 8fa4216

Please sign in to comment.