Skip to content

Commit

Permalink
Set typer phase after InteractiveDriver.run
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik authored and olsdavis committed Apr 4, 2022
1 parent b364667 commit 71caa2c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
cleanup(t)
myOpenedTrees(uri) = topLevelTrees(t, source)
myCompilationUnits(uri) = unit
myCtx = myCtx.fresh.setPhase(myInitCtx.base.typerPhase)

reporter.removeBufferedMessages
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import scala.io.Codec
import dotc._
import ast.{Trees, tpd, untpd}
import core._, core.Decorators._
import Comments._, Constants._, Contexts._, Flags._, Names._, NameOps._, Symbols._, SymDenotations._, Trees._, Types._, Periods._
import Comments._, Constants._, Contexts._, Flags._, Names._, NameOps._, Symbols._, SymDenotations._, Trees._, Types._
import classpath.ClassPathEntries
import reporting._
import typer.Typer
Expand Down Expand Up @@ -307,7 +307,7 @@ class DottyLanguageServer extends LanguageServer
val pos = sourcePosition(driver, uri, params.getPosition)
val items = driver.compilationUnits.get(uri) match {
case Some(unit) =>
val freshCtx = ctx.fresh.setPeriod(Period(ctx.runId, ctx.base.typerPhase.id)).setCompilationUnit(unit)
val freshCtx = ctx.fresh.setCompilationUnit(unit)
Completion.completions(pos)(using freshCtx)._2
case None => Nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ class CompletionTest {

@Test def syntheticThis: Unit = {
code"""|class Y() {
| def bar: Unit =
| def bar: Unit =
| val argument: Int = ???
| arg${m1}
|
Expand All @@ -870,4 +870,20 @@ class CompletionTest {
.completion(m1, Set(("arg", Method, "=> String"),
("argument", Field, "Int")))
}

@Test def concatMethodWithImplicits: Unit = {
code"""|object A {
| Array.concat${m1}
|}""".withSource
.completion(
m1,
Set(
(
"concat",
Method,
"[T](xss: Array[T]*)(implicit evidence$11: scala.reflect.ClassTag[T]): Array[T]"
)
)
)
}
}

0 comments on commit 71caa2c

Please sign in to comment.