aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Definitions.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-31 18:32:02 +0200
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:12 +0200
commitb4f21c6da6b6bc1797908f1400631573b6445e31 (patch)
tree19efe5c588230059b04ef046114c30d3fd64b1f9 /compiler/src/dotty/tools/dotc/core/Definitions.scala
parent7a927ce233a8ea4b8ddc285b8a36c61ca3fdd405 (diff)
downloaddotty-b4f21c6da6b6bc1797908f1400631573b6445e31.tar.gz
dotty-b4f21c6da6b6bc1797908f1400631573b6445e31.tar.bz2
dotty-b4f21c6da6b6bc1797908f1400631573b6445e31.zip
Names are no longer Seqs
Drop Seq implementation of name. This implementation was always problematic because it entailed potentially very costly conversions to toSimpleName. We now have better control over when we convert a name to a simple name.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Definitions.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Definitions.scala19
1 files changed, 9 insertions, 10 deletions
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