File tree Expand file tree Collapse file tree 4 files changed +10
-3
lines changed
compiler/src/dotty/tools/dotc/tastyreflect
library/src/scala/tasty/reflect Expand file tree Collapse file tree 4 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -1590,6 +1590,7 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
1590
1590
type Symbol = core.Symbols .Symbol
1591
1591
1592
1592
def Symbol_owner (self : Symbol )(given Context ): Symbol = self.owner
1593
+ def Symbol_maybeOwner (self : Symbol )(given Context ): Symbol = self.maybeOwner
1593
1594
1594
1595
def Symbol_flags (self : Symbol )(given Context ): Flags = self.flags
1595
1596
Original file line number Diff line number Diff line change @@ -1164,9 +1164,12 @@ trait CompilerInterface {
1164
1164
*/
1165
1165
type Symbol <: AnyRef
1166
1166
1167
- /** Owner of this symbol. The owner is the symbol in which this symbol is defined. */
1167
+ /** Owner of this symbol. The owner is the symbol in which this symbol is defined. Throws if this symbol does not have an owner. */
1168
1168
def Symbol_owner (self : Symbol )(given ctx : Context ): Symbol
1169
1169
1170
+ /** Owner of this symbol. The owner is the symbol in which this symbol is defined. Returns `NoSymbol` if this symbol does not have an owner. */
1171
+ def Symbol_maybeOwner (self : Symbol )(given ctx : Context ): Symbol
1172
+
1170
1173
/** Flags of this symbol */
1171
1174
def Symbol_flags (self : Symbol )(given ctx : Context ): Flags
1172
1175
Original file line number Diff line number Diff line change @@ -1228,7 +1228,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
1228
1228
1229
1229
def printAnnotation (annot : Term )(given elideThis : Option [Symbol ]): Buffer = {
1230
1230
val Annotation (ref, args) = annot
1231
- if (annot.symbol.exists && annot.symbol.owner .fullName == " scala.internal.quoted.showName" ) this
1231
+ if (annot.symbol.maybeOwner .fullName == " scala.internal.quoted.showName" ) this
1232
1232
else {
1233
1233
this += " @"
1234
1234
printTypeTree(ref)
Original file line number Diff line number Diff line change @@ -16,9 +16,12 @@ trait SymbolOps extends Core { selfSymbolOps: FlagsOps =>
16
16
17
17
given symbolOps : extension (self : Symbol ) {
18
18
19
- /** Owner of this symbol. The owner is the symbol in which this symbol is defined */
19
+ /** Owner of this symbol. The owner is the symbol in which this symbol is defined. Throws if this symbol does not have an owner. */
20
20
def owner (given ctx : Context ): Symbol = internal.Symbol_owner (self)
21
21
22
+ /** Owner of this symbol. The owner is the symbol in which this symbol is defined. Returns `NoSymbol` if this symbol does not have an owner. */
23
+ def maybeOwner (given ctx : Context ): Symbol = internal.Symbol_maybeOwner (self)
24
+
22
25
/** Flags of this symbol */
23
26
def flags (given ctx : Context ): Flags = internal.Symbol_flags (self)
24
27
You can’t perform that action at this time.
0 commit comments