Skip to content

Commit e52ad28

Browse files
committed
Cleanups of NameOps
Remove unused functionality
1 parent 9cd486c commit e52ad28

File tree

6 files changed

+15
-100
lines changed

6 files changed

+15
-100
lines changed

compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ import Decorators._
3030
import tpd._
3131

3232
import scala.tools.asm
33-
import NameOps._
3433
import StdNames.nme
3534
import NameOps._
35+
import NameKinds.DefaultGetterName
3636
import dotty.tools.dotc.core
3737
import dotty.tools.dotc.core.Names.TypeName
3838

@@ -255,7 +255,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
255255
val evalue = t.symbol.name.toString // value the actual enumeration value.
256256
av.visitEnum(name, edesc, evalue)
257257
} else {
258-
assert(toDenot(t.symbol).name.toTermName.defaultGetterIndex >= 0) // this should be default getter. do not emmit.
258+
assert(toDenot(t.symbol).name.is(DefaultGetterName)) // this should be default getter. do not emmit.
259259
}
260260
case t: SeqLiteral =>
261261
val arrAnnotV: AnnotationVisitor = av.visitArray(name)

compiler/src/dotty/tools/dotc/core/NameOps.scala

-79
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ object NameOps {
6161
def isReplWrapperName = name.toSimpleName containsSlice INTERPRETER_IMPORT_WRAPPER
6262
def isSetterName = name endsWith SETTER_SUFFIX
6363
def isScala2LocalSuffix = name.endsWith(" ")
64-
def isModuleVarName(name: Name): Boolean = name.exclude(UniqueName).is(ModuleVarName)
6564
def isSelectorName = name.startsWith("_") && name.tail.forall(_.isDigit)
6665

6766
/** Is name a variable name? */
@@ -105,9 +104,6 @@ object NameOps {
105104
else name.toTermName.exclude(AvoidClashName)
106105
}
107106

108-
/** The superaccessor for method with given name */
109-
def superName: TermName = SuperAccessorName(name.toTermName)
110-
111107
def expandedName(base: Symbol, kind: QualifiedNameKind = ExpandedName)(implicit ctx: Context): N = {
112108
val prefix =
113109
if (base.name.is(ExpandedName)) base.name else base.fullNameSeparated(ExpandPrefixName)
@@ -274,17 +270,6 @@ object NameOps {
274270
}
275271
}
276272

277-
// needed???
278-
private val Boxed = Map[TypeName, TypeName](
279-
tpnme.Boolean -> jtpnme.BoxedBoolean,
280-
tpnme.Byte -> jtpnme.BoxedByte,
281-
tpnme.Char -> jtpnme.BoxedCharacter,
282-
tpnme.Short -> jtpnme.BoxedShort,
283-
tpnme.Int -> jtpnme.BoxedInteger,
284-
tpnme.Long -> jtpnme.BoxedLong,
285-
tpnme.Float -> jtpnme.BoxedFloat,
286-
tpnme.Double -> jtpnme.BoxedDouble)
287-
288273
implicit class TermNameDecorator(val name: TermName) extends AnyVal {
289274
import nme._
290275

@@ -305,18 +290,6 @@ object NameOps {
305290
}
306291
else FieldName(name)
307292

308-
/** Nominally, name from name$default$N, CONSTRUCTOR for <init> */
309-
def defaultGetterToMethod: TermName =
310-
name rewrite {
311-
case DefaultGetterName(methName, _) => methName
312-
}
313-
314-
/** If this is a default getter, its index (starting from 0), else -1 */
315-
def defaultGetterIndex: Int =
316-
name collect {
317-
case DefaultGetterName(_, num) => num
318-
} getOrElse -1
319-
320293
def stripScala2LocalSuffix: TermName =
321294
if (name.isScala2LocalSuffix) name.init.asTermName else name
322295

@@ -328,57 +301,5 @@ object NameOps {
328301
case raw.BANG => UNARY_!
329302
case _ => name
330303
}
331-
332-
/** The name of a method which stands in for a primitive operation
333-
* during structural type dispatch.
334-
*/
335-
def primitiveInfixMethodName: TermName = name match {
336-
case OR => takeOr
337-
case XOR => takeXor
338-
case AND => takeAnd
339-
case EQ => testEqual
340-
case NE => testNotEqual
341-
case ADD => add
342-
case SUB => subtract
343-
case MUL => multiply
344-
case DIV => divide
345-
case MOD => takeModulo
346-
case LSL => shiftSignedLeft
347-
case LSR => shiftLogicalRight
348-
case ASR => shiftSignedRight
349-
case LT => testLessThan
350-
case LE => testLessOrEqualThan
351-
case GE => testGreaterOrEqualThan
352-
case GT => testGreaterThan
353-
case ZOR => takeConditionalOr
354-
case ZAND => takeConditionalAnd
355-
case _ => NO_NAME
356-
}
357-
358-
/** Postfix/prefix, really.
359-
*/
360-
def primitivePostfixMethodName: TermName = name match {
361-
case UNARY_! => takeNot
362-
case UNARY_+ => positive
363-
case UNARY_- => negate
364-
case UNARY_~ => complement
365-
case `toByte` => toByte
366-
case `toShort` => toShort
367-
case `toChar` => toCharacter
368-
case `toInt` => toInteger
369-
case `toLong` => toLong
370-
case `toFloat` => toFloat
371-
case `toDouble` => toDouble
372-
case _ => NO_NAME
373-
}
374-
375-
def primitiveMethodName: TermName =
376-
primitiveInfixMethodName match {
377-
case NO_NAME => primitivePostfixMethodName
378-
case name => name
379-
}
380304
}
381-
382-
private final val FalseSuper = "$$super".toTermName
383-
private val FalseSuperLength = FalseSuper.length
384305
}

