-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add regression test for issue 18726 #20318
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
cfe13a4
Add regression test for issue 18726
rochala f5dc97f
Make 11 test start only on jvm 11+
rochala 07deb55
Update presentation-compiler/test/dotty/tools/pc/utils/JRE.scala
rochala 0b45f44
Fix types
rochala 3078860
Fix accidentaly removed .nn call and remove -release from forbidden o…
rochala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease11Suite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
31 changes: 31 additions & 0 deletions
31
presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionRelease8Suite.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package dotty.tools.pc.utils | ||
|
||
object JRE: | ||
|
||
def getJavaMajorVersion: Int = | ||
val javaVersion = sys.env.get("java.version").filter(!_.isEmpty()) | ||
|
||
javaVersion match | ||
case Some(version) if version.startsWith("1.8") => 8 | ||
case _ => | ||
scala.util.Try: | ||
val versionMethod = classOf[Runtime].getMethod("version") | ||
versionMethod.nn.setAccessible(true) | ||
val version = versionMethod.nn.invoke(null) | ||
|
||
val majorMethod = version.getClass().getMethod("feature") | ||
majorMethod.nn.setAccessible(true) | ||
val major = majorMethod.nn.invoke(version).asInstanceOf[Int] | ||
major | ||
.getOrElse(8) // Minimal version supported by Scala | ||
|
||
rochala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this actually working? I think I actually had to turn it off and -release options is removed:
scala3/presentation-compiler/src/main/dotty/tools/pc/ScalaPresentationCompiler.scala
Line 61 in 5e83606
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I don't understand the question. Are you asking about how the test is implemented or how are we handling the release flag ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are the tests working? And maybe we need to stop removing the flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I guess it is because I passed it as
-release:8
and it is a single argument on the list, thus it is not removed ? We should remove this line tho beacuse-release 8
is a valid scala flag.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you remember why we added this check in the first place ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might have been interfering with some other options and it seemed not important for frontend phases scalameta/metals#3812
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tested it and seems to work ok with that removed.