diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 302ad7987889..b15a9cdb2444 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -543,7 +543,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling recur(tp1.parent, tp2) case tp1: MatchType => val reduced = tp1.reduced - if reduced.exists then + if reduced.exists && !reduced.isError then recur(reduced, tp2) && recordGadtUsageIf { MatchType.thatReducesUsingGadt(tp1) } else thirdTry case _: FlexType => @@ -786,7 +786,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling either(recur(tp1, tp21), recur(tp1, tp22)) || fourthTry case tp2: MatchType => val reduced = tp2.reduced - if reduced.exists then + if reduced.exists && !reduced.isError then recur(tp1, reduced) && recordGadtUsageIf { MatchType.thatReducesUsingGadt(tp2) } else fourthTry diff --git a/tests/neg/i19949.scala b/tests/neg/i19949.scala new file mode 100644 index 000000000000..96a22e42e079 --- /dev/null +++ b/tests/neg/i19949.scala @@ -0,0 +1,9 @@ + +trait T[N]: + type M = N match + case 0 => Any + +val t: T[Double] = new T[Double] {} +val x: t.M = "hello" // error + +val z: T[Double]#M = "hello" // error diff --git a/tests/pos/i18211.scala b/tests/pos/i18211.scala deleted file mode 100644 index c5ec30ba5d61..000000000000 --- a/tests/pos/i18211.scala +++ /dev/null @@ -1,39 +0,0 @@ -import scala.compiletime.ops.int.* - -type AnyInt[A <: Int] <: Int = A match { - case _ => A -} - -type IndexOf[A, T <: Tuple] <: Int = T match { - case EmptyTuple => -1 - case A *: t => 0 - case _ *: t => - IndexOf[A, t] match { - case -1 => -1 - case AnyInt[a] => S[a] - } -} - -type Indexes[A, T <: Tuple] -object Indexes { - given of[A, T <: Tuple](using IndexOf[A, T] >= 0 =:= true)(using - index: ValueOf[IndexOf[A, T]], - next: Indexes[A, Tuple.Drop[T, S[IndexOf[A, T]]]] - ): Indexes[A, T] = ??? - - given empty[A, T <: Tuple](using IndexOf[A, T] =:= -1): Indexes[A, T] = ??? -} - -class GetAll[A]: - def apply[T <: Tuple](t: T)(using indexes: Indexes[A, T]): List[A] = ??? - -def getAll[A]: GetAll[A] = new GetAll[A] - -def test = - // the code here is trying to get all values from a tuple that has type [X] as a list - - // this works if there are only two strings in the tuple - getAll[String](("str1", 1, "str2", false)) - - //but this not compiles if there are more than two strings in the tuple - getAll[String](("str1", 1, "str2", false, "str3")) diff --git a/tests/pos/i19950.scala b/tests/pos/i19950.scala new file mode 100644 index 000000000000..349140f43ff5 --- /dev/null +++ b/tests/pos/i19950.scala @@ -0,0 +1,10 @@ + +trait Apply[F[_]]: + extension [T <: NonEmptyTuple](tuple: T)(using toMap: Tuple.IsMappedBy[F][T]) + def mapN[B](f: Tuple.InverseMap[T, F] => B): F[B] = ??? + +given Apply[Option] = ??? +given Apply[List] = ??? +given Apply[util.Try] = ??? + +@main def Repro = (Option(1), Option(2), Option(3)).mapN(_ + _ + _) \ No newline at end of file