Skip to content

[Backport] Set typer phase after InteractiveDriver.run #13534

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

Merged
merged 1 commit into from
Sep 16, 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
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 @@ -857,4 +857,20 @@ class CompletionTest {
|}""".withSource
.completion(m1, Set(("show",Method, "(using x$2: x$1.reflect.Printer[x$1.reflect.Tree]): String")))
}

@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]"
)
)
)
}
}