Skip to content

Commit d2bb85d

Browse files
authored
Add regression test for issue 18726 (#20318)
Closes #18726 [test_windows_full]
2 parents c9b9aea + 3078860 commit d2bb85d

File tree

5 files changed

+77
-2
lines changed

5 files changed

+77
-2
lines changed

compiler/src/dotty/tools/dotc/interactive/Completion.scala

-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ object Completion:
287287
if denot.isType then denot.symbol.showFullName
288288
else denot.info.widenTermRefExpr.show
289289

290-
291290
def isInNewContext(untpdPath: List[untpd.Tree]): Boolean =
292291
untpdPath match
293292
case _ :: untpd.New(selectOrIdent: (untpd.Select | untpd.Ident)) :: _ => true

presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ case class ScalaPresentationCompiler(
6060
val scalaVersion = BuildInfo.scalaVersion
6161

6262
private val forbiddenOptions = Set("-print-lines", "-print-tasty")
63-
private val forbiddenDoubleOptions = Set("-release")
63+
private val forbiddenDoubleOptions = Set.empty[String]
6464

6565
given ReportContext =
6666
folderPath
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package dotty.tools.pc.tests.completion
2+
3+
import dotty.tools.pc.base.BaseCompletionSuite
4+
5+
import org.junit.Test
6+
import org.junit.Before
7+
import java.nio.file.Path
8+
import dotty.tools.pc.utils.JRE
9+
10+
class CompletionRelease11Suite extends BaseCompletionSuite:
11+
12+
override protected def scalacOptions(classpath: Seq[Path]): Seq[String] =
13+
"-release:11" +: super.scalacOptions(classpath)
14+
15+
@Before
16+
def beforeMethod(): Unit =
17+
org.junit.Assume.assumeTrue(JRE.getJavaMajorVersion >= 11)
18+
19+
@Test def java11Symbols =
20+
check(
21+
"""
22+
|object A {
23+
| "".repea@@
24+
|}""".stripMargin,
25+
"""repeat(x$0: Int): String
26+
|replaceAll(x$0: String, x$1: String): String
27+
|prependedAll[B >: A](prefix: IterableOnce[B]): IndexedSeq[B]
28+
|prependedAll(prefix: String): String
29+
|prependedAll[B >: Char](prefix: IterableOnce[B]): IndexedSeq[B]
30+
|replaceAllLiterally(literal: String, replacement: String): String
31+
|""".stripMargin
32+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package dotty.tools.pc.tests.completion
2+
3+
import dotty.tools.pc.base.BaseCompletionSuite
4+
5+
import org.junit.Test
6+
import org.junit.Before
7+
import java.nio.file.Path
8+
import dotty.tools.pc.utils.JRE
9+
10+
class CompletionRelease8Suite extends BaseCompletionSuite:
11+
12+
override protected def scalacOptions(classpath: Seq[Path]): Seq[String] =
13+
"-release:8" +: super.scalacOptions(classpath)
14+
15+
@Before
16+
def beforeMethod(): Unit =
17+
org.junit.Assume.assumeTrue(JRE.getJavaMajorVersion >= 8)
18+
19+
@Test def noJvm11Symbols =
20+
check(
21+
"""
22+
|object A {
23+
| "".repea@@
24+
|}""".stripMargin,
25+
"""replaceAll(x$0: String, x$1: String): String
26+
|prependedAll[B >: A](prefix: IterableOnce[B]): IndexedSeq[B]
27+
|prependedAll(prefix: String): String
28+
|prependedAll[B >: Char](prefix: IterableOnce[B]): IndexedSeq[B]
29+
|replaceAllLiterally(literal: String, replacement: String): String
30+
|""".stripMargin
31+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package dotty.tools.pc.utils
2+
3+
object JRE:
4+
5+
def getJavaMajorVersion: Int =
6+
val javaVersion = sys.env.get("java.specification.version").filter(!_.isEmpty())
7+
8+
javaVersion match
9+
case Some(version) if version.startsWith("1.8") => 8
10+
case Some(version) => version.toInt // it is better to crash during tests than to run incorrect suite
11+
case None => 8
12+
13+

0 commit comments

Comments
 (0)