Skip to content

Commit

Permalink
Revert "Approximate MatchTypes with lub of case bodies, if non-recurs…
Browse files Browse the repository at this point in the history
…ive" in 3.4.3 (#21268)

Reverts #19761 in 3.4.3-RC1 as discussed in #21258 and accepted by the
core compiler team.
  • Loading branch information
WojciechMazur authored Jul 29, 2024
2 parents 5f36df2 + ff34648 commit bbfa7bc
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 44 deletions.
7 changes: 0 additions & 7 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2897,13 +2897,6 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
tp
case tp: HKTypeLambda =>
tp
case tp: ParamRef =>
val st = tp.superTypeNormalized
if st.exists then
disjointnessBoundary(st)
else
// workaround for when ParamRef#underlying returns NoType
defn.AnyType
case tp: TypeProxy =>
disjointnessBoundary(tp.superTypeNormalized)
case tp: WildcardType =>
Expand Down
10 changes: 1 addition & 9 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2389,15 +2389,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
report.error(MatchTypeScrutineeCannotBeHigherKinded(sel1Tpe), sel1.srcPos)
val pt1 = if (bound1.isEmpty) pt else bound1.tpe
val cases1 = tree.cases.mapconserve(typedTypeCase(_, sel1Tpe, pt1))
val bound2 = if tree.bound.isEmpty then
val lub = cases1.foldLeft(defn.NothingType: Type): (acc, case1) =>
if !acc.exists then NoType
else if case1.body.tpe.isProvisional then NoType
else acc | case1.body.tpe
if lub.exists then TypeTree(lub, inferred = true)
else bound1
else bound1
assignType(cpy.MatchTypeTree(tree)(bound2, sel1, cases1), bound2, sel1, cases1)
assignType(cpy.MatchTypeTree(tree)(bound1, sel1, cases1), bound1, sel1, cases1)
}

def typedByNameTypeTree(tree: untpd.ByNameTypeTree)(using Context): ByNameTypeTree = tree.result match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package dotty.tools.pc.tests.completion
import dotty.tools.pc.base.BaseCompletionSuite

import org.junit.Test
import org.junit.Ignore

class CompletionScalaCliSuite extends BaseCompletionSuite:

Expand All @@ -28,7 +29,8 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
|// //> using lib ???
|//> using lib io.circe::circe-core_native0.4
|package A
|""".stripMargin
|""".stripMargin,
assertSingleItem = false
)

@Test def `version-sort` =
Expand All @@ -43,6 +45,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
|""".stripMargin,
)

@Ignore
@Test def `single-colon` =
check(
"""|//> using lib "io.circe:circe-core_na@@
Expand Down Expand Up @@ -73,6 +76,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
|""".stripMargin,
)

@Ignore
@Test def `multiple-libs` =
check(
"""|//> using lib "io.circe::circe-core:0.14.0", "io.circe::circe-core_na@@"
Expand All @@ -81,6 +85,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
"circe-core_native0.4"
)

@Ignore
@Test def `script` =
check(
scriptWrapper(
Expand Down Expand Up @@ -133,6 +138,7 @@ class CompletionScalaCliSuite extends BaseCompletionSuite:
|io.circul""".stripMargin
)

@Ignore
@Test def `multiple-deps2` =
check(
"""|//> using libs "io.circe::circe-core:0.14.0", "io.circe::circe-core_na@@"
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/13633.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object Sums extends App:

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

type PlusTri[A, B, C] <: Tuple = (A, B, C) match
type PlusTri[A, B, C] = (A, B, C) match
case (false, false, false) => (false, false)
case (true, false, false) | (false, true, false) | (false, false, true) => (false, true)
case (true, true, false) | (true, false, true) | (false, true, true) => (true, false)
Expand Down
7 changes: 0 additions & 7 deletions tests/pos/Tuple.Drop.scala

This file was deleted.

7 changes: 0 additions & 7 deletions tests/pos/Tuple.Elem.scala

This file was deleted.

11 changes: 0 additions & 11 deletions tests/pos/i19710.scala

This file was deleted.

2 changes: 1 addition & 1 deletion tests/run-macros/type-show/Test_2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object Test {
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Nothing"), """+
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"))), """+
"""MatchType("""+
"""TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "<root>")), "scala"), "Int"), """+ // match type bound
"""TypeRef(ThisType(TypeRef(NoPrefix(), "scala")), "Any"), """+ // match type bound
"""ParamRef(binder, 0), """+
"""List("""+
"""MatchCase("""+
Expand Down

0 comments on commit bbfa7bc

Please sign in to comment.