diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index d048d8d728d5..fad769793bb7 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -2640,7 +2640,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => // ----- Types ---------------------------------------------------- /** A type, type constructors, type bounds or NoPrefix */ - type TypeRepr + type TypeRepr <: Matchable /** Module object of `type TypeRepr` */ val TypeRepr: TypeReprModule diff --git a/tests/pos/i21282.scala b/tests/pos/i21282.scala new file mode 100644 index 000000000000..a483f3763f89 --- /dev/null +++ b/tests/pos/i21282.scala @@ -0,0 +1,18 @@ +//> using options -Xfatal-warnings -source:future-migration + +import scala.quoted.* + +private def isUnionCanonicalImpl[U: Type](using Quotes): Expr[Unit] = + import quotes.reflect.* + val u = TypeRepr.of[U].dealiasKeepOpaques + + def inner[U: Type](s: Set[TypeRepr], tr: TypeRepr): Set[TypeRepr] = + tr.dealiasKeepOpaques match + case OrType(a, b) => + val ss = inner[U](s, a) + inner[U](ss, b) + case x if s.contains(x) => + report.errorAndAbort(s"Type ${x.show} multiple times (CHECK ALIASES) in union ${u.show}") + case x => s + x + inner(Set.empty, u) + '{ () }