Skip to content

Commit 6eac278

Browse files
Revert "Approximate MatchTypes with lub of case bodies, if non-recursive" in 3.5.0 (#21266)
Reverts #19761 in 3.5.0-RC6 as discussed in #21258 and accepted by the core compiler team.
2 parents 8e6b582 + 51629a2 commit 6eac278

File tree

7 files changed

+3
-43
lines changed

7 files changed

+3
-43
lines changed

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

-7
Original file line numberDiff line numberDiff line change
@@ -2904,13 +2904,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
29042904
tp
29052905
case tp: HKTypeLambda =>
29062906
tp
2907-
case tp: ParamRef =>
2908-
val st = tp.superTypeNormalized
2909-
if st.exists then
2910-
disjointnessBoundary(st)
2911-
else
2912-
// workaround for when ParamRef#underlying returns NoType
2913-
defn.AnyType
29142907
case tp: TypeProxy =>
29152908
disjointnessBoundary(tp.superTypeNormalized)
29162909
case tp: WildcardType =>

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -2569,15 +2569,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
25692569
report.error(MatchTypeScrutineeCannotBeHigherKinded(sel1Tpe), sel1.srcPos)
25702570
val pt1 = if (bound1.isEmpty) pt else bound1.tpe
25712571
val cases1 = tree.cases.mapconserve(typedTypeCase(_, sel1Tpe, pt1))
2572-
val bound2 = if tree.bound.isEmpty then
2573-
val lub = cases1.foldLeft(defn.NothingType: Type): (acc, case1) =>
2574-
if !acc.exists then NoType
2575-
else if case1.body.tpe.isProvisional then NoType
2576-
else acc | case1.body.tpe
2577-
if lub.exists then TypeTree(lub, inferred = true)
2578-
else bound1
2579-
else bound1
2580-
assignType(cpy.MatchTypeTree(tree)(bound2, sel1, cases1), bound2, sel1, cases1)
2572+
assignType(cpy.MatchTypeTree(tree)(bound1, sel1, cases1), bound1, sel1, cases1)
25812573
}
25822574

25832575
def typedByNameTypeTree(tree: untpd.ByNameTypeTree)(using Context): ByNameTypeTree = tree.result match

tests/pos/13633.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ object Sums extends App:
2121

2222
type Reverse[A] = ReverseLoop[A, EmptyTuple]
2323

24-
type PlusTri[A, B, C] <: Tuple = (A, B, C) match
24+
type PlusTri[A, B, C] = (A, B, C) match
2525
case (false, false, false) => (false, false)
2626
case (true, false, false) | (false, true, false) | (false, false, true) => (false, true)
2727
case (true, true, false) | (true, false, true) | (false, true, true) => (true, false)

tests/pos/Tuple.Drop.scala

-7
This file was deleted.

tests/pos/Tuple.Elem.scala

-7
This file was deleted.

tests/pos/i19710.scala

-11
This file was deleted.

tests/run-macros/type-show/Test_2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object Test {
2323
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Nothing"), """+
2424
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"))), """+
2525
"""MatchType("""+
26-
"""TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int"), """+ // match type bound
26+
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"), """+ // match type bound
2727
"""ParamRef(binder, 0), """+
2828
"""List("""+
2929
"""MatchCase("""+

0 commit comments

Comments
 (0)