Skip to content

Improve documentation underlyingArgument #14619

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
Mar 16, 2022
Merged
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
14 changes: 12 additions & 2 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -699,10 +699,20 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** TypeRepr of this term */
def tpe: TypeRepr

/** Replace Inlined nodes and InlineProxy references to underlying arguments */
/** Replace Inlined nodes and InlineProxy references to underlying arguments.
* The resulting tree is useful for inspection of the value or content of a non-inline argument.
*
* Warning: This tree may contain references that are out of scope and should not be used in the generated code.
* This method should only used to port Scala 2 that used to access their outer scope unsoundly.
Copy link
Member

Choose a reason for hiding this comment

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

But it's safe to use this method for macros that don't splice the underlying argument anywhere, right?
Also, it'd be helpful to have an example showing what people should write instead of using underlying/underlyingArgument, because it's not clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, it'd be helpful to have an example showing what people should write instead of using underlying/underlyingArgument, because it's not clear to me.

That is basically all the text in the macro tutorial related to inline arguments, value extraction and quote pattern matching.

*/
def underlyingArgument: Term

/** Replace Ident nodes references to the underlying tree that defined them */
/** Replace Ident nodes references to the underlying tree that defined them.
* The resulting tree is useful for inspection of the definition of some bindings.
*
* Warning: This tree may contain references that are out of scope and should not be used in the generated code.
* This method should only used to port Scala 2 that used to access their outer scope unsoundly.
*/
def underlying: Term

/** Converts a partially applied term into a lambda expression */
Expand Down