From 1ea171d322dd2b7e9487763a1e6c23bd4c01e6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Thu, 26 Aug 2021 16:12:02 +0200 Subject: [PATCH 1/3] Add TypeRepr.memberInfo, Symbol.tpe, Symbol.typeParams to reflection API --- compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala | 4 ++++ library/src/scala/quoted/Quotes.scala | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala index 2d3f5490563c..eef4f3942f7b 100644 --- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala +++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala @@ -1743,6 +1743,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler dotc.core.Types.decorateTypeApplications(self).appliedTo(targ) def appliedTo(targs: List[TypeRepr]): TypeRepr = dotc.core.Types.decorateTypeApplications(self).appliedTo(targs) + def memberInfo(sym: Symbol): TypeRepr = + self.memberInfo(sym) end extension end TypeReprMethods @@ -2610,6 +2612,8 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler def companionClass: Symbol = self.denot.companionClass def companionModule: Symbol = self.denot.companionModule def children: List[Symbol] = self.denot.children + def tpe: TypeRepr = self.typeRef + def typeParams: List[Symbol] = self.denot.typeParams def show(using printer: Printer[Symbol]): String = printer.show(self) diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala index e6f229676d34..bff654641f13 100644 --- a/library/src/scala/quoted/Quotes.scala +++ b/library/src/scala/quoted/Quotes.scala @@ -2535,6 +2535,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** The current type applied to given type arguments: `this[targ0, ..., targN]` */ def appliedTo(targs: List[TypeRepr]): TypeRepr + /** Member info of `sym` as seen from the TypeRepr */ + def memberInfo(sym: Symbol): TypeRepr + end extension } @@ -3741,6 +3744,12 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching => /** Case class or case object children of a sealed trait or cases of an `enum`. */ def children: List[Symbol] + + /** Type of the symbol */ + def tpe: TypeRepr + + /** Type parameters of the symbol */ + def typeParams: List[Symbol] end extension } From 87eb26b1362a987cac51095d6dd847abaacb821e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Thu, 26 Aug 2021 16:12:18 +0200 Subject: [PATCH 2/3] Update MiMa filters --- project/MiMaFilters.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/project/MiMaFilters.scala b/project/MiMaFilters.scala index 697f0bca662b..38fac32744b6 100644 --- a/project/MiMaFilters.scala +++ b/project/MiMaFilters.scala @@ -18,5 +18,8 @@ object MiMaFilters { exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule.TypedOrTestTypeTest"), exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule.TypedOrTest"), exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule.TypedOrTestMethods"), + exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TypeReprMethods.memberInfo"), + exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.tpe"), + exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.typeParams"), ) } From 51735bd177dd02b0a90d75ad61a96fbc4d173549 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Zyba=C5=82a?= Date: Thu, 26 Aug 2021 16:12:52 +0200 Subject: [PATCH 3/3] Use reflection API methods in Scaladoc --- .../src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala index bbf737464eff..8292b4ecd37c 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala @@ -88,7 +88,9 @@ trait ClassLikeSupport: val tpe = valdef.tpt.tpe LinkToType(tpe.asSignature, symbol.dri, Kind.Type(false, false, Seq.empty)) } - val selfSignature: DSignature = typeForClass(classDef).asSignature + val selfSignature: DSignature = classDef.symbol.tpe + .appliedTo(classDef.symbol.typeParams.map(_.tpe)) + .asSignature val graph = HierarchyGraph.withEdges( getSupertypesGraph(classDef, LinkToType(selfSignature, classDef.symbol.dri, bareClasslikeKind(classDef.symbol))) @@ -631,7 +633,7 @@ trait ClassLikeSupport: def unwrapMemberInfo(c: ClassDef, symbol: Symbol): MemberInfo = - val baseTypeRepr = memberInfo(c, symbol) + val baseTypeRepr = c.symbol.tpe.memberInfo(symbol) def isSyntheticEvidence(name: String) = if !name.startsWith(NameKinds.EvidenceParamName.separator) then false else