diff --git a/compiler/src/dotty/tools/dotc/interactive/Completion.scala b/compiler/src/dotty/tools/dotc/interactive/Completion.scala index 1395d9b80b53..6e86f45237cf 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Completion.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Completion.scala @@ -286,7 +286,6 @@ object Completion: if denot.isType then denot.symbol.showFullName else denot.info.widenTermRefExpr.show - def isInNewContext(untpdPath: List[untpd.Tree]): Boolean = untpdPath match case _ :: untpd.New(selectOrIdent: (untpd.Select | untpd.Ident)) :: _ => true diff --git a/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala b/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala index 85de8e7d8439..679fbf000f75 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala @@ -58,7 +58,7 @@ case class ScalaPresentationCompiler( val scalaVersion = BuildInfo.scalaVersion private val forbiddenOptions = Set("-print-lines", "-print-tasty") - private val forbiddenDoubleOptions = Set("-release") + private val forbiddenDoubleOptions = Set.empty[String] given ReportContext = folderPath diff --git a/presentation-compiler/test/dotty/tools/pc/base/ReusableClassRunner.scala b/presentation-compiler/test/dotty/tools/pc/base/ReusableClassRunner.scala index 82e697e6e9a1..4999e0ddbc69 100644 --- a/presentation-compiler/test/dotty/tools/pc/base/ReusableClassRunner.scala +++ b/presentation-compiler/test/dotty/tools/pc/base/ReusableClassRunner.scala @@ -13,22 +13,17 @@ class ReusableClassRunner(testClass: Class[BasePCSuite]) testClass.getDeclaredConstructor().newInstance() override def createTest(): AnyRef = instance - override def withBefores( - method: FrameworkMethod, - target: Object, - statement: Statement - ): Statement = - statement override def withAfters( method: FrameworkMethod, target: Object, statement: Statement ): Statement = + val newStatement = super.withAfters(method, target, statement) new Statement(): override def evaluate(): Unit = try - statement.evaluate() + newStatement.evaluate() finally if (isLastTestCase(method)) then instance.clean() diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease11Suite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease11Suite.scala new file mode 100644 index 000000000000..76015a588387 --- /dev/null +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease11Suite.scala @@ -0,0 +1,32 @@ +package dotty.tools.pc.tests.completion + +import dotty.tools.pc.base.BaseCompletionSuite + +import org.junit.Test +import org.junit.Before +import java.nio.file.Path +import dotty.tools.pc.utils.JRE + +class CompletionRelease11Suite extends BaseCompletionSuite: + + override protected def scalacOptions(classpath: Seq[Path]): Seq[String] = + "-release:11" +: super.scalacOptions(classpath) + + @Before + def beforeMethod(): Unit = + org.junit.Assume.assumeTrue(JRE.getJavaMajorVersion >= 11) + + @Test def java11Symbols = + check( + """ + |object A { + | "".repea@@ + |}""".stripMargin, + """repeat(x$0: Int): String + |replaceAll(x$0: String, x$1: String): String + |prependedAll[B >: A](prefix: IterableOnce[B]): IndexedSeq[B] + |prependedAll(prefix: String): String + |prependedAll[B >: Char](prefix: IterableOnce[B]): IndexedSeq[B] + |replaceAllLiterally(literal: String, replacement: String): String + |""".stripMargin + ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease8Suite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease8Suite.scala new file mode 100644 index 000000000000..587cd5a53073 --- /dev/null +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease8Suite.scala @@ -0,0 +1,31 @@ +package dotty.tools.pc.tests.completion + +import dotty.tools.pc.base.BaseCompletionSuite + +import org.junit.Test +import org.junit.Before +import java.nio.file.Path +import dotty.tools.pc.utils.JRE + +class CompletionRelease8Suite extends BaseCompletionSuite: + + override protected def scalacOptions(classpath: Seq[Path]): Seq[String] = + "-release:8" +: super.scalacOptions(classpath) + + @Before + def beforeMethod(): Unit = + org.junit.Assume.assumeTrue(JRE.getJavaMajorVersion >= 8) + + @Test def noJvm11Symbols = + check( + """ + |object A { + | "".repea@@ + |}""".stripMargin, + """replaceAll(x$0: String, x$1: String): String + |prependedAll[B >: A](prefix: IterableOnce[B]): IndexedSeq[B] + |prependedAll(prefix: String): String + |prependedAll[B >: Char](prefix: IterableOnce[B]): IndexedSeq[B] + |replaceAllLiterally(literal: String, replacement: String): String + |""".stripMargin + ) diff --git a/presentation-compiler/test/dotty/tools/pc/utils/JRE.scala b/presentation-compiler/test/dotty/tools/pc/utils/JRE.scala new file mode 100644 index 000000000000..d082258c255b --- /dev/null +++ b/presentation-compiler/test/dotty/tools/pc/utils/JRE.scala @@ -0,0 +1,13 @@ +package dotty.tools.pc.utils + +object JRE: + + def getJavaMajorVersion: Int = + val javaVersion = sys.env.get("java.specification.version").filter(!_.isEmpty()) + + javaVersion match + case Some(version) if version.startsWith("1.8") => 8 + case Some(version) => version.toInt // it is better to crash during tests than to run incorrect suite + case None => 8 + +