Skip to content

Commit 3d170d1

Browse files
committed
Use Scala 3 implicit scopes in scalatest
Add `-Yscala3ImplicitScopes` to eneble Scala 3 implicit scope rules under `-language:Scala2`
1 parent 0cd166a commit 3d170d1

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed
Submodule scalatest updated 36 files

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class ScalaSettings extends Settings.SettingGroup {
109109
val YemitTastyInClass: Setting[Boolean] = BooleanSetting("-Yemit-tasty-in-class", "Generate tasty in the .class file and add an empty *.hasTasty file.")
110110
val YlogClasspath: Setting[Boolean] = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.")
111111
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
112+
val Yscala3ImplicitScopes: Setting[Boolean] = BooleanSetting("-Yscala3ImplicitScopes", "Use Scala 3 implicit scopes rules under -language:Scala2")
112113

113114
val Yscala2Unpickler: Setting[String] = StringSetting("-Yscala2-unpickler", "", "Control where we may get Scala 2 symbols from. This is either \"always\", \"never\", or a classpath.", "always")
114115
// TODO: Remove once we drop support for 2.12 standard library

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ object Implicits {
268268
*/
269269
override val level: Int =
270270
if (outerImplicits == null) 1
271-
else if (ctx.scala2Mode ||
271+
else if ((ctx.scala2Mode && !ctx.settings.Yscala3ImplicitScopes.value) ||
272272
(ctx.owner eq outerImplicits.ctx.owner) &&
273273
(ctx.scope eq outerImplicits.ctx.scope) &&
274274
!refs.head.implicitName.is(LazyImplicitName)) outerImplicits.level

0 commit comments

Comments
 (0)