Skip to content

Commit

Permalink
Fix scala#8313: special case typeparamCorrespondsToField
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierBlanvillain committed Mar 9, 2020
1 parent 435397f commit 36f5e5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2219,13 +2219,15 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
/** Returns last check's debug mode, if explicitly enabled. */
def lastTrace(): String = ""

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

/** Is `tp` an empty type?
*
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/8313.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object Test {
type DU[A <: Tuple] <: Tuple = A match {
case Unit => Unit
case Unit *: tl => DU[tl]
case hd *: tl => hd *: DU[tl]
}

(1, 2): DU[Int *: Int *: Unit]
}

0 comments on commit 36f5e5d

Please sign in to comment.