Skip to content

Commit c3ac0ec

Browse files
author
Adriaan Moors
committed
Merge pull request scala#986 from scalamacros/ticket/6075
SI-6075 cleans up api.StandardNames
2 parents 41ee45e + 2926dfc commit c3ac0ec

File tree

5 files changed

+32
-162
lines changed

5 files changed

+32
-162
lines changed

src/library/scala/reflect/base/Base.scala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class Base extends Universe { self =>
5252
else if (isFreeTerm) "free term"
5353
else if (isTerm) "value"
5454
else "symbol"
55-
// [Eugene++ to Martin] base names should expose `decode`
5655
override def toString() = s"$kindString $name"
5756
}
5857
implicit val SymbolTag = ClassTag[Symbol](classOf[Symbol])
@@ -204,20 +203,22 @@ class Base extends Universe { self =>
204203

205204
object nme extends TermNamesBase {
206205
type NameType = TermName
207-
val EMPTY = newTermName("")
208-
val ROOT = newTermName("<root>")
209-
val EMPTY_PACKAGE_NAME = newTermName("<empty>")
210-
val CONSTRUCTOR = newTermName("<init>")
206+
val WILDCARD = newTermName("_")
207+
val CONSTRUCTOR = newTermName("<init>")
208+
val ROOTPKG = newTermName("_root_")
209+
val EMPTY = newTermName("")
210+
val EMPTY_PACKAGE_NAME = newTermName("<empty>")
211+
val ROOT = newTermName("<root>")
211212
val NO_NAME = newTermName("<none>")
212-
val WILDCARD = newTermName("_")
213213
}
214214

215215
object tpnme extends TypeNamesBase {
216216
type NameType = TypeName
217-
val EMPTY = nme.EMPTY.toTypeName
218-
val ROOT = nme.ROOT.toTypeName
219-
val EMPTY_PACKAGE_NAME = nme.EMPTY_PACKAGE_NAME.toTypeName
220-
val WILDCARD = nme.WILDCARD.toTypeName
217+
val WILDCARD = nme.WILDCARD.toTypeName
218+
val EMPTY = nme.EMPTY.toTypeName
219+
val WILDCARD_STAR = newTypeName("_*")
220+
val EMPTY_PACKAGE_NAME = nme.EMPTY_PACKAGE_NAME.toTypeName
221+
val ROOT = nme.ROOT.toTypeName
221222
}
222223

223224
type FlagSet = Long

src/library/scala/reflect/base/StandardNames.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
package scala.reflect
77
package base
88

9+
// Q: I have a pretty name. Where do I put it - into base.StandardNames or into api.StandardNames?
10+
// A: Is it necessary to construct trees (like EMPTY or WILDCARD_STAR)? If yes, then it goes to base.StandardNames.
11+
// Is it necessary to perform reflection (like ERROR or LOCAL_SUFFIX_STRING)? If yes, then it goes to api.StandardNames.
12+
// Otherwise it goes nowhere - reflection API should stay minimalistic.
13+
914
trait StandardNames {
1015
self: Universe =>
1116

@@ -14,16 +19,16 @@ trait StandardNames {
1419

1520
trait NamesBase {
1621
type NameType >: Null <: Name
17-
val EMPTY: NameType
18-
val ROOT: NameType
19-
val EMPTY_PACKAGE_NAME: NameType
2022
val WILDCARD: NameType
2123
}
2224

23-
trait TypeNamesBase extends NamesBase
24-
2525
trait TermNamesBase extends NamesBase {
2626
val CONSTRUCTOR: TermName
27-
val NO_NAME: NameType
27+
val ROOTPKG: TermName
28+
}
29+
30+
trait TypeNamesBase extends NamesBase {
31+
val EMPTY: NameType
32+
val WILDCARD_STAR: NameType
2833
}
2934
}

src/reflect/scala/reflect/api/Names.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ trait Names extends base.Names {
2020
*/
2121
abstract class NameApi extends NameBase {
2222

23-
// [Eugene++] this functionality should be in base
24-
// this is because stuff will be reified in mangled state, and people will need a way to figure it out
25-
2623
/** Replaces all occurrences of \$op_names in this name by corresponding operator symbols.
2724
* Example: `foo_\$plus\$eq` becomes `foo_+=`
2825
*/

src/reflect/scala/reflect/api/StandardNames.scala

Lines changed: 4 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -5,158 +5,26 @@
55
package scala.reflect
66
package api
77

8+
// Q: I have a pretty name. Where do I put it - into base.StandardNames or into api.StandardNames?
9+
// A: <see base.StandardNames>
10+
811
trait StandardNames extends base.StandardNames {
912
self: Universe =>
1013

1114
val nme: TermNamesApi
1215
val tpnme: TypeNamesApi
1316

1417
trait NamesApi extends NamesBase {
15-
val ANON_CLASS_NAME: NameType
16-
val ANON_FUN_NAME: NameType
18+
val ROOT: NameType
1719
val EMPTY: NameType
1820
val ERROR: NameType
19-
val IMPORT: NameType
20-
val MODULE_VAR_SUFFIX: NameType
2121
val PACKAGE: NameType
22-
val ROOT: NameType
23-
val SPECIALIZED_SUFFIX: NameType
24-
25-
def flattenedName(segments: Name*): NameType
2622
}
2723

2824
trait TermNamesApi extends NamesApi with TermNamesBase {
29-
val EXPAND_SEPARATOR_STRING: String
30-
val IMPL_CLASS_SUFFIX: String
31-
val INTERPRETER_IMPORT_WRAPPER: String
32-
val INTERPRETER_LINE_PREFIX: String
33-
val INTERPRETER_VAR_PREFIX: String
34-
val INTERPRETER_WRAPPER_SUFFIX: String
35-
val LOCALDUMMY_PREFIX: String
3625
val LOCAL_SUFFIX_STRING: String
37-
val MODULE_SUFFIX_NAME: TermName
38-
val NAME_JOIN_NAME: TermName
39-
val PROTECTED_PREFIX: String
40-
val PROTECTED_SET_PREFIX: String
41-
val SETTER_SUFFIX: TermName
42-
val SINGLETON_SUFFIX: String
43-
val SUPER_PREFIX_STRING: String
44-
val TRAIT_SETTER_SEPARATOR_STRING: String
45-
46-
val FAKE_LOCAL_THIS: TermName
47-
val INITIALIZER: TermName
48-
val LAZY_LOCAL: TermName
49-
val UNIVERSE_BUILD: NameType
50-
val UNIVERSE_BUILD_PREFIX: NameType
51-
val UNIVERSE_PREFIX: NameType
52-
val UNIVERSE_SHORT: NameType
53-
val MIRROR_PREFIX: NameType
54-
val MIRROR_SHORT: NameType
55-
val MIRROR_UNTYPED: NameType
56-
val REIFY_FREE_PREFIX: NameType
57-
val REIFY_FREE_THIS_SUFFIX: NameType
58-
val REIFY_FREE_VALUE_SUFFIX: NameType
59-
val REIFY_SYMDEF_PREFIX: NameType
60-
val MIXIN_CONSTRUCTOR: TermName
61-
val MODULE_INSTANCE_FIELD: TermName
62-
val OUTER: TermName
63-
val OUTER_LOCAL: TermName
64-
val OUTER_SYNTH: TermName
65-
val SELECTOR_DUMMY: TermName
66-
val SELF: TermName
67-
val SPECIALIZED_INSTANCE: TermName
68-
val STAR: TermName
69-
val THIS: TermName
70-
71-
val BITMAP_NORMAL: TermName
72-
val BITMAP_TRANSIENT: TermName
73-
val BITMAP_CHECKINIT: TermName
74-
val BITMAP_CHECKINIT_TRANSIENT: TermName
75-
76-
val ROOTPKG: TermName
77-
78-
val ADD: TermName
79-
val AND: TermName
80-
val ASR: TermName
81-
val DIV: TermName
82-
val EQ: TermName
83-
val EQL: TermName
84-
val GE: TermName
85-
val GT: TermName
86-
val HASHHASH: TermName
87-
val LE: TermName
88-
val LSL: TermName
89-
val LSR: TermName
90-
val LT: TermName
91-
val MINUS: TermName
92-
val MOD: TermName
93-
val MUL: TermName
94-
val NE: TermName
95-
val OR: TermName
96-
val PLUS : TermName
97-
val SUB: TermName
98-
val XOR: TermName
99-
val ZAND: TermName
100-
val ZOR: TermName
101-
102-
val UNARY_~ : TermName
103-
val UNARY_+ : TermName
104-
val UNARY_- : TermName
105-
val UNARY_! : TermName
106-
107-
val ??? : TermName
108-
109-
def isConstructorName(name: Name): Boolean
110-
def isExceptionResultName(name: Name): Boolean
111-
def isImplClassName(name: Name): Boolean
112-
def isLocalDummyName(name: Name): Boolean
113-
def isLocalName(name: Name): Boolean
114-
def isLoopHeaderLabel(name: Name): Boolean
115-
def isModuleName(name: Name): Boolean
116-
def isOpAssignmentName(name: Name): Boolean
117-
def isProtectedAccessorName(name: Name): Boolean
118-
def isReplWrapperName(name: Name): Boolean
119-
def isSetterName(name: Name): Boolean
120-
def isSingletonName(name: Name): Boolean
121-
def isSuperAccessorName(name: Name): Boolean
122-
def isTraitSetterName(name: Name): Boolean
123-
124-
def defaultGetterName(name: Name, pos: Int): TermName
125-
def defaultGetterToMethod(name: Name): TermName
126-
def expandedName(name: TermName, base: Symbol, separator: String): TermName
127-
def expandedSetterName(name: TermName, base: Symbol): TermName
128-
def getterName(name: TermName): TermName
129-
def getterToLocal(name: TermName): TermName
130-
def getterToSetter(name: TermName): TermName
131-
def localDummyName(clazz: Symbol): TermName
132-
def localToGetter(name: TermName): TermName
133-
def protName(name: Name): TermName
134-
def protSetterName(name: Name): TermName
135-
def setterToGetter(name: TermName): TermName
136-
def superName(name: Name): TermName
137-
138-
def dropLocalSuffix(name: Name): Name
139-
def originalName(name: Name): Name
140-
def stripModuleSuffix(name: Name): Name
141-
def unspecializedName(name: Name): Name
142-
def segments(name: String, assumeTerm: Boolean): List[Name]
143-
def splitSpecializedName(name: Name): (Name, String, String)
14426
}
14527

14628
trait TypeNamesApi extends NamesApi with TypeNamesBase {
147-
val BYNAME_PARAM_CLASS_NAME: TypeName
148-
val EQUALS_PATTERN_NAME: TypeName
149-
val JAVA_REPEATED_PARAM_CLASS_NAME: TypeName
150-
val LOCAL_CHILD: TypeName
151-
val REFINE_CLASS_NAME: TypeName
152-
val REPEATED_PARAM_CLASS_NAME: TypeName
153-
val WILDCARD_STAR: TypeName
154-
val REIFY_TYPECREATOR_PREFIX: NameType
155-
val REIFY_TREECREATOR_PREFIX: NameType
156-
157-
def dropSingletonName(name: Name): TypeName
158-
def implClassName(name: Name): TypeName
159-
def interfaceName(implname: Name): TypeName
160-
def singletonName(name: Name): TypeName
16129
}
16230
}

src/reflect/scala/reflect/internal/Printers.scala

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -649,19 +649,18 @@ trait Printers extends api.Printers { self: SymbolTable =>
649649
}
650650

651651
def show(name: Name): String = name match {
652-
// base.StandardNames
653652
case tpnme.EMPTY => "tpnme.EMPTY"
654653
case tpnme.ROOT => "tpnme.ROOT"
654+
case tpnme.PACKAGE => "tpnme.PACKAGE"
655655
case tpnme.EMPTY_PACKAGE_NAME => "tpnme.EMPTY_PACKAGE_NAME"
656656
case tpnme.WILDCARD => "tpnme.WILDCARD"
657-
case nme.CONSTRUCTOR => "nme.CONSTRUCTOR"
658-
case nme.NO_NAME => "nme.NO_NAME"
659-
// api.StandardNames
660-
case tpnme.ERROR => "tpnme.ERROR"
661-
case nme.ERROR => "nme.ERROR"
662657
case nme.EMPTY => "nme.EMPTY"
663-
case tpnme.PACKAGE => "tpnme.PACKAGE"
658+
case nme.ROOT => "nme.ROOT"
664659
case nme.PACKAGE => "nme.PACKAGE"
660+
case nme.EMPTY_PACKAGE_NAME => "nme.EMPTY_PACKAGE_NAME"
661+
case nme.WILDCARD => "nme.WILDCARD"
662+
case nme.CONSTRUCTOR => "nme.CONSTRUCTOR"
663+
case nme.ROOTPKG => "nme.ROOTPKG"
665664
case _ =>
666665
val prefix = if (name.isTermName) "newTermName(\"" else "newTypeName(\""
667666
prefix + name.toString + "\")"

0 commit comments

Comments
 (0)