Skip to content

Commit c7739c0

Browse files
committed
Revert "Merge pull request #275 from scala/backport-lts-3.3-22604"
This reverts commit 91aacdb, reversing changes made to cc130d4.
1 parent aa8ff7f commit c7739c0

File tree

15 files changed

+47
-69
lines changed

15 files changed

+47
-69
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
169169

170170
/* ---------------- helper utils for generating classes and fields ---------------- */
171171

172-
def genPlainClass(cd0: TypeDef) = (cd0: @unchecked) match {
172+
def genPlainClass(cd0: TypeDef) = cd0 match {
173173
case TypeDef(_, impl: Template) =>
174174
assert(cnode == null, "GenBCode detected nested methods.")
175175

compiler/src/dotty/tools/dotc/core/Comments.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,15 @@ object Comments {
405405
val Trim = "(?s)^[\\s&&[^\n\r]]*(.*?)\\s*$".r
406406

407407
val raw = ctx.docCtx.flatMap(_.docstring(sym).map(_.raw)).getOrElse("")
408-
defs(sym) ++= defines(raw).map { str =>
409-
val start = skipWhitespace(str, "@define".length)
410-
val (key, Trim(value)) = str.splitAt(skipVariable(str, start)): @unchecked
411-
variableName(key.drop(start)) -> value.replaceAll("\\s+\\*+$", "")
408+
defs(sym) ++= defines(raw).map {
409+
str => {
410+
val start = skipWhitespace(str, "@define".length)
411+
val (key, value) = str.splitAt(skipVariable(str, start))
412+
key.drop(start) -> value
413+
}
414+
} map {
415+
case (key, Trim(value)) =>
416+
variableName(key) -> value.replaceAll("\\s+\\*+$", "")
412417
}
413418
}
414419

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ object SpaceEngine {
801801
}
802802

803803
private def exhaustivityCheckable(sel: Tree)(using Context): Boolean = {
804+
val seen = collection.mutable.Set.empty[Symbol]
804805

805806
// Possible to check everything, but be compatible with scalac by default
806807
def isCheckable(tp: Type): Boolean =
@@ -815,7 +816,10 @@ object SpaceEngine {
815816
}) ||
816817
tpw.isRef(defn.BooleanClass) ||
817818
classSym.isAllOf(JavaEnumTrait) ||
818-
classSym.is(Case)
819+
classSym.is(Case) && {
820+
if seen.add(classSym) then productSelectorTypes(tpw, sel.srcPos).exists(isCheckable(_))
821+
else true // recursive case class: return true and other members can still fail the check
822+
}
819823

820824
!sel.tpe.hasAnnotation(defn.UncheckedAnnot)
821825
&& {

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

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,30 +1294,29 @@ trait Implicits:
12941294
if alt1.isExtension then
12951295
// Fall back: if both results are extension method applications,
12961296
// compare the extension methods instead of their wrappers.
1297-
def stripExtension(alt: SearchSuccess) =
1298-
methPart(stripApply(alt.tree)).tpe: @unchecked match { case ref: TermRef => ref }
1299-
val ref1 = stripExtension(alt1)
1300-
val ref2 = stripExtension(alt2)
1301-
// ref1 and ref2 might refer to type variables owned by
1302-
// alt1.tstate and alt2.tstate respectively, to compare the
1303-
// alternatives correctly we need a TyperState that includes
1304-
// constraints from both sides, see
1305-
// tests/*/extension-specificity2.scala for test cases.
1306-
val constraintsIn1 = alt1.tstate.constraint ne ctx.typerState.constraint
1307-
val constraintsIn2 = alt2.tstate.constraint ne ctx.typerState.constraint
1308-
def exploreState(alt: SearchSuccess): TyperState =
1309-
alt.tstate.fresh(committable = false)
1310-
val comparisonState =
1311-
if constraintsIn1 && constraintsIn2 then
1312-
exploreState(alt1).mergeConstraintWith(alt2.tstate)
1313-
else if constraintsIn1 then
1314-
exploreState(alt1)
1315-
else if constraintsIn2 then
1316-
exploreState(alt2)
1317-
else
1318-
ctx.typerState
1319-
1320-
diff = inContext(ctx.withTyperState(comparisonState)):
1297+
def stripExtension(alt: SearchSuccess) = methPart(stripApply(alt.tree)).tpe
1298+
(stripExtension(alt1), stripExtension(alt2)) match
1299+
case (ref1: TermRef, ref2: TermRef) =>
1300+
// ref1 and ref2 might refer to type variables owned by
1301+
// alt1.tstate and alt2.tstate respectively, to compare the
1302+
// alternatives correctly we need a TyperState that includes
1303+
// constraints from both sides, see
1304+
// tests/*/extension-specificity2.scala for test cases.
1305+
val constraintsIn1 = alt1.tstate.constraint ne ctx.typerState.constraint
1306+
val constraintsIn2 = alt2.tstate.constraint ne ctx.typerState.constraint
1307+
def exploreState(alt: SearchSuccess): TyperState =
1308+
alt.tstate.fresh(committable = false)
1309+
val comparisonState =
1310+
if constraintsIn1 && constraintsIn2 then
1311+
exploreState(alt1).mergeConstraintWith(alt2.tstate)
1312+
else if constraintsIn1 then
1313+
exploreState(alt1)
1314+
else if constraintsIn2 then
1315+
exploreState(alt2)
1316+
else
1317+
ctx.typerState
1318+
1319+
diff = inContext(ctx.withTyperState(comparisonState)):
13211320
compare(ref1, ref2)
13221321
else // alt1 is a conversion, prefer extension alt2 over it
13231322
diff = -1

compiler/test/dotty/tools/scripting/BashExitCodeTests.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,6 @@ class BashExitCodeTests:
6262
@Test def xPluginList = scala("-Xplugin-list")(0)
6363
@Test def vPhases = scala("-Vphases")(0)
6464

65-
@Test def replEval =
66-
scala("--repl-quit-after-init", "--repl-init-script", "'val i = 2 * 2; val j = i + 2'")(0)
67-
6865
/** A utility for running two commands in a row, like you do in bash. */
6966
extension (inline u1: Unit) inline def & (inline u2: Unit): Unit = { u1; u2 }
7067
end BashExitCodeTests

library/src/scala/annotation/newMain.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ final class newMain extends MainAnnotation[FromString, Any]:
253253
case (arg +: t, "") => recurse(t, arg, acc)
254254
case (arg +: t, l) if l.length + 1 + arg.length <= maxLength => recurse(t, s"$l $arg", acc)
255255
case (arg +: t, l) => recurse(t, arg, acc :+ l)
256-
case (_, _) => acc
257256
}
258257

259258
recurse(argsUsage, "", Vector()).toList

scaladoc/src/dotty/tools/scaladoc/site/templates.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,11 @@ case class TemplateFile(
102102
ctx.layouts.getOrElse(name, throw new RuntimeException(s"No layouts named $name in ${ctx.layouts}"))
103103
)
104104

105-
def asJavaElement(o: Any): Any = o match
106-
case m: Map[?, ?] => m.transform { (k, v) => asJavaElement(v) }.asJava
107-
case l: List[?] => l.map(asJavaElement).asJava
105+
def asJavaElement(o: Object): Object = o match
106+
case m: Map[_, _] => m.transform {
107+
case (k: String, v: Object) => asJavaElement(v)
108+
}.asJava
109+
case l: List[_] => l.map(x => asJavaElement(x.asInstanceOf[Object])).asJava
108110
case other => other
109111

110112
// Library requires mutable maps..

tests/pos/switches.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class Test {
4242
case IntAnyVal(100) => 2
4343
case IntAnyVal(1000) => 3
4444
case IntAnyVal(10000) => 4
45-
case _ => -1
4645
}
4746
}
4847

tests/warn/t10373.scala renamed to tests/pos/t10373.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -deprecation -feature
1+
//> using options -Xfatal-warnings -deprecation -feature
22

33
abstract class Foo {
44
def bar(): Unit = this match {
@@ -7,7 +7,7 @@ abstract class Foo {
77
// Works fine
88
}
99

10-
def baz(that: Foo): Unit = (this, that) match { // warn: match may not be exhaustive.
10+
def baz(that: Foo): Unit = (this, that) match {
1111
case (Foo_1(), _) => //do something
1212
case (Foo_2(), _) => //do something
1313
// match may not be exhaustive

tests/warn/i15662.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ case class Composite[T](v: T)
55
def m(composite: Composite[?]): Unit =
66
composite match {
77
case Composite[Int](v) => println(v) // warn: cannot be checked at runtime
8-
case _ => println("OTHER")
98
}
109

1110
def m2(composite: Composite[?]): Unit =

0 commit comments

Comments
 (0)