compiler/src/dotty/tools/dotc/core/StdNames.scala

-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ object StdNames {
252252
val REIFY_SYMDEF_PREFIX: N = "symdef$"
253253
val MODULE_INSTANCE_FIELD: N = NameTransformer.MODULE_INSTANCE_NAME // "MODULE$"
254254
val OUTER: N = "$outer"
255-
val OUTER_LOCAL: N = "$outer "
256255
val REFINE_CLASS: N = "<refinement>"
257256
val ROOTPKG: N = "_root_"
258257
val SELECTOR_DUMMY: N = "<unapply-selector>"

compiler/src/dotty/tools/dotc/transform/SuperAccessors.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Types._, Contexts._, Constants._, Names._, NameOps._, Flags._, DenotTrans
1111
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._, Scopes._, Denotations._
1212
import util.Positions._
1313
import Decorators._
14-
import NameKinds.{ProtectedAccessorName, ProtectedSetterName, OuterSelectName}
14+
import NameKinds.{ProtectedAccessorName, ProtectedSetterName, OuterSelectName, SuperAccessorName}
1515
import Symbols._, TypeUtils._
1616

1717
/** This class performs the following functions:
@@ -72,7 +72,7 @@ class SuperAccessors(thisTransformer: DenotTransformer) {
7272
val Select(qual, name) = sel
7373
val sym = sel.symbol
7474
val clazz = qual.symbol.asClass
75-
var superName = name.superName
75+
var superName = SuperAccessorName(name.asTermName)
7676
if (clazz is Trait) superName = superName.expandedName(clazz)
7777
val superInfo = sel.tpe.widenSingleton.ensureMethodic
7878

compiler/src/dotty/tools/dotc/typer/Namer.scala

+4-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import core._
66
import ast._
77
import Trees._, Constants._, StdNames._, Scopes._, Denotations._, Comments._
88
import Contexts._, Symbols._, Types._, SymDenotations._, Names._, NameOps._, Flags._, Decorators._
9+
import NameKinds.DefaultGetterName
910
import ast.desugar, ast.desugar._
1011
import ProtoTypes._
1112
import util.Positions._
@@ -1002,12 +1003,8 @@ class Namer { typer: Typer =>
10021003
* the corresponding parameter where bound parameters are replaced by
10031004
* Wildcards.
10041005
*/
1005-
def rhsProto = {
1006-
val name = sym.asTerm.name
1007-
val idx = name.defaultGetterIndex
1008-
if (idx < 0) WildcardType
1009-
else {
1010-
val original = name.defaultGetterToMethod
1006+
def rhsProto = sym.asTerm.name collect {
1007+
case DefaultGetterName(original, idx) =>
10111008
val meth: Denotation =
10121009
if (original.isConstructorName && (sym.owner is ModuleClass))
10131010
sym.owner.companionClass.info.decl(nme.CONSTRUCTOR)
@@ -1025,8 +1022,7 @@ class Namer { typer: Typer =>
10251022
paramProto(defaultAlts.head.info.widen.paramTypess, idx)
10261023
else
10271024
WildcardType
1028-
}
1029-
}
1025+
} getOrElse WildcardType
10301026

10311027
// println(s"final inherited for $sym: ${inherited.toString}") !!!
10321028
// println(s"owner = ${sym.owner}, decls = ${sym.owner.info.decls.show}")

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import core._
66
import config._
77
import Symbols._, SymDenotations._, Types._, Contexts._, Decorators._, Flags._, Names._, NameOps._
88
import StdNames._, Denotations._, Scopes._, Constants.Constant, SymUtils._
9+
import NameKinds.DefaultGetterName
910
import Annotations._
1011
import util.Positions._
1112
import scala.collection.{ mutable, immutable }
@@ -24,12 +25,8 @@ object RefChecks {
2425
import reporting.diagnostic.Message
2526
import reporting.diagnostic.messages._
2627

27-
28-
private def isDefaultGetter(name: Name): Boolean =
29-
name.isTermName && name.asTermName.defaultGetterIndex >= 0
30-
3128
private val defaultMethodFilter = new NameFilter {
32-
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean = isDefaultGetter(name)
29+
def apply(pre: Type, name: Name)(implicit ctx: Context): Boolean = name.is(DefaultGetterName)
3330
}
3431

3532
/** Only one overloaded alternative is allowed to define default arguments */
@@ -45,7 +42,9 @@ object RefChecks {
4542
if defaultGetterClass.isClass
4643
) {
4744
val defaultGetterNames = defaultGetterClass.asClass.memberNames(defaultMethodFilter)
48-
val defaultMethodNames = defaultGetterNames map (_.asTermName.defaultGetterToMethod)
45+
val defaultMethodNames = defaultGetterNames map { _ rewrite {
46+
case DefaultGetterName(methName, _) => methName
47+
}}
4948

5049
for (name <- defaultMethodNames) {
5150
val methods = clazz.info.member(name).alternatives.map(_.symbol)
@@ -238,7 +237,7 @@ object RefChecks {
238237
}
239238
}
240239
else
241-
isDefaultGetter(member.name) || // default getters are not checked for compatibility
240+
member.name.is(DefaultGetterName) || // default getters are not checked for compatibility
242241
memberTp.overrides(otherTp)
243242

244243
//Console.println(infoString(member) + " overrides " + infoString(other) + " in " + clazz);//DEBUG
@@ -298,7 +297,7 @@ object RefChecks {
298297
} else if (other.isEffectivelyFinal) { // (1.2)
299298
overrideError(i"cannot override final member ${other.showLocated}")
300299
} else if (!other.is(Deferred) &&
301-
!isDefaultGetter(other.name) &&
300+
!other.name.is(DefaultGetterName) &&
302301
!member.isAnyOverride) {
303302
// (*) Exclusion for default getters, fixes SI-5178. We cannot assign the Override flag to
304303
// the default getter: one default getter might sometimes override, sometimes not. Example in comment on ticket.

0 commit comments

Comments
 (0)