aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/dotty/tools/dotc/FromTasty.scala3
-rw-r--r--compiler/src/dotty/tools/dotc/ast/Desugar.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/ast/TreeInfo.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/Definitions.scala19
-rw-r--r--compiler/src/dotty/tools/dotc/core/NameKinds.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/core/NameOps.scala101
-rw-r--r--compiler/src/dotty/tools/dotc/core/Names.scala57
-rw-r--r--compiler/src/dotty/tools/dotc/core/StdNames.scala37
-rw-r--r--compiler/src/dotty/tools/dotc/core/SymDenotations.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala10
-rw-r--r--compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala4
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/Scanners.scala6
-rw-r--r--compiler/src/dotty/tools/dotc/parsing/package.scala2
-rw-r--r--compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala5
-rw-r--r--compiler/src/dotty/tools/dotc/typer/Applications.scala5
-rw-r--r--compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala2
16 files changed, 124 insertions, 139 deletions
diff --git a/compiler/src/dotty/tools/dotc/FromTasty.scala b/compiler/src/dotty/tools/dotc/FromTasty.scala
index b060a2054..da0190fa1 100644
--- a/compiler/src/dotty/tools/dotc/FromTasty.scala
+++ b/compiler/src/dotty/tools/dotc/FromTasty.scala
@@ -17,6 +17,7 @@ import Decorators._
import dotty.tools.dotc.transform.Pickler
import tasty.DottyUnpickler
import ast.tpd._
+import NameKinds.QualifiedName
/** Compiler for TASTY files.
* Usage:
@@ -74,7 +75,7 @@ object FromTasty extends Driver {
case unit: TASTYCompilationUnit =>
val className = unit.className.toTypeName
val clsd =
- if (className.contains('.')) ctx.base.staticRef(className)
+ if (className.is(QualifiedName)) ctx.base.staticRef(className)
else defn.EmptyPackageClass.info.decl(className)
def cannotUnpickle(reason: String) = {
ctx.error(s"class $className cannot be unpickled because $reason")
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala
index 9cf530f8f..111382b18 100644
--- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala
@@ -403,7 +403,7 @@ object desugar {
def anyRef = ref(defn.AnyRefAlias.typeRef)
def productConstr(n: Int) = {
- val tycon = scalaDot((tpnme.Product.toString + n).toTypeName)
+ val tycon = scalaDot((str.Product + n).toTypeName)
val targs = constrVparamss.head map (_.tpt)
if (targs.isEmpty) tycon else AppliedTypeTree(tycon, targs)
}
diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
index 037ab73af..f3bce4000 100644
--- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
+++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
@@ -157,7 +157,7 @@ trait TreeInfo[T >: Untyped <: Type] { self: Trees.Instance[T] =>
}
/** Is name a left-associative operator? */
- def isLeftAssoc(operator: Name) = operator.nonEmpty && (operator.last != ':')
+ def isLeftAssoc(operator: Name) = !operator.isEmpty && (operator.toSimpleName.last != ':')
/** can this type be a type pattern? */
def mayBeTypePat(tree: untpd.Tree): Boolean = unsplice(tree) match {
diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala
index 670b919ac..a1858e934 100644
--- a/compiler/src/dotty/tools/dotc/core/Definitions.scala
+++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala
@@ -119,7 +119,7 @@ class Definitions {
enterTypeParam(cls, name ++ "$T" ++ i.toString, Contravariant, decls)
val resParam = enterTypeParam(cls, name ++ "$R", Covariant, decls)
val (methodType, parentTraits) =
- if (name.startsWith(tpnme.ImplicitFunction)) {
+ if (name.startsWith(str.ImplicitFunction)) {
val superTrait =
FunctionType(arity).appliedTo(argParams.map(_.typeRef) ::: resParam.typeRef :: Nil)
(ImplicitMethodType, ctx.normalizeToClassRefs(superTrait :: Nil, cls, decls))
@@ -723,12 +723,11 @@ class Definitions {
/** If type `ref` refers to a class in the scala package, its name, otherwise EmptyTypeName */
def scalaClassName(ref: Type)(implicit ctx: Context): TypeName = scalaClassName(ref.classSymbol)
- private def isVarArityClass(cls: Symbol, prefix: Name) = {
- val name = scalaClassName(cls)
- name.startsWith(prefix) &&
- name.length > prefix.length &&
- name.drop(prefix.length).forall(_.isDigit)
- }
+ private def isVarArityClass(cls: Symbol, prefix: String) =
+ scalaClassName(cls).testSimple(name =>
+ name.startsWith(prefix) &&
+ name.length > prefix.length &&
+ name.drop(prefix.length).forall(_.isDigit))
def isBottomClass(cls: Symbol) =
cls == NothingClass || cls == NullClass
@@ -758,9 +757,9 @@ class Definitions {
*/
def isSyntheticFunctionClass(cls: Symbol) = scalaClassName(cls).isSyntheticFunction
- def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.AbstractFunction)
- def isTupleClass(cls: Symbol) = isVarArityClass(cls, tpnme.Tuple)
- def isProductClass(cls: Symbol) = isVarArityClass(cls, tpnme.Product)
+ def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, str.AbstractFunction)
+ def isTupleClass(cls: Symbol) = isVarArityClass(cls, str.Tuple)
+ def isProductClass(cls: Symbol) = isVarArityClass(cls, str.Product)
/** Returns the erased class of the function class `cls`
* - FunctionN for N > 22 becomes FunctionXXL
diff --git a/compiler/src/dotty/tools/dotc/core/NameKinds.scala b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
index cabb83171..8ea19bed2 100644
--- a/compiler/src/dotty/tools/dotc/core/NameKinds.scala
+++ b/compiler/src/dotty/tools/dotc/core/NameKinds.scala
@@ -164,7 +164,7 @@ object NameKinds {
val ExpandPrefixName = new QualifiedNameKind(EXPANDPREFIX, "$")
val ExpandedName = new QualifiedNameKind(EXPANDED, str.EXPAND_SEPARATOR) {
- private val FalseSuper = "$$super".toTermName
+ private val FalseSuper = termName("$$super")
private val FalseSuperLength = FalseSuper.length
override def unmangle(name: SimpleTermName): TermName = {
@@ -216,10 +216,10 @@ object NameKinds {
object DefaultGetterName extends NumberedNameKind(DEFAULTGETTER, "DefaultGetter") {
def mkString(underlying: TermName, info: ThisInfo) = {
val prefix = if (underlying.isConstructorName) nme.DEFAULT_GETTER_INIT else underlying
- prefix.toString + nme.DEFAULT_GETTER + (info.num + 1)
+ prefix.toString + str.DEFAULT_GETTER + (info.num + 1)
}
- private val dgLen = nme.DEFAULT_GETTER.length
+ private val dgLen = str.DEFAULT_GETTER.length
override def unmangle(name: SimpleTermName): TermName = {
var i = name.length
diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala
index 2caaaf1ab..e74bf8ca7 100644
--- a/compiler/src/dotty/tools/dotc/core/NameOps.scala
+++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala
@@ -52,24 +52,32 @@ object NameOps {
implicit class NameDecorator[N <: Name](val name: N) extends AnyVal {
import nme._
+ def testSimple(f: SimpleTermName => Boolean): Boolean = name match {
+ case name: SimpleTermName => f(name)
+ case name: TypeName => name.toTermName.testSimple(f)
+ case _ => false
+ }
+
def likeTyped(n: PreName): N =
(if (name.isTermName) n.toTermName else n.toTypeName).asInstanceOf[N]
def isConstructorName = name == CONSTRUCTOR || name == TRAIT_CONSTRUCTOR
def isStaticConstructorName = name == STATIC_CONSTRUCTOR
def isLocalDummyName = name startsWith LOCALDUMMY_PREFIX
- def isReplWrapperName = name.toSimpleName containsSlice INTERPRETER_IMPORT_WRAPPER
+ def isReplWrapperName = name.toString contains str.INTERPRETER_IMPORT_WRAPPER
def isSetterName = name endsWith SETTER_SUFFIX
- def isScala2LocalSuffix = name.endsWith(" ")
- def isSelectorName = name.startsWith("_") && name.tail.forall(_.isDigit)
+ def isScala2LocalSuffix = testSimple(_.endsWith(" "))
+ def isSelectorName = testSimple(n => n.startsWith("_") && n.drop(1).forall(_.isDigit))
/** Is name a variable name? */
- def isVariableName: Boolean = name.length > 0 && {
- val first = name.head
- (((first.isLower && first.isLetter) || first == '_')
- && (name != false_)
- && (name != true_)
- && (name != null_))
+ def isVariableName: Boolean = testSimple { n =>
+ n.length > 0 && {
+ val first = n.head
+ (((first.isLower && first.isLetter) || first == '_')
+ && (n != false_)
+ && (n != true_)
+ && (n != null_))
+ }
}
def isOpAssignmentName: Boolean = name match {
@@ -91,11 +99,10 @@ object NameOps {
* method needs to work on mangled as well as unmangled names because
* it is also called from the backend.
*/
- def stripModuleClassSuffix: Name = name.toTermName match {
- case n: SimpleTermName if n.endsWith("$") =>
- name.unmangleClassName.exclude(ModuleClassName)
- case _ =>
- name.exclude(ModuleClassName)
+ def stripModuleClassSuffix: N = likeTyped {
+ val name1 =
+ if (name.isSimple && name.endsWith("$")) name.unmangleClassName else name
+ name.exclude(ModuleClassName)
}
/** If flags is a ModuleClass but not a Package, add module class suffix */
@@ -159,56 +166,13 @@ object NameOps {
}
}
- def unmangleClassName: N =
- if (name.isSimple && name.isTypeName)
- if (name.endsWith(MODULE_SUFFIX) && !tpnme.falseModuleClassNames.contains(name.asTypeName))
- likeTyped(name.dropRight(MODULE_SUFFIX.length).moduleClassName)
- else name
- else name
-
- /** Translate a name into a list of simple TypeNames and TermNames.
- * In all segments before the last, type/term is determined by whether
- * the following separator char is '.' or '#'. The last segment
- * is of the same type as the original name.
- *
- * Examples:
- *
- * package foo {
- * object Lorax { object Wog ; class Wog }
- * class Lorax { object Zax ; class Zax }
- * }
- *
- * f("foo.Lorax".toTermName) == List("foo": Term, "Lorax": Term) // object Lorax
- * f("foo.Lorax".toTypeName) == List("foo": Term, "Lorax": Type) // class Lorax
- * f("Lorax.Wog".toTermName) == List("Lorax": Term, "Wog": Term) // object Wog
- * f("Lorax.Wog".toTypeName) == List("Lorax": Term, "Wog": Type) // class Wog
- * f("Lorax#Zax".toTermName) == List("Lorax": Type, "Zax": Term) // object Zax
- * f("Lorax#Zax".toTypeName) == List("Lorax": Type, "Zax": Type) // class Zax
- *
- * Note that in actual scala syntax you cannot refer to object Zax without an
- * instance of Lorax, so Lorax#Zax could only mean the type. One might think
- * that Lorax#Zax.type would work, but this is not accepted by the parser.
- * For the purposes of referencing that object, the syntax is allowed.
- */
- def segments: List[Name] = {
- def mkName(name: Name, follow: Char): Name =
- if (follow == '.') name.toTermName else name.toTypeName
-
- name.indexWhere(ch => ch == '.' || ch == '#') match {
- case -1 =>
- if (name.isEmpty) scala.Nil else name :: scala.Nil
- case idx =>
- mkName(name take idx, name(idx)) :: (name drop (idx + 1)).segments
- }
- }
-
/** Is a synthetic function name
* - N for FunctionN
* - N for ImplicitFunctionN
* - (-1) otherwise
*/
def functionArity: Int =
- functionArityFor(tpnme.Function) max functionArityFor(tpnme.ImplicitFunction)
+ functionArityFor(str.Function) max functionArityFor(str.ImplicitFunction)
/** Is a function name
* - FunctionN for N >= 0
@@ -221,7 +185,7 @@ object NameOps {
* - ImplicitFunctionN for N >= 0
* - false otherwise
*/
- def isImplicitFunction: Boolean = functionArityFor(tpnme.ImplicitFunction) >= 0
+ def isImplicitFunction: Boolean = functionArityFor(str.ImplicitFunction) >= 0
/** Is a synthetic function name
* - FunctionN for N > 22
@@ -229,12 +193,12 @@ object NameOps {
* - false otherwise
*/
def isSyntheticFunction: Boolean = {
- functionArityFor(tpnme.Function) > MaxImplementedFunctionArity ||
- functionArityFor(tpnme.ImplicitFunction) >= 0
+ functionArityFor(str.Function) > MaxImplementedFunctionArity ||
+ functionArityFor(str.ImplicitFunction) >= 0
}
/** Parsed function arity for function with some specific prefix */
- private def functionArityFor(prefix: Name): Int = {
+ private def functionArityFor(prefix: String): Int = {
if (name.startsWith(prefix))
try name.toString.substring(prefix.length).toInt
catch { case _: NumberFormatException => -1 }
@@ -285,6 +249,13 @@ object NameOps {
/** If name length exceeds allowable limit, replace part of it by hash */
def compactified(implicit ctx: Context): TermName = termName(compactify(name.toString))
+ def unmangleClassName: N = name.toTermName match {
+ case name: SimpleTermName
+ if name.endsWith(str.MODULE_SUFFIX) && !nme.falseModuleClassNames.contains(name) =>
+ likeTyped(name.dropRight(str.MODULE_SUFFIX.length).moduleClassName)
+ case _ => name
+ }
+
def unmangle(kind: NameKind): N = likeTyped {
name rewrite {
case unmangled: SimpleTermName =>
@@ -306,11 +277,11 @@ object NameOps {
implicit class TermNameDecorator(val name: TermName) extends AnyVal {
import nme._
- def setterName: TermName = name.exclude(FieldName) ++ SETTER_SUFFIX
+ def setterName: TermName = name.exclude(FieldName) ++ str.SETTER_SUFFIX
def getterName: TermName =
name.exclude(FieldName).mapLast(n =>
- if (n.endsWith(SETTER_SUFFIX)) n.take(n.length - SETTER_SUFFIX.length).asSimpleName
+ if (n.endsWith(SETTER_SUFFIX)) n.take(n.length - str.SETTER_SUFFIX.length).asSimpleName
else n)
def fieldName: TermName =
@@ -324,7 +295,7 @@ object NameOps {
else FieldName(name)
def stripScala2LocalSuffix: TermName =
- if (name.isScala2LocalSuffix) name.init.asTermName else name
+ if (name.isScala2LocalSuffix) name.asSimpleName.dropRight(1) else name
/** The name unary_x for a prefix operator x */
def toUnaryName: TermName = name match {
diff --git a/compiler/src/dotty/tools/dotc/core/Names.scala b/compiler/src/dotty/tools/dotc/core/Names.scala
index d1412c35c..5b6315e66 100644
--- a/compiler/src/dotty/tools/dotc/core/Names.scala
+++ b/compiler/src/dotty/tools/dotc/core/Names.scala
@@ -88,8 +88,8 @@ object Names {
/** Replace operator symbols by corresponding \$op_name's. */
def encode: Name
- def firstPart: TermName
- def lastPart: TermName
+ def firstPart: SimpleTermName
+ def lastPart: SimpleTermName
/** A more efficient version of concatenation */
def ++ (other: Name): ThisName = ++ (other.toString)
@@ -204,7 +204,15 @@ object Names {
def apply(n: Int) = chrs(start + n)
- private def contains(ch: Char): Boolean = {
+ def exists(p: Char => Boolean): Boolean = {
+ var i = 0
+ while (i < length && !p(chrs(start + i))) i += 1
+ i < length
+ }
+
+ def forall(p: Char => Boolean) = !exists(!p(_))
+
+ def contains(ch: Char): Boolean = {
var i = 0
while (i < length && chrs(start + i) != ch) i += 1
i < length
@@ -224,6 +232,12 @@ object Names {
i > str.length
}
+ def lastIndexOf(ch: Char, start: Int = length - 1): Int = {
+ var i = start
+ while (i >= 0 && apply(i) != ch) i -= 1
+ i
+ }
+
override def replace(from: Char, to: Char): SimpleTermName = {
val cs = new Array[Char](length)
Array.copy(chrs, start, cs, 0, length)
@@ -233,6 +247,19 @@ object Names {
termName(cs, 0, length)
}
+ def slice(from: Int, until: Int): SimpleTermName = {
+ assert(0 <= from && from <= until && until <= length)
+ termName(chrs, start + from, until - from)
+ }
+
+ def drop(n: Int) = slice(n, length)
+ def take(n: Int) = slice(0, n)
+ def dropRight(n: Int) = slice(0, length - n)
+ def takeRight(n: Int) = slice(length - n, length)
+
+ def head = apply(0)
+ def last = apply(length - 1)
+
def isSimple = true
def asSimpleName = this
def toSimpleName = this
@@ -242,12 +269,6 @@ object Names {
def mapLast(f: SimpleTermName => SimpleTermName) = f(this)
def mapParts(f: SimpleTermName => SimpleTermName) = f(this)
- /*def exists(p: Char => Boolean): Boolean = {
- var i = 0
- while (i < length && !p(chrs(start + i))) i += 1
- i < length
- }*/
-
def encode: SimpleTermName =
if (dontEncode(toTermName)) this else NameTransformer.encode(this)
@@ -490,24 +511,6 @@ object Names {
val dontEncode = Set(CONSTRUCTOR, EMPTY_PACKAGE, REFINEMENT)
- def termNameBuilder: Builder[Char, TermName] =
- StringBuilder.newBuilder.mapResult(termName)
-
- def typeNameBuilder: Builder[Char, TypeName] =
- StringBuilder.newBuilder.mapResult(termName(_).toTypeName)
-
- implicit class nameToSeq(val name: Name) extends IndexedSeqOptimized[Char, Name] {
- def length = name.asSimpleName.length
- def apply(n: Int) = name.asSimpleName.apply(n)
- override protected[this] def newBuilder: Builder[Char, Name] =
- if (name.isTypeName) typeNameBuilder else termNameBuilder
-
- def seq: WrappedString = new WrappedString(name.toString)
- override protected[this] def thisCollection: WrappedString = seq
- def indexOfSlice(name: Name): Int = indexOfSlice(name.toString)
- def containsSlice(name: Name): Boolean = containsSlice(name.toString)
- }
-
implicit val NameOrdering: Ordering[Name] = new Ordering[Name] {
private def compareInfos(x: NameInfo, y: NameInfo): Int =
if (x.kind.tag != y.kind.tag) x.kind.tag - y.kind.tag
diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala
index 8eea6aded..c942a058a 100644
--- a/compiler/src/dotty/tools/dotc/core/StdNames.scala
+++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala
@@ -16,12 +16,26 @@ object StdNames {
/** Base strings from which synthetic names are derived. */
object str {
- val EXPAND_SEPARATOR = "$$"
- val TRAIT_SETTER_SEPARATOR = "$_setter_$"
- val SUPER_PREFIX = "super$"
- val INITIALIZER_PREFIX = "initial$"
- val SHADOWED_PREFIX = "(shadowed)"
- val AVOID_CLASH_SUFFIX = "$_avoid_name_clash_$"
+ final val SETTER_SUFFIX = "_$eq"
+ final val EXPAND_SEPARATOR = "$$"
+ final val TRAIT_SETTER_SEPARATOR = "$_setter_$"
+ final val SUPER_PREFIX = "super$"
+ final val INITIALIZER_PREFIX = "initial$"
+ final val SHADOWED_PREFIX = "(shadowed)"
+ final val AVOID_CLASH_SUFFIX = "$_avoid_name_clash_$"
+ final val MODULE_SUFFIX = NameTransformer.MODULE_SUFFIX_STRING
+ final val DEFAULT_GETTER = "$default$"
+
+ final val INTERPRETER_IMPORT_WRAPPER = "$iw"
+ final val INTERPRETER_LINE_PREFIX = "line"
+ final val INTERPRETER_VAR_PREFIX = "res"
+ final val INTERPRETER_WRAPPER_SUFFIX = "$object"
+
+ final val Function = "Function"
+ final val ImplicitFunction = "ImplicitFunction"
+ final val AbstractFunction = "AbstractFunction"
+ final val Tuple = "Tuple"
+ final val Product = "Product"
def sanitize(str: String) = str.replaceAll("""[<>]""", """\$""")
}
@@ -102,7 +116,7 @@ object StdNames {
val BITMAP_TRANSIENT: N = BITMAP_PREFIX + "trans$" // initialization bitmap for transient lazy vals
val BITMAP_CHECKINIT: N = BITMAP_PREFIX + "init$" // initialization bitmap for checkinit values
val BITMAP_CHECKINIT_TRANSIENT: N = BITMAP_PREFIX + "inittrans$" // initialization bitmap for transient checkinit values
- val DEFAULT_GETTER: N = "$default$"
+ val DEFAULT_GETTER: N = str.DEFAULT_GETTER
val DEFAULT_GETTER_INIT: N = "$lessinit$greater"
val DO_WHILE_PREFIX: N = "doWhile$"
val EMPTY: N = ""
@@ -111,10 +125,6 @@ object StdNames {
val EXPAND_SEPARATOR: N = str.EXPAND_SEPARATOR
val IMPL_CLASS_SUFFIX: N = "$class"
val IMPORT: N = "<import>"
- val INTERPRETER_IMPORT_WRAPPER: N = "$iw"
- val INTERPRETER_LINE_PREFIX: N = "line"
- val INTERPRETER_VAR_PREFIX: N = "res"
- val INTERPRETER_WRAPPER_SUFFIX: N = "$object"
val LOCALDUMMY_PREFIX: N = "<local " // owner of local blocks
val MODULE_SUFFIX: N = NameTransformer.MODULE_SUFFIX_STRING
val NAME_JOIN: N = NameTransformer.NAME_JOIN_STRING
@@ -177,23 +187,18 @@ object StdNames {
final val REIFY_TREECREATOR_PREFIX: N = "$treecreator"
final val REIFY_TYPECREATOR_PREFIX: N = "$typecreator"
- final val AbstractFunction: N = "AbstractFunction"
final val Any: N = "Any"
final val AnyVal: N = "AnyVal"
final val ExprApi: N = "ExprApi"
- final val Function: N = "Function"
- final val ImplicitFunction: N = "ImplicitFunction"
final val Mirror: N = "Mirror"
final val Nothing: N = "Nothing"
final val Null: N = "Null"
final val Object: N = "Object"
final val PartialFunction: N = "PartialFunction"
final val PrefixType: N = "PrefixType"
- final val Product: N = "Product"
final val Serializable: N = "Serializable"
final val Singleton: N = "Singleton"
final val Throwable: N = "Throwable"
- final val Tuple: N = "Tuple"
final val ClassfileAnnotation: N = "ClassfileAnnotation"
final val ClassManifest: N = "ClassManifest"
diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
index f4682bf7d..547fd2d91 100644
--- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -407,7 +407,7 @@ object SymDenotations {
// duplicate scalac's behavior: don't write a double '$$' for module class members.
prefix = prefix.exclude(ModuleClassName)
def qualify(n: SimpleTermName) =
- kind(prefix.toTermName, if (filler.isEmpty) n else termName(filler ++ n))
+ kind(prefix.toTermName, if (filler.isEmpty) n else termName(filler + n))
val fn = name rewrite {
case name: SimpleTermName => qualify(name)
case name @ AnyQualifiedName(_, _) => qualify(name.toSimpleName)
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index b09da70e1..98ac52533 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -247,7 +247,8 @@ class ClassfileParser(
final def objToAny(tp: Type)(implicit ctx: Context) =
if (tp.isDirectRef(defn.ObjectClass) && !ctx.phase.erasedTypes) defn.AnyType else tp
- private def sigToType(sig: TermName, owner: Symbol = null)(implicit ctx: Context): Type = {
+ private def sigToType(signature: TermName, owner: Symbol = null)(implicit ctx: Context): Type = {
+ val sig = signature.toSimpleName
var index = 0
val end = sig.length
def accept(ch: Char): Unit = {
@@ -655,7 +656,10 @@ class ClassfileParser(
* and implicitly current class' superclasses.
*/
private def enterOwnInnerClasses()(implicit ctx: Context): Unit = {
- def className(name: Name): Name = name.drop(name.lastIndexOf('.') + 1)
+ def className(name: Name): Name = {
+ val name1 = name.toSimpleName
+ name1.drop(name1.lastIndexOf('.') + 1)
+ }
def enterClassAndModule(entry: InnerClassEntry, file: AbstractFile, jflags: Int) = {
ctx.base.loaders.enterClassAndModule(
@@ -1003,7 +1007,7 @@ class ClassfileParser(
val start = starts(index)
if (in.buf(start).toInt != CONSTANT_CLASS) errorBadTag(start)
val name = getExternalName(in.getChar(start + 1))
- if (name(0) == ARRAY_TAG) {
+ if (name.firstPart(0) == ARRAY_TAG) {
c = sigToType(name)
values(index) = c
} else {
diff --git a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala
index 6df96a9a0..7ee6427f3 100644
--- a/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala
+++ b/compiler/src/dotty/tools/dotc/core/tasty/NameBuffer.scala
@@ -30,7 +30,7 @@ class NameBuffer extends TastyBuffer(10000) {
nameIndex(prefix); nameIndex(name)
case AnyUniqueName(original, separator, num) =>
nameIndex(separator.toTermName)
- if (original.nonEmpty) nameIndex(original)
+ if (!original.isEmpty) nameIndex(original)
case DerivedTermName(original, _) =>
nameIndex(original)
case _ =>
@@ -68,7 +68,7 @@ class NameBuffer extends TastyBuffer(10000) {
withLength {
writeNameRef(separator.toTermName)
writeNat(num)
- if (original.nonEmpty) writeNameRef(original)
+ if (!original.isEmpty) writeNameRef(original)
}
case DefaultGetterName(method, paramNumber) =>
withLength { writeNameRef(method); writeNat(paramNumber) }
diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
index 3084c30a8..b0fa8d760 100644
--- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala
@@ -37,7 +37,7 @@ object Scanners {
var lastOffset: Offset = 0
/** the name of an identifier */
- var name: TermName = null
+ var name: SimpleTermName = null
/** the string value of a literal */
var strVal: String = null
@@ -98,10 +98,10 @@ object Scanners {
/** Clear buffer and set name and token */
def finishNamed(idtoken: Token = IDENTIFIER, target: TokenData = this): Unit = {
- target.name = flushBuf(litBuf).toTermName
+ target.name = termName(flushBuf(litBuf))
target.token = idtoken
if (idtoken == IDENTIFIER) {
- val idx = target.name.asSimpleName.start
+ val idx = target.name.start
target.token = toToken(idx)
}
}
diff --git a/compiler/src/dotty/tools/dotc/parsing/package.scala b/compiler/src/dotty/tools/dotc/parsing/package.scala
index 8b113ed96..cdb30d0be 100644
--- a/compiler/src/dotty/tools/dotc/parsing/package.scala
+++ b/compiler/src/dotty/tools/dotc/parsing/package.scala
@@ -10,7 +10,7 @@ package object parsing {
def precedence(operator: Name): Int =
if (operator eq nme.ERROR) -1
else {
- val firstCh = operator(0)
+ val firstCh = operator.firstPart.head
if (isScalaLetter(firstCh)) 1
else if (operator.isOpAssignmentName) 0
else firstCh match {
diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index f6399d3b7..c3f36cc46 100644
--- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -156,8 +156,9 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
// one version of the annotation tree that has the correct positions).
withoutPos(super.toText(tp))
case tp: SelectionProto =>
- return "?{ " ~ toText(tp.name) ~ (" " provided !tp.name.decode.last.isLetterOrDigit) ~
- ": " ~ toText(tp.memberProto) ~ " }"
+ return "?{ " ~ toText(tp.name) ~
+ (" " provided !tp.name.toSimpleName.decode.last.isLetterOrDigit) ~
+ ": " ~ toText(tp.memberProto) ~ " }"
case tp: ViewProto =>
return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
case tp @ FunProto(args, resultType, _) =>
diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala
index db1e0bcfb..2f2af9868 100644
--- a/compiler/src/dotty/tools/dotc/typer/Applications.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala
@@ -403,7 +403,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
def missingArg(n: Int): Unit = {
val pname = methodType.paramNames(n)
fail(
- if (pname contains '$') s"not enough arguments for $methString"
+ if (pname.firstPart contains '$') s"not enough arguments for $methString"
else s"missing argument for parameter $pname of $methString")
}
@@ -719,7 +719,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
val lhs1 = typedExpr(lhs)
val liftedDefs = new mutable.ListBuffer[Tree]
val lhs2 = untpd.TypedSplice(liftAssigned(liftedDefs, lhs1))
- val assign = untpd.Assign(lhs2, untpd.Apply(untpd.Select(lhs2, name.init), rhss))
+ val assign = untpd.Assign(lhs2,
+ untpd.Apply(untpd.Select(lhs2, name.asSimpleName.dropRight(1)), rhss))
wrapDefs(liftedDefs, typed(assign))
}
diff --git a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
index 22acd112b..e5480c98d 100644
--- a/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
+++ b/compiler/src/dotty/tools/dotc/typer/EtaExpansion.scala
@@ -63,7 +63,7 @@ object EtaExpansion {
case mt: MethodType =>
(args, mt.paramNames, mt.paramInfos).zipped map { (arg, name, tp) =>
if (tp.isInstanceOf[ExprType]) arg
- else liftArg(defs, arg, if (name contains '$') EmptyTermName else name)
+ else liftArg(defs, arg, if (name.firstPart contains '$') EmptyTermName else name)
}
case _ =>
args map (liftArg(defs, _))