Skip to content

Commit 67e3bb5

Browse files
committed
Add doc to Ref.apply
1 parent a73f2b8 commit 67e3bb5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

library/src/scala/tasty/reflect/TreeOps.scala

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,22 @@ trait TreeOps extends Core {
241241

242242
object Ref {
243243

244-
/** Create a reference tree */
244+
/** Create a reference tree from a symbol
245+
*
246+
* If `sym` refers to a class member `foo` in class `C`,
247+
* returns a tree representing `C.this.foo`.
248+
*
249+
* If `sym` refers to a local definition `foo`, returns
250+
* a tree representing `foo`.
251+
*
252+
* @note In both cases, the constructed tree should only
253+
* be spliced into the places where such accesses make sense.
254+
* For example, it is incorrect to have `C.this.foo` outside
255+
* the class body of `C`, or have `foo` outside the lexical
256+
* scope for the definition of `foo`.
257+
*/
245258
def apply(sym: Symbol)(given ctx: Context): Ref =
246259
internal.Ref_apply(sym)
247-
248-
// TODO def copy(original: Tree)(name: String)(given ctx: Context): Ref
249-
250260
}
251261

252262
given (given Context): IsInstanceOf[Ident] = internal.isInstanceOfIdent

0 commit comments

Comments
 (0)