Skip to content

Add TypeBoundsTree and WildcardTypeTree constructors #10435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler/src/scala/quoted/runtime/impl/QuoteContextImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,10 @@ class QuoteContextImpl private (using val ctx: Context) extends QuoteContext, Qu
end TypeBoundsTreeTypeTest

object TypeBoundsTree extends TypeBoundsTreeModule:
def apply(low: TypeTree, hi: TypeTree): TypeBoundsTree =
withDefaultPos(tpd.TypeBoundsTree(low, hi))
def copy(original: Tree)(low: TypeTree, hi: TypeTree): TypeBoundsTree =
tpd.cpy.TypeBoundsTree(original)(low, hi, tpd.EmptyTree)
def unapply(x: TypeBoundsTree): Option[(TypeTree, TypeTree)] =
Some((x.low, x.hi))
end TypeBoundsTree
Expand All @@ -1323,6 +1327,7 @@ class QuoteContextImpl private (using val ctx: Context) extends QuoteContext, Qu
end WildcardTypeTreeTypeTest

object WildcardTypeTree extends WildcardTypeTreeModule:
def apply(tpe: TypeRepr): WildcardTypeTree = withDefaultPos(tpd.Underscore(tpe))
def unapply(x: WildcardTypeTree): Boolean = true
end WildcardTypeTree

Expand Down
8 changes: 6 additions & 2 deletions library/src/scala/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,8 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
val TypeBoundsTree: TypeBoundsTreeModule

trait TypeBoundsTreeModule { this: TypeBoundsTree.type =>
def apply(low: TypeTree, hi: TypeTree): TypeBoundsTree
def copy(original: Tree)(low: TypeTree, hi: TypeTree): TypeBoundsTree
def unapply(x: TypeBoundsTree): Option[(TypeTree, TypeTree)]
}

Expand All @@ -1587,6 +1589,7 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
val WildcardTypeTree: WildcardTypeTreeModule

trait WildcardTypeTreeModule { this: WildcardTypeTree.type =>
def apply(tpe: TypeRepr): WildcardTypeTree
/** Matches a TypeBoundsTree containing wildcard type bounds */
def unapply(x: WildcardTypeTree): Boolean
}
Expand Down Expand Up @@ -3548,8 +3551,9 @@ trait QuoteContext { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
case tree: Statement =>
transformStatement(tree)(owner)
case tree: TypeTree => transformTypeTree(tree)(owner)
case tree: TypeBoundsTree => tree // TODO traverse tree
case tree: WildcardTypeTree => tree // TODO traverse tree
case tree: TypeBoundsTree =>
TypeBoundsTree.copy(tree)(transformTypeTree(tree.low)(owner), transformTypeTree(tree.hi)(owner))
case tree: WildcardTypeTree => tree
case tree: CaseDef =>
transformCaseDef(tree)(owner)
case tree: TypeCaseDef =>
Expand Down