diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index c3b462f3b179..4a48eccffec9 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1620,11 +1620,11 @@ class Definitions { /** If `cls` is Tuple1..Tuple22, add the corresponding *: type as last parent to `parents` */ def adjustForTuple(cls: ClassSymbol, tparams: List[TypeSymbol], parents: List[Type]): List[Type] = { - def syntheticParent(tparams: List[TypeSymbol]): Type = - if (tparams.isEmpty) TupleTypeRef - else TypeOps.nestedPairs(tparams.map(_.typeRef)) - if (isTupleClass(cls)) parents :+ syntheticParent(tparams) - else parents + if !isTupleClass(cls) then parents + else if tparams.isEmpty then parents :+ TupleTypeRef + else + assert(parents.head.typeSymbol == ObjectClass) + TypeOps.nestedPairs(tparams.map(_.typeRef)) :: parents.tail } /** If it is BoxedUnit, remove `java.io.Serializable` from `parents`. */ @@ -1777,6 +1777,7 @@ class Definitions { .updated(SingletonClass, ObjectClass) .updated(TupleClass, ProductClass) .updated(NonEmptyTupleClass, ProductClass) + .updated(PairClass, ObjectClass) // ----- Initialization --------------------------------------------------- diff --git a/tests/neg/i13435.check b/tests/neg/i13435.check new file mode 100644 index 000000000000..d60bea7ab588 --- /dev/null +++ b/tests/neg/i13435.check @@ -0,0 +1,12 @@ +-- [E029] Pattern Match Exhaustivity Warning: tests/neg/i13435.scala:7:2 ----------------------------------------------- +7 | s match + | ^ + | match may not be exhaustive. + | + | It would fail on pattern case: (_), ((_, _), (_, _)) + +longer explanation available when compiling with `-explain` +-- Error: tests/neg/i13435.scala:8:10 ---------------------------------------------------------------------------------- +8 | case (dim: Axis, size: Int) => dim // error + | ^^^^^^^^^ + | trait Singleton cannot be used in runtime type tests diff --git a/tests/neg/i13435.scala b/tests/neg/i13435.scala new file mode 100644 index 000000000000..eaff4976eb71 --- /dev/null +++ b/tests/neg/i13435.scala @@ -0,0 +1,8 @@ +type Axis = String&Singleton +type ShapeTuple = Tuple1[(Axis, Int)]|Tuple2[(Axis, Int), (Axis, Int)] +type Shape = (Axis, Int) |ShapeTuple + + +def mkSchema(s: Shape) = + s match + case (dim: Axis, size: Int) => dim // error \ No newline at end of file