Skip to content

Commit 51533cd

Browse files
liufengyunmichelou
authored andcommitted
Improve documentatino for Symbol.tree
1 parent 9567678 commit 51533cd

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

library/src/scala/quoted/Quotes.scala

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3460,14 +3460,28 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
34603460
def docstring: Option[String]
34613461

34623462
/** Tree of this definition
3463-
*
3464-
* If this symbol `isClassDef` it will return `a `ClassDef`,
3465-
* if this symbol `isTypeDef` it will return `a `TypeDef`,
3466-
* if this symbol `isValDef` it will return `a `ValDef`,
3467-
* if this symbol `isDefDef` it will return `a `DefDef`
3468-
* if this symbol `isBind` it will return `a `Bind`,
3469-
* else will throw
3470-
*/
3463+
*
3464+
* If this symbol `isClassDef` it will return `a `ClassDef`,
3465+
* if this symbol `isTypeDef` it will return `a `TypeDef`,
3466+
* if this symbol `isValDef` it will return `a `ValDef`,
3467+
* if this symbol `isDefDef` it will return `a `DefDef`
3468+
* if this symbol `isBind` it will return `a `Bind`,
3469+
* else will throw
3470+
*
3471+
* **Warning**: avoid using this method in macros.
3472+
*
3473+
* **Caveat**: The tree is not guaranteed to exist unless the compiler
3474+
* option `-Yretain-trees` is enabled.
3475+
*
3476+
* **Anti-pattern**: The following code is an anti-pattern:
3477+
*
3478+
* symbol.tree.info
3479+
*
3480+
* It should be replaced by the following code:
3481+
*
3482+
* tp.memberType(symbol)
3483+
*
3484+
*/
34713485
def tree: Tree
34723486

34733487
/** Is the annotation defined with `annotSym` attached to this symbol? */

0 commit comments

Comments
 (0)