Skip to content

Commit 5daf050

Browse files
committed
Cleanups of NameOps
Remove unused functionality
1 parent 661059f commit 5daf050

File tree

6 files changed

+15
-100
lines changed

6 files changed

+15
-100
lines changed

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 0 additions & 79 deletions
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)
@@ -307,17 +303,6 @@ object NameOps {
307303
}
308304
}
309305

310-
// needed???
311-
private val Boxed = Map[TypeName, TypeName](
312-
tpnme.Boolean -> jtpnme.BoxedBoolean,
313-
tpnme.Byte -> jtpnme.BoxedByte,
314-
tpnme.Char -> jtpnme.BoxedCharacter,
315-
tpnme.Short -> jtpnme.BoxedShort,
316-
tpnme.Int -> jtpnme.BoxedInteger,
317-
tpnme.Long -> jtpnme.BoxedLong,
318-
tpnme.Float -> jtpnme.BoxedFloat,
319-
tpnme.Double -> jtpnme.BoxedDouble)
320-
321306
implicit class TermNameDecorator(val name: TermName) extends AnyVal {
322307
import nme._
323308

@@ -338,18 +323,6 @@ object NameOps {
338323
}
339324
else FieldName(name)
340325

341-
/** Nominally, name from name$default$N, CONSTRUCTOR for <init> */
342-
def defaultGetterToMethod: TermName =
343-
name rewrite {
344-
case DefaultGetterName(methName, _) => methName
345-
}
346-
347-
/** If this is a default getter, its index (starting from 0), else -1 */
348-
def defaultGetterIndex: Int =
349-
name collect {
350-
case DefaultGetterName(_, num) => num
351-
} getOrElse -1
352-
353326
def stripScala2LocalSuffix: TermName =
354327
if (name.isScala2LocalSuffix) name.init.asTermName else name
355328

@@ -361,57 +334,5 @@ object NameOps {
361334
case raw.BANG => UNARY_!
362335
case _ => name
363336
}
364-
365-
/** The name of a method which stands in for a primitive operation
366-
* during structural type dispatch.
367-
*/
368-
def primitiveInfixMethodName: TermName = name match {
369-
case OR => takeOr
370-
case XOR => takeXor
371-
case AND => takeAnd
372-
case EQ => testEqual
373-
case NE => testNotEqual
374-
case ADD => add
375-
case SUB => subtract
376-
case MUL => multiply
377-
case DIV => divide
378-
case MOD => takeModulo
379-
case LSL => shiftSignedLeft
380-
case LSR => shiftLogicalRight
381-
case ASR => shiftSignedRight
382-
case LT => testLessThan
383-
case LE => testLessOrEqualThan
384-
case GE => testGreaterOrEqualThan
385-
case GT => testGreaterThan
386-
case ZOR => takeConditionalOr
387-
case ZAND => takeConditionalAnd
388-
case _ => NO_NAME
389-
}
390-
391-
/** Postfix/prefix, really.
392-
*/
393-
def primitivePostfixMethodName: TermName = name match {
394-
case UNARY_! => takeNot
395-
case UNARY_+ => positive
396-
case UNARY_- => negate
397-
case UNARY_~ => complement
398-
case `toByte` => toByte
399-
case `toShort` => toShort
400-
case `toChar` => toCharacter
401-
case `toInt` => toInteger
402-
case `toLong` => toLong
403-
case `toFloat` => toFloat
404-
case `toDouble` => toDouble
405-
case _ => NO_NAME
406-
}
407-
408-
def primitiveMethodName: TermName =
409-
primitiveInfixMethodName match {
410-
case NO_NAME => primitivePostfixMethodName
411-
case name => name
412-
}
413337
}
414-
415-
private final val FalseSuper = "$$super".toTermName
416-
private val FalseSuperLength = FalseSuper.length
417338
}

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 8 deletions
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._
@@ -1012,12 +1013,8 @@ class Namer { typer: Typer =>
10121013
* the corresponding parameter where bound parameters are replaced by
10131014
* Wildcards.
10141015
*/
1015-
def rhsProto = {
1016-
val name = sym.asTerm.name
1017-
val idx = name.defaultGetterIndex
1018-
if (idx < 0) WildcardType
1019-
else {
1020-
val original = name.defaultGetterToMethod
1016+
def rhsProto = sym.asTerm.name collect {
1017+
case DefaultGetterName(original, idx) =>
10211018
val meth: Denotation =
10221019
if (original.isConstructorName && (sym.owner is ModuleClass))
10231020
sym.owner.companionClass.info.decl(nme.CONSTRUCTOR)
@@ -1035,8 +1032,7 @@ class Namer { typer: Typer =>
10351032
paramProto(defaultAlts.head.info.widen.paramInfoss, idx)
10361033
else
10371034
WildcardType
1038-
}
1039-
}
1035+
} getOrElse WildcardType
10401036

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

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

Lines changed: 7 additions & 8 deletions
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)