Skip to content

Add Reflection Symbol docs #9983

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
Oct 12, 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
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -733,10 +733,10 @@ object SymDenotations {
originalName.isSetterName &&
(!isCompleted || info.firstParamTypes.nonEmpty) // to avoid being fooled by var x_= : Unit = ...

/** is this a symbol representing an import? */
/** Is this a symbol representing an import? */
final def isImport: Boolean = name == nme.IMPORT

/** is this the constructor of a class? */
/** Is this the constructor of a class? */
final def isClassConstructor: Boolean = name == nme.CONSTRUCTOR

/** Is this the constructor of a trait or a class */
Expand Down
16 changes: 16 additions & 0 deletions library/src/scala/tasty/Reflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2679,14 +2679,30 @@ trait Reflection { reflection =>
/** Annotations attached to this symbol */
def annots: List[Term]

/** Does this symbol come from a currently compiled source file? */
def isDefinedInCurrentRun: Boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be potentially ambiguous, as now the compiler may compile a batch of files in multiple runs to support macros.


/** Dummy val symbol that owns all statements within the initialization of the class.
* This may also contain local definitions such as classes defined in a `locally` block in the class.
*/
def isLocalDummy: Boolean
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding isLocalDummy and isRefinementClass, it would be better to not provide them if they are not useful in practice, as they involve implementation details that might change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should see if we can have an alternative design. We cannot return the owner of the local dummy as that would be ambiguous.


/** Is this symbol a class representing a refinement? */
def isRefinementClass: Boolean

/** Is this symbol an alias type? */
def isAliasType: Boolean

/** Is this symbol an anonymous class? */
def isAnonymousClass: Boolean

/** Is this symbol an anonymous function? */
def isAnonymousFunction: Boolean

/** Is this symbol an abstract type? */
def isAbstractType: Boolean

/** Is this the constructor of a class? */
def isClassConstructor: Boolean

/** Is this the definition of a type? */
Expand Down