Skip to content

Commit cf49c2b

Browse files
authored
Merge pull request #581 from scala/backport-lts-3.3-23679
Backport "Fix implicit scope liftToAnchors for parameter lower bounds" to 3.3 LTS
2 parents 6cbcdc2 + 772d478 commit cf49c2b

File tree

11 files changed

+32
-47
lines changed

11 files changed

+32
-47
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1657,7 +1657,7 @@ object desugar {
16571657
case pat @ Bind(nme.WILDCARD, body) =>
16581658
val name =
16591659
body match
1660-
case Typed(Ident(nme.WILDCARD), tpt) if pat.mods.is(Given) => inventGivenName(tpt)
1660+
case Typed(Ident(nme.WILDCARD), tpt) if pat.mods.is(Given) => inventGivenOrExtensionName(tpt)
16611661
case _ => UniqueName.fresh()
16621662
(cpy.Bind(pat)(name, body).withMods(pat.mods), Ident(name))
16631663
case Bind(name, _) => (pat, Ident(name))

compiler/src/dotty/tools/dotc/transform/init/Checker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Checker extends Phase:
4646
cancellable {
4747
val classes = traverser.getClasses()
4848

49-
if ctx.settings.Whas.safeInit then
49+
if ctx.settings.Whas.checkInit then
5050
Semantic.checkClasses(classes)(using checkCtx)
5151
}
5252

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ trait ImplicitRunInfo:
790790
WildcardType
791791
else
792792
seen += t
793-
t.superType match
793+
t.underlying match
794794
case TypeBounds(lo, hi) =>
795795
if lo.isBottomTypeAfterErasure then apply(hi)
796796
else AndType.make(apply(lo), apply(hi))

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import config.Config
5353
import transform.CheckUnused.OriginalName
5454

5555
import scala.annotation.constructorOnly
56+
import scala.util.chaining.scalaUtilChainingOps
5657
import dotty.tools.dotc.rewrites.Rewrites
5758

5859
object Typer {

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class CompilationTests {
132132
compileFilesInDir("tests/neg-deep-subtype", allowDeepSubtypes),
133133
compileFilesInDir("tests/neg-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
134134
compileFile("tests/neg-custom-args/sourcepath/outer/nested/Test1.scala", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath")),
135-
compileDir("tests/neg-custom-args/sourcepath2/hi", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath2", "-Werror")),
135+
compileDir("tests/neg-custom-args/sourcepath2/hi", defaultOptions.and("-sourcepath", "tests/neg-custom-args/sourcepath2", "-Xfatal-warnings")),
136136
compileList("duplicate source", List(
137137
"tests/neg-custom-args/toplevel-samesource/S.scala",
138138
"tests/neg-custom-args/toplevel-samesource/nested/S.scala"),
@@ -214,7 +214,7 @@ class CompilationTests {
214214
compileFilesInDir("tests/init/neg", options).checkExpectedErrors()
215215
compileFilesInDir("tests/init/warn", defaultOptions.and("-Ysafe-init")).checkWarnings()
216216
compileFilesInDir("tests/init/pos", options).checkCompile()
217-
compileFilesInDir("tests/init/crash", options.without("-Werror")).checkCompile()
217+
compileFilesInDir("tests/init/crash", options.without("-Xfatal-warnings")).checkCompile()
218218
// The regression test for i12128 has some atypical classpath requirements.
219219
// The test consists of three files: (a) Reflect_1 (b) Macro_2 (c) Test_3
220220
// which must be compiled separately. In addition:
@@ -223,7 +223,7 @@ class CompilationTests {
223223
// - the output from (a) _must not_ be on the classpath while compiling (c)
224224
locally {
225225
val i12128Group = TestGroup("checkInit/i12128")
226-
val i12128Options = options.without("-Werror")
226+
val i12128Options = options.without("-Xfatal-warnings")
227227
val outDir1 = defaultOutputDir + i12128Group + "/Reflect_1/i12128/Reflect_1"
228228
val outDir2 = defaultOutputDir + i12128Group + "/Macro_2/i12128/Macro_2"
229229

@@ -242,7 +242,7 @@ class CompilationTests {
242242
* an error when reading the files' TASTy trees. */
243243
locally {
244244
val tastyErrorGroup = TestGroup("checkInit/tasty-error/val-or-defdef")
245-
val tastyErrorOptions = options.without("-Werror")
245+
val tastyErrorOptions = options.without("-Xfatal-warnings")
246246

247247
val classA0 = defaultOutputDir + tastyErrorGroup + "/A/v0/A"
248248
val classA1 = defaultOutputDir + tastyErrorGroup + "/A/v1/A"
@@ -265,7 +265,7 @@ class CompilationTests {
265265
* an error when reading the files' TASTy trees. This fact is demonstrated by the compilation of Main. */
266266
locally {
267267
val tastyErrorGroup = TestGroup("checkInit/tasty-error/typedef")
268-
val tastyErrorOptions = options.without("-Werror").without("-Ycheck:all")
268+
val tastyErrorOptions = options.without("-Xfatal-warnings").without("-Ycheck:all")
269269

270270
val classC = defaultOutputDir + tastyErrorGroup + "/C/typedef/C"
271271
val classA0 = defaultOutputDir + tastyErrorGroup + "/A/v0/A"

compiler/test/dotty/tools/dotc/reporting/CodeActionTest.scala

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import dotty.tools.DottyTest
44
import dotty.tools.dotc.rewrites.Rewrites
55
import dotty.tools.dotc.rewrites.Rewrites.ActionPatch
66
import dotty.tools.dotc.util.SourceFile
7+
import dotty.tools.dotc.core.Contexts._
78

89
import scala.annotation.tailrec
910
import scala.jdk.CollectionConverters.*
@@ -136,35 +137,6 @@ class CodeActionTest extends DottyTest:
136137
afterPhase = "patternMatcher"
137138
)
138139

139-
@Test def removeNN =
140-
val ctxx = newContext
141-
ctxx.setSetting(ctxx.settings.YexplicitNulls, true)
142-
checkCodeAction(
143-
code =
144-
"""|val s: String|Null = "foo".nn
145-
|""".stripMargin,
146-
title = "Remove unnecessary .nn",
147-
expected =
148-
"""|val s: String|Null = "foo"
149-
|""".stripMargin,
150-
ctxx = ctxx
151-
)
152-
153-
154-
@Test def removeNN2 =
155-
val ctxx = newContext
156-
ctxx.setSetting(ctxx.settings.YexplicitNulls, true)
157-
checkCodeAction(
158-
code =
159-
"""val s: String|Null = null.nn
160-
|""".stripMargin,
161-
title = "Remove unnecessary .nn",
162-
expected =
163-
"""val s: String|Null = null
164-
|""".stripMargin,
165-
ctxx = ctxx
166-
)
167-
168140
@Test def addNN1 =
169141
val ctxx = newContext
170142
ctxx.setSetting(ctxx.settings.YexplicitNulls, true)
@@ -278,12 +250,12 @@ class CodeActionTest extends DottyTest:
278250
ctxx.setSetting(ctxx.settings.YexplicitNulls, true)
279251
checkCodeAction(
280252
code =
281-
"""given ctx: String | Null = null
253+
"""given ctx: (String | Null) = null
282254
|def f(using c: String): String = c
283255
|val s: String = f(using ctx)""".stripMargin,
284256
title = "Add .nn",
285257
expected =
286-
"""given ctx: String | Null = null
258+
"""given ctx: (String | Null) = null
287259
|def f(using c: String): String = c
288260
|val s: String = f(using ctx.nn)""".stripMargin,
289261
ctxx = ctxx
@@ -295,8 +267,8 @@ class CodeActionTest extends DottyTest:
295267
val rep = new StoreReporter(null) with UniqueMessagePositions with HideNonSensicalMessages
296268
initialCtx.setReporter(rep).withoutColors
297269

298-
private def checkCodeAction(code: String, title: String, expected: String, afterPhase: String = "typer") =
299-
ctx = newContext
270+
private def checkCodeAction(code: String, title: String, expected: String, afterPhase: String = "typer", ctxx: Context = newContext) =
271+
ctx = ctxx
300272
val source = SourceFile.virtual("test", code).content
301273
val runCtx = checkCompile(afterPhase, code) { (_, _) => () }
302274
val diagnostics = runCtx.reporter.removeBufferedMessages

tests/neg/i23119.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
| given myGiven: Option[List[String]] // define an instance
1010
| given myGiven @ Option[List[String]] // as a pattern variable
1111
-- [E161] Naming Error: tests/neg/i23119.scala:18:8 --------------------------------------------------------------------
12-
18 | given [A] => List[A] = ??? // error
13-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
12+
18 | given [A]: List[A] = ??? // error
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^
1414
| given_List_A is already defined as given instance given_List_A
1515
|
1616
| Provide an explicit, unique name to given definitions,

tests/neg/i23119.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
// duplicate pattern variable: given_Option_List
1515

1616
def also =
17-
given [A] => List[A] = ???
18-
given [A] => List[A] = ??? // error
17+
given [A]: List[A] = ???
18+
given [A]: List[A] = ??? // error
1919
()

tests/neg/i23832b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- [E120] Naming Error: tests/neg/i23832b.scala:9:8 --------------------------------------------------------------------
2-
9 | given [A] => Special[Option[A]] = ??? // error
2+
9 | given [A]: Special[Option[A]] = ??? // error
33
| ^
44
| Conflicting definitions:
55
| final lazy given val given_Special_Option: Special[Option[Long]] in object syntax at line 8 and

tests/neg/i23832b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ trait Special[A]
66

77
object syntax:
88
given Special[Option[Long]] = ???
9-
given [A] => Special[Option[A]] = ??? // error
9+
given [A]: Special[Option[A]] = ??? // error

0 commit comments

Comments
 (0)