Skip to content

Commit

Permalink
Deprecate old Symbol member methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Aug 20, 2021
1 parent 821a0e3 commit 88764c5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
18 changes: 6 additions & 12 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3588,16 +3588,14 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
def declaredFields: List[Symbol]

/** Get named non-private fields declared or inherited */
// TODO: deprecate after 3.1.x
// @deprecated("Use fieldMember", "3.2.0")
@deprecated("Use fieldMember", "3.1.0")
def memberField(name: String): Symbol

/** Get named non-private fields declared or inherited */
def fieldMember(name: String): Symbol

/** Get all non-private fields declared or inherited */
// TODO: deprecate after 3.1.x
// @deprecated("Use fieldMembers", "3.2.0")
@deprecated("Use fieldMembers", "3.1.0")
def memberFields: List[Symbol]

/** Get all non-private fields declared or inherited */
Expand All @@ -3610,16 +3608,14 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
def declaredMethods: List[Symbol]

/** Get named non-private methods declared or inherited */
// TODO: deprecate after 3.1.x
// @deprecated("Use methodMember", "3.2.0")
@deprecated("Use methodMember", "3.1.0")
def memberMethod(name: String): List[Symbol]

/** Get named non-private methods declared or inherited */
def methodMember(name: String): List[Symbol]

/** Get all non-private methods declared or inherited */
// TODO: deprecate after 3.1.x
// @deprecated("Use methodMembers", "3.2.0")
@deprecated("Use methodMembers", "3.1.0")
def memberMethods: List[Symbol]

/** Get all non-private methods declared or inherited */
Expand All @@ -3632,16 +3628,14 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
def declaredTypes: List[Symbol]

/** Type member with the given name directly declared in the class */
// TODO: deprecate after 3.1.x
// @deprecated("Use typeMember", "3.2.0")
@deprecated("Use typeMember", "3.1.0")
def memberType(name: String): Symbol

/** Type member with the given name directly declared in the class */
def typeMember(name: String): Symbol

/** Type member directly declared in the class */
// TODO: deprecate after 3.1.x
// @deprecated("Use typeMembers", "3.2.0")
@deprecated("Use typeMembers", "3.1.0")
def memberTypes: List[Symbol]

/** Type member directly declared in the class */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ trait ClassLikeSupport:
}
// TODO check given methods?
case dd: DefDef if !dd.symbol.isHiddenByVisibility && dd.symbol.isGiven && !dd.symbol.isArtifact =>
Some(dd.symbol.owner.memberType(dd.name))
Some(dd.symbol.owner.typeMember(dd.name))
.filterNot(_.exists)
.map { _ =>
parseMethod(c, dd.symbol, specificKind =
Expand Down Expand Up @@ -312,7 +312,7 @@ trait ClassLikeSupport:
case vd: ValDef if !isSyntheticField(vd.symbol) && (!vd.symbol.flags.is(Flags.Case) || !vd.symbol.flags.is(Flags.Enum)) =>
Some(parseValDef(c, vd))

case c: ClassDef if c.symbol.owner.memberMethod(c.name).exists(_.flags.is(Flags.Given)) =>
case c: ClassDef if c.symbol.owner.methodMember(c.name).exists(_.flags.is(Flags.Given)) =>
Some(parseGivenClasslike(c))

case c: ClassDef if c.symbol.shouldDocumentClasslike && !c.symbol.isGiven =>
Expand Down Expand Up @@ -348,7 +348,7 @@ trait ClassLikeSupport:
def inheritance = Some(InheritedFrom(s.symbol.owner.normalizedName, s.symbol.dri))
processTreeOpt(s)(s match
case c: ClassDef if c.symbol.shouldDocumentClasslike && !c.symbol.isGiven => Some(parseClasslike(c, signatureOnly = true))
case c: ClassDef if c.symbol.owner.memberMethod(c.name).exists(_.flags.is(Flags.Given)) => Some(parseGivenClasslike(c))
case c: ClassDef if c.symbol.owner.methodMember(c.name).exists(_.flags.is(Flags.Given)) => Some(parseGivenClasslike(c))
case other => {
val parsed = parseMember(c)(other)
parsed.map(p =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import dotty.tools.scaladoc.tasty.TastyParser
class CommentExpanderTests {
def check(using Quotes)(): Unit =
assertCommentEquals(
reflect.Symbol.requiredClass("tests.B").memberMethod("otherMethod").head,
reflect.Symbol.requiredClass("tests.B").methodMember("otherMethod").head,
"/** This is my foo: Bar, actually. */",
)
assertCommentEquals(
reflect.Symbol.requiredClass("tests.C"),
"/** This is foo: Foo expanded. */",
)
assertCommentEquals(
reflect.Symbol.requiredModule("tests.O").memberMethod("method").head,
reflect.Symbol.requiredModule("tests.O").methodMember("method").head,
"/** This is foo: O's foo. */",
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ class LookupTestCases[Q <: Quotes](val q: Quotes) {
if s.flags.is(q.reflect.Flags.Module) then s.moduleClass else s
Sym(hackResolveModule(symbol.declaredField(name)))
def fun(name: String) =
val List(sym) = symbol.memberMethod(name)
val List(sym) = symbol.methodMember(name)
Sym(sym)
def tpe(name: String) = Sym(symbol.memberType(name))
def tpe(name: String) = Sym(symbol.typeMember(name))
}

def cls(fqn: String) = Sym(q.reflect.Symbol.classSymbol(fqn))
Expand Down

0 comments on commit 88764c5

Please sign in to comment.