Skip to content

Commit

Permalink
Don't enable -Yscala3-implicit-resolution with Xsource:3
Browse files Browse the repository at this point in the history
  • Loading branch information
povder committed Apr 22, 2022
1 parent f4d930b commit 3570c0f
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 32 deletions.
7 changes: 3 additions & 4 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -134,10 +134,9 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "")
val reporter = StringSetting ("-Xreporter", "classname", "Specify a custom subclass of FilteringReporter for compiler messages.", "scala.tools.nsc.reporters.ConsoleReporter")
val source = ScalaVersionSetting ("-Xsource", "version", "Enable features that will be available in a future version of Scala, for purposes of early migration and alpha testing.", initial = ScalaVersion("2.13")).withPostSetHook { s =>
if (s.value >= ScalaVersion("3")) {
if (s.value >= ScalaVersion("3"))
isScala3.value = true
Yscala3ImplicitResolution.value = true
} else if (s.value >= ScalaVersion("2.14"))
else if (s.value >= ScalaVersion("2.14"))
s.withDeprecationMessage("instead of -Xsource:2.14, use -Xsource:3").value = ScalaVersion("3")
else if (s.value < ScalaVersion("2.13"))
errorFn.apply(s"-Xsource must be at least the current major version (${ScalaVersion("2.13").versionString})")
Expand Down Expand Up @@ -284,7 +283,7 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
val YpickleWrite = StringSetting("-Ypickle-write", "directory|jar", "destination for generated .sig files containing type signatures.", "", None).internalOnly()
val YpickleWriteApiOnly = BooleanSetting("-Ypickle-write-api-only", "Exclude private members (other than those material to subclass compilation, such as private trait vals) from generated .sig files containing type signatures.").internalOnly()
val YtrackDependencies = BooleanSetting("-Ytrack-dependencies", "Record references to in unit.depends. Deprecated feature that supports SBT 0.13 with incOptions.withNameHashing(false) only.", default = true)
val Yscala3ImplicitResolution = BooleanSetting("-Yscala3-implicit-resolution", "Use Scala-3-style downwards comparisons for implicit search and overloading resolution")
val Yscala3ImplicitResolution = BooleanSetting("-Yscala3-implicit-resolution", "Use Scala-3-style downwards comparisons for implicit search and overloading resolution", default = false)

sealed abstract class CachePolicy(val name: String, val help: String)
object CachePolicy {
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t2509-2.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
class A
class B extends A
class C extends B
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t2509-3.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
class A
class B extends A

Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t2509-7b.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
class Both[-A, +B]

trait Factory[A] {
Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/t2509-5.scala
@@ -1,5 +1,5 @@
// See https://github.com/lampepfl/dotty/issues/2974
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution

trait Foo[-T]

Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/t2509-6.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
class A
class B extends A

Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/t2509-7a.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution

class Both[-A, +B]

Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t2509-1.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
import scala.language.implicitConversions

class A
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t2509-4.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
import scala.language.implicitConversions

class A
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t7768.scala
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0
// scalac: -Yscala3-implicit-resolution
class A
class B extends A
class C extends B
Expand Down
23 changes: 4 additions & 19 deletions test/junit/scala/tools/nsc/typechecker/InferencerTest.scala
Expand Up @@ -6,7 +6,6 @@ import org.junit.{After, Before, Test}
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

import scala.tools.nsc.settings.ScalaVersion
import scala.tools.testkit.BytecodeTesting

class A
Expand All @@ -26,33 +25,19 @@ trait ZwC[-T] extends Z[T] with C
class InferencerTests extends BytecodeTesting {
import compiler.global._, analyzer._

var storedXsource: ScalaVersion = null
var storedYscala3ImplicitResolution: Boolean = false
@Before
def storeXsource(): Unit = {
storedXsource = settings.source.value
def storeYscala3ImplicitResolution(): Unit = {
storedYscala3ImplicitResolution = settings.Yscala3ImplicitResolution.value
}
@After
def restoreXsource(): Unit = {
settings.source.value = storedXsource
def restoreYscala3ImplicitResolution(): Unit = {
settings.Yscala3ImplicitResolution.value = storedYscala3ImplicitResolution
}

@Test
def isAsSpecificScala2Source213(): Unit = {
settings.source.value = ScalaVersion("2.13")
isAsSpecificScala2()
}

@Test
def isAsSpecificScala2Source3DisableScala3Resolution(): Unit = {
settings.source.value = ScalaVersion("3.0")
def isAsSpecificScala2(): Unit = {
settings.Yscala3ImplicitResolution.value = false
isAsSpecificScala2()
}

private def isAsSpecificScala2(): Unit = {
val run = new global.Run

enteringPhase(run.typerPhase) {
Expand Down Expand Up @@ -118,7 +103,7 @@ class InferencerTests extends BytecodeTesting {

@Test
def isAsSpecificScala3(): Unit = {
settings.source.value = ScalaVersion("3.0")
settings.Yscala3ImplicitResolution.value = true

val run = new global.Run

Expand Down

0 comments on commit 3570c0f

Please sign in to comment.