diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 0a26ea697a6a..5162b3fed1b9 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -661,15 +661,9 @@ trait ImplicitRunInfo: case t: TypeLambda => for p <- t.paramRefs do partSeen += p traverseChildren(t) - case t: MatchType => - traverseChildren(t) - traverse(t.normalized) - case MatchType.InDisguise(mt) - if !t.isInstanceOf[LazyRef] // skip recursive applications (eg. Tuple.Map) - => - traverse(mt) case t => traverseChildren(t) + traverse(t.normalized) catch case ex: Throwable => handleRecursive("collectParts of", t.show, ex) def apply(tp: Type): collection.Set[Type] = diff --git a/tests/pos/i17395-spec.ordered.scala b/tests/pos/i17395-spec.ordered.scala new file mode 100644 index 000000000000..6e6ae8dd1e59 --- /dev/null +++ b/tests/pos/i17395-spec.ordered.scala @@ -0,0 +1,17 @@ +trait ThingWithPart { type Part } +type PartField[A] = ThingWithPart { type Part = A } +type ExtractPart[B] = B match { case PartField[a] => a } + +trait TC[C] +object TC: + def tcForOptionPart[D](implicit tc: TC[ExtractPart[D]]): TC[Option[ExtractPart[D]]] = new {} + +class Value +object Value: + implicit val tcValue: TC[Value] = new {} + +class ValuePartHolder extends ThingWithPart { type Part = Value } + +class Test: + def t1: Unit = + val tc = TC.tcForOptionPart[ValuePartHolder] diff --git a/tests/pos/i19857.scala b/tests/pos/i19857.scala new file mode 100644 index 000000000000..aeb6e49111c6 --- /dev/null +++ b/tests/pos/i19857.scala @@ -0,0 +1,23 @@ +sealed trait DFTypeAny + +sealed trait DFTuple[T <: NonEmptyTuple] extends DFTypeAny + +sealed trait DFBit extends DFTypeAny + +sealed trait DFValOf[T] + +type Of[T] <: DFTypeAny = T match + case DFTypeAny => T & DFTypeAny + case Product => FromProduct[T] + +type JUSTVAL[T] = DFValOf[Of[T]] + +type FromProduct[T <: Product] <: DFTypeAny = T match + case NonEmptyTuple => DFTuple[Tuple.Map[T, JUSTVAL]] + +trait Width2[T] + +object Width2: + inline given [T]: Width2[T] = new Width2[T] {} + +val x = summon[Width2[Of[(DFBit, DFBit)]]]