Skip to content

Rename reflection Projection to TypeProjection #10418

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 1 commit into from
Nov 21, 2020
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
22 changes: 11 additions & 11 deletions compiler/src/scala/quoted/internal/impl/QuoteContextImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1056,27 +1056,27 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext, QuoteUnpickl
end extension
end TypeSelectMethodsImpl

type Projection = tpd.Select
type TypeProjection = tpd.Select

object ProjectionTypeTest extends TypeTest[Tree, Projection]:
def unapply(x: Tree): Option[Projection & x.type] = x match
object TypeProjectionTypeTest extends TypeTest[Tree, TypeProjection]:
def unapply(x: Tree): Option[TypeProjection & x.type] = x match
case tpt: (tpd.Select & x.type) if tpt.isType && tpt.qualifier.isType => Some(tpt)
case _ => None
end ProjectionTypeTest
end TypeProjectionTypeTest

object Projection extends ProjectionModule:
def copy(original: Tree)(qualifier: TypeTree, name: String): Projection =
object TypeProjection extends TypeProjectionModule:
def copy(original: Tree)(qualifier: TypeTree, name: String): TypeProjection =
tpd.cpy.Select(original)(qualifier, name.toTypeName)
def unapply(x: Projection): Option[(TypeTree, String)] =
def unapply(x: TypeProjection): Option[(TypeTree, String)] =
Some((x.qualifier, x.name.toString))
end Projection
end TypeProjection

object ProjectionMethodsImpl extends ProjectionMethods:
extension (self: Projection):
object TypeProjectionMethodsImpl extends TypeProjectionMethods:
extension (self: TypeProjection):
def qualifier: TypeTree = self.qualifier
def name: String = self.name.toString
end extension
end ProjectionMethodsImpl
end TypeProjectionMethodsImpl

type Singleton = tpd.SingletonTypeTree

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object Extractors {
this += "TypeIdent(\"" += name += "\")"
case TypeSelect(qualifier, name) =>
this += "TypeSelect(" += qualifier += ", \"" += name += "\")"
case Projection(qualifier, name) =>
case TypeProjection(qualifier, name) =>
this += "Projection(" += qualifier += ", \"" += name += "\")"
case Singleton(ref) =>
this += "Singleton(" += ref += ")"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ object SourceCode {
case TypeSelect(qual, name) =>
printTree(qual) += "." += highlightTypeDef(name)

case Projection(qual, name) =>
case TypeProjection(qual, name) =>
printTypeTree(qual) += "#" += highlightTypeDef(name)

case Singleton(ref) =>
Expand Down
32 changes: 16 additions & 16 deletions library/src/scala/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ trait QuoteContext { self: internal.QuoteUnpickler & internal.QuoteMatching =>
* +- TypeTree ----+- Inferred
* | +- TypeIdent
* | +- TypeSelect
* | +- Projection
* | +- TypeProjection
* | +- Singleton
* | +- Refined
* | +- Applied
Expand Down Expand Up @@ -1323,28 +1323,28 @@ trait QuoteContext { self: internal.QuoteUnpickler & internal.QuoteMatching =>
end TypeSelectMethods

/** Type tree representing a selection of definition with a given name on a given type prefix */
type Projection <: TypeTree
type TypeProjection <: TypeTree

given TypeTest[Tree, Projection] = ProjectionTypeTest
protected val ProjectionTypeTest: TypeTest[Tree, Projection]
given TypeTest[Tree, TypeProjection] = TypeProjectionTypeTest
protected val TypeProjectionTypeTest: TypeTest[Tree, TypeProjection]

val Projection: ProjectionModule
val TypeProjection: TypeProjectionModule

trait ProjectionModule { this: Projection.type =>
trait TypeProjectionModule { this: TypeProjection.type =>
// TODO def apply(qualifier: TypeTree, name: String): Project
def copy(original: Tree)(qualifier: TypeTree, name: String): Projection
def unapply(x: Projection): Option[(TypeTree, String)]
def copy(original: Tree)(qualifier: TypeTree, name: String): TypeProjection
def unapply(x: TypeProjection): Option[(TypeTree, String)]
}

given ProjectionMethods as ProjectionMethods = ProjectionMethodsImpl
protected val ProjectionMethodsImpl: ProjectionMethods
given TypeProjectionMethods as TypeProjectionMethods = TypeProjectionMethodsImpl
protected val TypeProjectionMethodsImpl: TypeProjectionMethods

trait ProjectionMethods:
extension (self: Projection):
trait TypeProjectionMethods:
extension (self: TypeProjection):
def qualifier: TypeTree
def name: String
end extension
end ProjectionMethods
end TypeProjectionMethods

/** Type tree representing a singleton type */
type Singleton <: TypeTree
Expand Down Expand Up @@ -3494,7 +3494,7 @@ trait QuoteContext { self: internal.QuoteUnpickler & internal.QuoteMatching =>
case Inferred() => x
case TypeIdent(_) => x
case TypeSelect(qualifier, _) => foldTree(x, qualifier)(owner)
case Projection(qualifier, _) => foldTree(x, qualifier)(owner)
case TypeProjection(qualifier, _) => foldTree(x, qualifier)(owner)
case Singleton(ref) => foldTree(x, ref)(owner)
case Refined(tpt, refinements) => foldTrees(foldTree(x, tpt)(owner), refinements)(owner)
case Applied(tpt, args) => foldTrees(foldTree(x, tpt)(owner), args)(owner)
Expand Down Expand Up @@ -3646,8 +3646,8 @@ trait QuoteContext { self: internal.QuoteUnpickler & internal.QuoteMatching =>
case tree: TypeIdent => tree
case tree: TypeSelect =>
TypeSelect.copy(tree)(tree.qualifier, tree.name)
case tree: Projection =>
Projection.copy(tree)(tree.qualifier, tree.name)
case tree: TypeProjection =>
TypeProjection.copy(tree)(tree.qualifier, tree.name)
case tree: Annotated =>
Annotated.copy(tree)(tree.arg, tree.annotation)
case tree: Singleton =>
Expand Down