From 0d1c25dfdcfc04a7d7e616a9fa5dd8c2494d0884 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Tue, 14 Sep 2021 18:49:55 +0200 Subject: [PATCH] Set typer phase after InteractiveDriver.run Fixes https://github.com/lampepfl/dotty/issues/13467 --- .../dotc/interactive/InteractiveDriver.scala | 1 + .../languageserver/DottyLanguageServer.scala | 4 ++-- .../tools/languageserver/CompletionTest.scala | 16 ++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index 7ab7f3b1869f..c0584c51b842 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -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 } diff --git a/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala b/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala index f59133226d42..3f7c58b022d6 100644 --- a/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala +++ b/language-server/src/dotty/tools/languageserver/DottyLanguageServer.scala @@ -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 @@ -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 } diff --git a/language-server/test/dotty/tools/languageserver/CompletionTest.scala b/language-server/test/dotty/tools/languageserver/CompletionTest.scala index 5aa12f425371..d8b347095a11 100644 --- a/language-server/test/dotty/tools/languageserver/CompletionTest.scala +++ b/language-server/test/dotty/tools/languageserver/CompletionTest.scala @@ -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]" + ) + ) + ) + } }