Skip to content

Commit 299c0b7

Browse files
Revert "Approximate MatchTypes with lub of case bodies, if non-recursive" in 3.5.1 (#21267)
Reverts #19761 in 3.5.1-RC2 as discussed in #21258 and accepted by the core compiler team.
2 parents 49f22bf + 8b82e69 commit 299c0b7

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
@@ -2915,13 +2915,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
29152915
tp.tryCompiletimeConstantFold
29162916
case tp: HKTypeLambda =>
29172917
tp
2918-
case tp: ParamRef =>
2919-
val st = tp.superTypeNormalized
2920-
if st.exists then
2921-
disjointnessBoundary(st)
2922-
else
2923-
// workaround for when ParamRef#underlying returns NoType
2924-
defn.AnyType
29252918
case tp: TypeProxy =>
29262919
disjointnessBoundary(tp.superTypeNormalized)
29272920
case tp: WildcardType =>

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -2604,15 +2604,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
26042604
report.error(MatchTypeScrutineeCannotBeHigherKinded(sel1Tpe), sel1.srcPos)
26052605
val pt1 = if (bound1.isEmpty) pt else bound1.tpe
26062606
val cases1 = tree.cases.mapconserve(typedTypeCase(_, sel1Tpe, pt1))
2607-
val bound2 = if tree.bound.isEmpty then
2608-
val lub = cases1.foldLeft(defn.NothingType: Type): (acc, case1) =>
2609-
if !acc.exists then NoType
2610-
else if case1.body.tpe.isProvisional then NoType
2611-
else acc | case1.body.tpe
2612-
if lub.exists then TypeTree(lub, inferred = true)
2613-
else bound1
2614-
else bound1
2615-
assignType(cpy.MatchTypeTree(tree)(bound2, sel1, cases1), bound2, sel1, cases1)
2607+
assignType(cpy.MatchTypeTree(tree)(bound1, sel1, cases1), bound1, sel1, cases1)
26162608
}
26172609

26182610
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)