From 0698383d595fec40c70905eb0e06b430f93ba0b8 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 27 Mar 2017 10:08:59 +0200 Subject: Add NameExtractors Use a new scheme for creating and accessing semantic names which is based on semantic name extractors with nested info classes. --- compiler/src/dotty/tools/dotc/core/Denotations.scala | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/core/Denotations.scala') diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala index aa0ea39a2..60a506291 100644 --- a/compiler/src/dotty/tools/dotc/core/Denotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala @@ -6,6 +6,7 @@ import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation } import Contexts.{Context, ContextBase} import Names._ import NameOps._ +import NameExtractors._ import StdNames._ import Symbols.NoSymbol import Symbols._ @@ -1185,19 +1186,19 @@ object Denotations { } else owner } - def recur(path: Name, wrap: Name => Name = identity): Denotation = path match { + def recur(path: Name, wrap: TermName => Name = identity): Denotation = path match { case path: TypeName => - recur(path.toTermName, n => wrap(n.toTypeName)) - case DerivedTermName(prefix, NameInfo.ModuleClass) => - recur(prefix, n => wrap(n.derived(NameInfo.ModuleClass))) - case DerivedTermName(prefix, NameInfo.Select(selector)) => + recur(path.toTermName, n => n.toTypeName) + case ModuleClassName(underlying) => + recur(underlying, n => wrap(ModuleClassName(n))) + case QualifiedName(prefix, selector) => select(recur(prefix), wrap(selector)) - case DerivedTermName(prefix, qual: NameInfo.Qualified) => - recur(prefix, n => wrap(n ++ qual.separator ++ qual.name)) + case AnyQualifiedName(prefix, info) => + recur(prefix, n => wrap(info.mkString(n).toTermName)) case path: SimpleTermName => - def recurSimple(len: Int, wrap: Name => Name): Denotation = { + def recurSimple(len: Int, wrap: TermName => Name): Denotation = { val point = path.lastIndexOf('.', len - 1) - val selector = wrap(path.slice(point + 1, len)) + val selector = wrap(path.slice(point + 1, len).asTermName) val prefix = if (point > 0) recurSimple(point, identity) else if (selector.isTermName) defn.RootClass.denot -- cgit v1.2.3