Skip to content

Commit b64afad

Browse files
authored
Bound TypeRepr by Matchable in Quotes (#21377)
Closes #21282
2 parents 99f431e + 05966dc commit b64afad

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

library/src/scala/quoted/Quotes.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2640,7 +2640,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
26402640
// ----- Types ----------------------------------------------------
26412641

26422642
/** A type, type constructors, type bounds or NoPrefix */
2643-
type TypeRepr
2643+
type TypeRepr <: Matchable
26442644

26452645
/** Module object of `type TypeRepr` */
26462646
val TypeRepr: TypeReprModule

tests/pos/i21282.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//> using options -Xfatal-warnings -source:future-migration
2+
3+
import scala.quoted.*
4+
5+
private def isUnionCanonicalImpl[U: Type](using Quotes): Expr[Unit] =
6+
import quotes.reflect.*
7+
val u = TypeRepr.of[U].dealiasKeepOpaques
8+
9+
def inner[U: Type](s: Set[TypeRepr], tr: TypeRepr): Set[TypeRepr] =
10+
tr.dealiasKeepOpaques match
11+
case OrType(a, b) =>
12+
val ss = inner[U](s, a)
13+
inner[U](ss, b)
14+
case x if s.contains(x) =>
15+
report.errorAndAbort(s"Type ${x.show} multiple times (CHECK ALIASES) in union ${u.show}")
16+
case x => s + x
17+
inner(Set.empty, u)
18+
'{ () }

0 commit comments

Comments
 (0)