Skip to content

Commit 36f5e5d

Browse files
Fix #8313: special case typeparamCorrespondsToField
1 parent 435397f commit 36f5e5d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2219,13 +2219,15 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
22192219
/** Returns last check's debug mode, if explicitly enabled. */
22202220
def lastTrace(): String = ""
22212221

2222+
/** Does `tycon` have a field with type `tparam`? Special cased for `scala.*:`
2223+
* as that type is artificially added to tuples. */
22222224
private def typeparamCorrespondsToField(tycon: Type, tparam: TypeParamInfo): Boolean =
22232225
productSelectorTypes(tycon, null).exists {
22242226
case tp: TypeRef =>
22252227
tp.designator.eq(tparam) // Bingo!
22262228
case _ =>
22272229
false
2228-
}
2230+
} || tycon.derivesFrom(defn.PairClass)
22292231

22302232
/** Is `tp` an empty type?
22312233
*

tests/pos/8313.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Test {
2+
type DU[A <: Tuple] <: Tuple = A match {
3+
case Unit => Unit
4+
case Unit *: tl => DU[tl]
5+
case hd *: tl => hd *: DU[tl]
6+
}
7+
8+
(1, 2): DU[Int *: Int *: Unit]
9+
}

0 commit comments

Comments
 (0)