-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use symbol instead of definition tree in TASTy reflect #4991
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
nicolasstucki
merged 6 commits into
scala:master
from
dotty-staging:use-tasty-reflect-symbols
Aug 24, 2018
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d492a1f
Use symbol instead of definition tree
nicolasstucki af339b3
Use more conditions on symbols
nicolasstucki 2ee909f
Use Symbol in SymRef in TASTy reflect
nicolasstucki 17b1be4
Move methods from Definition to Symbol
nicolasstucki 18bb14c
Use Symbols instead of Definitions in StandardDefinitions
nicolasstucki 0d726cc
Rename isEmpty to exists
nicolasstucki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 38 additions & 3 deletions
41
compiler/src/dotty/tools/dotc/tastyreflect/SymbolOpsImpl.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,49 @@ | ||
package dotty.tools.dotc.tastyreflect | ||
package dotty.tools.dotc | ||
package tastyreflect | ||
|
||
import dotty.tools.dotc.core.Symbols._ | ||
|
||
trait SymbolOpsImpl extends scala.tasty.reflect.SymbolOps with TastyCoreImpl { | ||
|
||
def SymbolDeco(symbol: Symbol): SymbolAPI = new SymbolAPI { | ||
def isEmpty: Boolean = symbol eq NoSymbol | ||
def localContext(implicit ctx: Context): Context = ctx.withOwner(symbol) | ||
|
||
def isEmpty(implicit ctx: Context): Boolean = symbol eq NoSymbol | ||
def isClass(implicit ctx: Context): Boolean = symbol.isClass | ||
|
||
def flags(implicit ctx: Context): FlagSet = new FlagSet(symbol.flags) | ||
|
||
def privateWithin(implicit ctx: Context): Option[Type] = { | ||
val within = symbol.privateWithin | ||
if (within.exists && !symbol.is(core.Flags.Protected)) Some(within.typeRef) | ||
else None | ||
} | ||
|
||
def protectedWithin(implicit ctx: Context): Option[Type] = { | ||
val within = symbol.privateWithin | ||
if (within.exists && symbol.is(core.Flags.Protected)) Some(within.typeRef) | ||
else None | ||
} | ||
|
||
def name(implicit ctx: Context): String = symbol.name.toString | ||
def fullName(implicit ctx: Context): String = symbol.fullName.toString | ||
|
||
def owner(implicit ctx: Context): Symbol = symbol.owner | ||
|
||
def localContext(implicit ctx: Context): Context = { | ||
if (symbol.exists) ctx.withOwner(symbol) | ||
else ctx | ||
} | ||
|
||
def tree(implicit ctx: Context): Option[Definition] = | ||
if (isEmpty) None else Some(FromSymbol.definitionFromSym(symbol)) | ||
|
||
def annots(implicit ctx: Context): List[Term] = { | ||
symbol.annotations.flatMap { | ||
case _: core.Annotations.LazyBodyAnnotation => Nil | ||
case annot => annot.tree :: Nil | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename it to
exists
? Not important, somehow I feelexists
is more friendly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed