Skip to content

Homogenize Reflect.SelectOuter API #9862

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
Sep 24, 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
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/quoted/QuoteContextImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -954,13 +954,14 @@ class QuoteContextImpl private (ctx: Context) extends QuoteContext:
withDefaultPos(tpd.Select(qualifier, NameKinds.OuterSelectName(name.toTermName, levels)))
def copy(original: Tree)(qualifier: Term, name: String, levels: Int): SelectOuter =
tpd.cpy.Select(original)(qualifier, NameKinds.OuterSelectName(name.toTermName, levels))
def unapply(x: SelectOuter): Option[(Term, Int, Type)] = // TODO homogenize order of parameters
Some((x.qualifier, x.level, x.tpe))
def unapply(x: SelectOuter): Option[(Term, String, Int)] =
Some((x.qualifier, x.name.toString, x.level))
end SelectOuter

object SelectOuterMethodsImpl extends SelectOuterMethods:
extension (self: SelectOuter):
def qualifier: Term = self.qualifier
def name: String = self.name.toString
def level: Int =
val NameKinds.OuterSelectName(_, levels) = self.name
levels
Expand Down
3 changes: 2 additions & 1 deletion library/src/scala/tasty/Reflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ trait Reflection { reflection =>
trait SelectOuterModule { this: SelectOuter.type =>
def apply(qualifier: Term, name: String, levels: Int): SelectOuter
def copy(original: Tree)(qualifier: Term, name: String, levels: Int): SelectOuter
def unapply(x: SelectOuter): Option[(Term, Int, Type)] // TODO homogenize order of parameters
def unapply(x: SelectOuter): Option[(Term, String, Int)]
}

given SelectOuterMethods as SelectOuterMethods = SelectOuterMethodsImpl
Expand All @@ -1116,6 +1116,7 @@ trait Reflection { reflection =>
trait SelectOuterMethods:
extension (self: SelectOuter):
def qualifier: Term
def name: String
def level: Int
end extension
end SelectOuterMethods
Expand Down