Skip to content

Commit

Permalink
Bound TypeRepr by Matchable in Quotes (#21377)
Browse files Browse the repository at this point in the history
Closes #21282
  • Loading branch information
hamzaremmal authored Aug 19, 2024
2 parents 99f431e + 05966dc commit b64afad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions tests/pos/i21282.scala
Original file line number Diff line number Diff line change
@@ -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)
'{ () }

0 comments on commit b64afad

Please sign in to comment.