Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix#12600: Handle ExprType during tab completion #13368

Merged
merged 2 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}
| }
|}""".withSource
.completion(m1, Set(("show",Method, "(using x$2: x$1.reflect.Printer[x$1.reflect.Tree]): String")))
}
}