@@ -6,33 +6,51 @@ package macros
66 * <span class="badge badge-red" style="float: right;">EXPERIMENTAL</span>
77 *
88 * A slice of [[scala.reflect.macros.blackbox.Context the Scala macros context ]] that
9- * provides functions that generate unique names.
9+ * provides functions that generate fresh names.
10+ *
11+ * In the current implementation, fresh names are more or less unique in the sense that
12+ * within the same compilation run they are guaranteed not to clash with:
13+ * 1) Results of past and future invocations of functions of `freshName` family
14+ * 2) User-defined or macro-generated names that don't contain dollar symbols
15+ * 3) Macro-generated names that are created by concatenating names from the first, second and third categories
16+ *
17+ * Uniqueness of fresh names across compilation runs is not guaranteed, but that's something
18+ * that we would like to improve upon in future releases. See [[https://issues.scala-lang.org/browse/SI-6879 ]] for more information.
19+ *
20+ * @define freshNameNoParams
21+ * Creates a string that represents a more or less unique name.
22+ * Consult [[scala.reflect.macros.Names ]] for more information on uniqueness of such names.
23+ *
24+ * @define freshNameStringParam
25+ * Creates a string that represents a more or less unique name having a given prefix.
26+ * Consult [[scala.reflect.macros.Names ]] for more information on uniqueness of such names.
27+ *
28+ * @define freshNameNameParam
29+ * Creates a more or less unique name having a given name as a prefix and
30+ * having the same flavor (term name or type name) as the given name.
31+ * Consult [[scala.reflect.macros.Names ]] for more information on uniqueness of such names.
1032 */
1133trait Names {
1234 self : blackbox.Context =>
1335
14- /** Creates a unique string. */
36+ /** $freshNameNoParams */
1537 @ deprecated(" Use freshName instead" , " 2.11.0" )
1638 def fresh (): String
1739
18- /** Creates a unique string having a given prefix. */
40+ /** $freshNameStringParam */
1941 @ deprecated(" Use freshName instead" , " 2.11.0" )
2042 def fresh (name : String ): String
2143
22- /** Creates a unique name having a given name as a prefix and
23- * having the same flavor (term name or type name) as the given name.
24- */
44+ /** $freshNameNameParam */
2545 @ deprecated(" Use freshName instead" , " 2.11.0" )
2646 def fresh [NameType <: Name ](name : NameType ): NameType
2747
28- /** Creates a unique string. */
48+ /** $freshNameNoParams */
2949 def freshName (): String
3050
31- /** Creates a unique string having a given prefix. */
51+ /** $freshNameStringParam */
3252 def freshName (name : String ): String
3353
34- /** Creates a unique name having a given name as a prefix and
35- * having the same flavor (term name or type name) as the given name.
36- */
54+ /** $freshNameNameParam */
3755 def freshName [NameType <: Name ](name : NameType ): NameType
3856}
0 commit comments