Skip to content

Commit

Permalink
Merge pull request #13530 from tgodzik/fix-wrong-phase
Browse files Browse the repository at this point in the history
Set typer phase after InteractiveDriver.run
  • Loading branch information
Kordyjan committed Sep 15, 2021
2 parents a86c97a + 790359f commit ea871c2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
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
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
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 ea871c2

Please sign in to comment.