Skip to content

Delay name mangling #2128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 68 commits into from
Apr 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
efb5fa4
Cleanup of simple names
odersky Mar 21, 2017
f827882
Add derived name machinery
odersky Mar 21, 2017
8144ac2
Fix @sharable problem
odersky Mar 21, 2017
01d9659
Fix handling of qualified names
odersky Mar 22, 2017
67105e3
Start to use structured ModuleNames
odersky Mar 22, 2017
ccba1b7
Self-checked structured qualified names
odersky Mar 22, 2017
88171be
Unmangle class names in ClassfileParser
odersky Mar 22, 2017
d44eb20
Deug info in classfile parser
odersky Mar 22, 2017
e1181d9
Fix typos and redundant statements in previous commits
odersky Mar 22, 2017
2cc16c4
Use system hashcode for all names except SimpleTermNames
odersky Mar 22, 2017
19bc1ff
Disentangle Names from Seqs
odersky Mar 22, 2017
bbc84ea
Implement startsWith/encode/decode for derived names.
odersky Mar 22, 2017
c27cbd1
Bug fixes
odersky Mar 23, 2017
e2056bb
Polishings
odersky Mar 23, 2017
a2731a8
Handle expansion and flattening
odersky Mar 23, 2017
0ad1cd8
Add default getter names
odersky Mar 24, 2017
0755ec2
Add Variant NameInfo
odersky Mar 24, 2017
f9a9ddb
Turn on semantic names
odersky Mar 25, 2017
624b4eb
Semantic SuperAccessor and Initializer names
odersky Mar 25, 2017
2ab3759
Fix test
odersky Mar 25, 2017
47158c9
Properly integrate TraitSetter names
odersky Mar 26, 2017
baa2d51
Fix to fieldName for trait setters
odersky Mar 26, 2017
606294c
Don't forget ExpandedName when unpickling SuperAccessors
odersky Mar 26, 2017
0698383
Add NameExtractors
odersky Mar 27, 2017
0bb5bb3
Eliminate TastyNames
odersky Mar 27, 2017
0ccc76e
Add missing file
odersky Mar 27, 2017
c599f7a
Drop Config.semanticNames option
odersky Mar 27, 2017
0efd6b9
Fix PrefixNameExtractor mkString
odersky Mar 27, 2017
21ab9a1
Get rid of ExpandedName flag
odersky Mar 27, 2017
ea96ecd
Get rid of SuperAccessor flag
odersky Mar 27, 2017
1d6f5f7
Streamline pickling and unpickling of names
odersky Mar 27, 2017
0021ffb
Add ShadowedName and AvoidClashName
odersky Mar 27, 2017
1e49dda
Redefine definesNewName
odersky Mar 28, 2017
ca5652c
Make freshName semantic
odersky Mar 28, 2017
3fe4e06
Rename NameExtractor -> NameKind
odersky Mar 28, 2017
d5c1e6d
Fix rebase breakage
odersky Mar 28, 2017
a5d94d2
Decentralize unmangling, add new nameKinds
odersky Mar 29, 2017
b595a98
New unmangling for ExpandedName
odersky Mar 29, 2017
ae69495
Fix inner class name table emission with semantic names
smarter Mar 29, 2017
21ded6e
Revise qualified names
odersky Mar 30, 2017
ab2d095
Make "direct names" semantic
odersky Mar 30, 2017
6786cea
Make field names semantic
odersky Mar 30, 2017
1c13559
Fix ParallelTesting NPE
odersky Mar 30, 2017
0ffa6d8
Fix dropModule logic
odersky Mar 31, 2017
e3e5e79
Avoid duplicate hashCode/equals
odersky Mar 31, 2017
a3f6ca5
Make module var names semantic
odersky Mar 31, 2017
24f40bc
Make outer select names semantic
odersky Mar 31, 2017
130069a
Cleanups of NameOps
odersky Mar 31, 2017
7a927ce
Run compileStdLib only as junit test
odersky Mar 31, 2017
b4f21c6
Names are no longer Seqs
odersky Mar 31, 2017
4a54b2c
Merge likeTyped and likeKinded into likeSpaced
odersky Mar 31, 2017
a574ba6
Further simplification for Name
odersky Mar 31, 2017
c646883
Bugfix in stripModuleClassSuffix
odersky Apr 1, 2017
9f7012e
Memoize toSimpleName
odersky Apr 1, 2017
b2bd0bf
Don't unmangle names in ClassfileParser
odersky Apr 1, 2017
e2fb134
Simplify classfile parser "own name" checking
odersky Apr 1, 2017
e4780e5
Keep package member names mangled
odersky Apr 1, 2017
2bfb2ca
Introduce mangled method
odersky Apr 1, 2017
bd992dd
Fix and activate package scopes
odersky Apr 1, 2017
a7ee8dc
Avoid setter in Name
odersky Apr 1, 2017
264211f
Scope refactoring
odersky Apr 2, 2017
d0efabf
Lazy entering of names with internal $'s in package scopes
odersky Apr 2, 2017
868a6a1
Make extension method names semantic
odersky Apr 3, 2017
b17af4b
Fix rebase breakage
odersky Apr 6, 2017
800b1ad
Fix pickling/unpickling of names
odersky Apr 6, 2017
a5b6bd6
Adapt isPackageObject to semantic naming
odersky Apr 10, 2017
bec4f9d
Better documentation of sharable structures in Names, NameKinds
odersky Apr 11, 2017
87608bd
Fix type error
odersky Apr 11, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import Decorators._
import tpd._

import scala.tools.asm
import NameOps._
import StdNames.nme
import NameOps._
import NameKinds.DefaultGetterName
import dotty.tools.dotc.core
import dotty.tools.dotc.core.Names.TypeName

Expand Down Expand Up @@ -255,7 +255,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
val evalue = t.symbol.name.toString // value the actual enumeration value.
av.visitEnum(name, edesc, evalue)
} else {
assert(toDenot(t.symbol).name.toTermName.defaultGetterIndex >= 0) // this should be default getter. do not emmit.
assert(toDenot(t.symbol).name.is(DefaultGetterName)) // this should be default getter. do not emmit.
}
case t: SeqLiteral =>
val arrAnnotV: AnnotationVisitor = av.visitArray(name)
Expand Down Expand Up @@ -421,7 +421,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
val Flag_METHOD: Flags = Flags.Method.bits
val ExcludedForwarderFlags: Flags = {
Flags.Specialized | Flags.Lifted | Flags.Protected | Flags.JavaStatic |
Flags.ExpandedName | Flags.Bridge | Flags.VBridge | Flags.Private | Flags.Macro
Flags.Bridge | Flags.VBridge | Flags.Private | Flags.Macro
}.bits


Expand Down Expand Up @@ -544,8 +544,8 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def toTermName: Name = n.toTermName
def dropModule: Name = n.stripModuleClassSuffix

def len: Int = n.length
def offset: Int = n.start
def len: Int = n.toSimpleName.length
def offset: Int = n.toSimpleName.start
def isTermName: Boolean = n.isTermName
def startsWith(s: String): Boolean = n.startsWith(s)
}
Expand All @@ -557,7 +557,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
def fullName: String = sym.showFullName
def simpleName: Name = sym.name
def javaSimpleName: Name = toDenot(sym).name // addModuleSuffix(simpleName.dropLocal)
def javaBinaryName: Name = toDenot(sym).fullNameSeparated("/") // addModuleSuffix(fullNameInternal('/'))
def javaBinaryName: Name = javaClassName.replace('.', '/').toTypeName // TODO: can we make this a string? addModuleSuffix(fullNameInternal('/'))
def javaClassName: String = toDenot(sym).fullName.toString// addModuleSuffix(fullNameInternal('.')).toString
def name: Name = sym.name
def rawname: Name = {
Expand Down Expand Up @@ -794,7 +794,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma

def memberInfo(s: Symbol): Type = tp.memberInfo(s)

def decls: List[Symbol] = tp.decls.map(_.symbol).toList
def decls: List[Symbol] = tp.decls.toList

def members: List[Symbol] =
tp.memberDenots(takeAllFilter, (name, buf) => buf ++= tp.member(name).alternatives).map(_.symbol).toList
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/FromTasty.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down
17 changes: 9 additions & 8 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import core._
import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._
import Decorators._
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName}
import language.higherKinds
import typer.FrontEnd
import collection.mutable.ListBuffer
Expand Down Expand Up @@ -128,7 +129,7 @@ object desugar {
def makeImplicitParameters(tpts: List[Tree], forPrimaryConstructor: Boolean)(implicit ctx: Context) =
for (tpt <- tpts) yield {
val paramFlags: FlagSet = if (forPrimaryConstructor) PrivateLocalParamAccessor else Param
val epname = ctx.freshName(nme.EVIDENCE_PARAM_PREFIX).toTermName
val epname = EvidenceParamName.fresh()
ValDef(epname, tpt, EmptyTree).withFlags(paramFlags | Implicit)
}

Expand Down Expand Up @@ -186,7 +187,7 @@ object desugar {
case (vparam :: vparams) :: vparamss1 =>
def defaultGetter: DefDef =
DefDef(
name = meth.name.defaultGetterName(n),
name = DefaultGetterName(meth.name, n),
tparams = meth.tparams.map(tparam => dropContextBound(toDefParam(tparam))),
vparamss = takeUpTo(normalizedVparamss.nestedMap(toDefParam), n),
tpt = TypeTree(),
Expand Down Expand Up @@ -230,7 +231,7 @@ object desugar {
private def evidenceParams(meth: DefDef)(implicit ctx: Context): List[ValDef] =
meth.vparamss.reverse match {
case (vparams @ (vparam :: _)) :: _ if vparam.mods is Implicit =>
vparams.dropWhile(!_.name.startsWith(nme.EVIDENCE_PARAM_PREFIX))
vparams.dropWhile(!_.name.is(EvidenceParamName))
case _ =>
Nil
}
Expand All @@ -244,7 +245,7 @@ object desugar {
def typeDef(tdef: TypeDef)(implicit ctx: Context): Tree = {
if (tdef.mods is PrivateLocalParam) {
val tparam = cpy.TypeDef(tdef)(name = tdef.name.expandedName(ctx.owner))
.withMods(tdef.mods &~ PrivateLocal | ExpandedName)
.withMods(tdef.mods &~ PrivateLocal)
val alias = cpy.TypeDef(tdef)(rhs = refOfDef(tparam))
.withMods(tdef.mods & VarianceFlags | PrivateLocalParamAccessor | Synthetic)
Thicket(tparam, alias)
Expand Down Expand Up @@ -402,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)
}
Expand Down Expand Up @@ -635,7 +636,7 @@ object desugar {
case (named, tpt) :: Nil =>
derivedValDef(original, named, tpt, matchExpr, mods)
case _ =>
val tmpName = ctx.freshName().toTermName
val tmpName = UniqueName.fresh()
val patMods =
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal else EmptyFlags)
val firstDef =
Expand Down Expand Up @@ -810,7 +811,7 @@ object desugar {
val selectPos = Position(left.pos.start, op.pos.end, op.pos.start)
Apply(Select(left, op.name).withPos(selectPos), args)
} else {
val x = ctx.freshName().toTermName
val x = UniqueName.fresh()
val selectPos = Position(op.pos.start, right.pos.end, op.pos.start)
new InfixOpBlock(
ValDef(x, TypeTree(), left).withMods(synthetic),
Expand Down Expand Up @@ -888,7 +889,7 @@ object desugar {
case id: Ident if isVarPattern(id) && id.name != nme.WILDCARD => (id, id)
case Typed(id: Ident, _) if isVarPattern(id) && id.name != nme.WILDCARD => (pat, id)
case _ =>
val name = ctx.freshName().toTermName
val name = UniqueName.fresh()
(Bind(name, pat), Ident(name))
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ object Trees {
def namePos =
if (pos.exists)
if (rawMods.is(Synthetic)) Position(pos.point, pos.point)
else Position(pos.point, pos.point + name.stripModuleClassSuffix.length, pos.point)
else Position(pos.point, pos.point + name.stripModuleClassSuffix.lastPart.length, pos.point)
else pos
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Denotations._, Decorators._, DenotTransformers._
import collection.mutable
import util.{Property, SourceFile, NoSource}
import typer.ErrorReporting._
import NameKinds.TempResultName

import scala.annotation.tailrec
import scala.io.Codec
Expand Down Expand Up @@ -897,7 +898,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def evalOnce(tree: Tree)(within: Tree => Tree)(implicit ctx: Context) = {
if (isIdempotentExpr(tree)) within(tree)
else {
val vdef = SyntheticValDef(ctx.freshName("ev$").toTermName, tree)
val vdef = SyntheticValDef(TempResultName.fresh(), tree)
Block(vdef :: Nil, within(Ident(vdef.namedType)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class ScalaSettings extends Settings.SettingGroup {
val YcheckMods = BooleanSetting("-Ycheck-mods", "Check that symbols and their defining trees have modifiers in sync")
val debug = BooleanSetting("-Ydebug", "Increase the quantity of debugging output.")
val debugAlias = BooleanSetting("-Ydebug-alias", "Never follow alias when printing types")
val debugNames = BooleanSetting("-YdebugNames", "Show name-space indicators when printing names")
val debugTrace = BooleanSetting("-Ydebug-trace", "Trace core operations")
val debugFlags = BooleanSetting("-Ydebug-flags", "Print all flags of definitions")
val debugNames = BooleanSetting("-Ydebug-names", "Show internal representation of names")
val debugOwners = BooleanSetting("-Ydebug-owners", "Print all owners of definitions (requires -Yprint-syms)")
val termConflict = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error")
val log = PhasesSetting("-Ylog", "Log operations during")
Expand Down
5 changes: 1 addition & 4 deletions compiler/src/dotty/tools/dotc/core/Contexts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,6 @@ object Contexts {
protected def freshNames_=(freshNames: FreshNameCreator) = _freshNames = freshNames
def freshNames: FreshNameCreator = _freshNames

def freshName(prefix: String = ""): String = freshNames.newName(prefix)
def freshName(prefix: Name): String = freshName(prefix.toString)

/** A map in which more contextual properties can be stored */
private var _moreProperties: Map[Key[Any], Any] = _
protected def moreProperties_=(moreProperties: Map[Key[Any], Any]) = _moreProperties = moreProperties
Expand Down Expand Up @@ -297,7 +294,7 @@ object Contexts {

/** Is this a context that introduces a non-empty scope? */
def isNonEmptyScopeContext: Boolean =
(this.scope ne outer.scope) && this.scope.nonEmpty
(this.scope ne outer.scope) && !this.scope.isEmpty

/** Leave message in diagnostics buffer if it exists */
def diagnose(str: => String) =
Expand Down
42 changes: 11 additions & 31 deletions compiler/src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Definitions {
enterTypeField(cls, name, flags | ClassTypeParamCreationFlags, scope)

private def enterSyntheticTypeParam(cls: ClassSymbol, paramFlags: FlagSet, scope: MutableScope, suffix: String = "T0") =
enterTypeParam(cls, suffix.toTypeName.expandedName(cls), ExpandedName | paramFlags, scope)
enterTypeParam(cls, suffix.toTypeName.expandedName(cls), paramFlags, scope)

// NOTE: Ideally we would write `parentConstrs: => Type*` but SIP-24 is only
// implemented in Dotty and not in Scala 2.
Expand Down Expand Up @@ -108,7 +108,7 @@ class Definitions {
* def apply(implicit $x0: T0, ..., $x{N_1}: T{N-1}): R
* }
*/
private def newFunctionNTrait(name: TypeName) = {
def newFunctionNTrait(name: TypeName) = {
val completer = new LazyType {
def complete(denot: SymDenotation)(implicit ctx: Context): Unit = {
val cls = denot.asClass.classSymbol
Expand All @@ -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.firstPart.startsWith(str.ImplicitFunction)) {
val superTrait =
FunctionType(arity).appliedTo(argParams.map(_.typeRef) ::: resParam.typeRef :: Nil)
(ImplicitMethodType, ctx.normalizeToClassRefs(superTrait :: Nil, cls, decls))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -933,23 +932,6 @@ class Definitions {

// ----- Initialization ---------------------------------------------------

/** Give the scala package a scope where a FunctionN trait is automatically
* added when someone looks for it.
*/
private def makeScalaSpecial()(implicit ctx: Context) = {
val oldInfo = ScalaPackageClass.classInfo
val oldDecls = oldInfo.decls
val newDecls = new MutableScope(oldDecls) {
override def lookupEntry(name: Name)(implicit ctx: Context): ScopeEntry = {
val res = super.lookupEntry(name)
if (res == null && name.isTypeName && name.isSyntheticFunction)
newScopeEntry(newFunctionNTrait(name.asTypeName))
else res
}
}
ScalaPackageClass.info = oldInfo.derivedClassInfo(decls = newDecls)
}

/** Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe */
lazy val syntheticScalaClasses = List(
AnyClass,
Expand Down Expand Up @@ -977,8 +959,6 @@ class Definitions {
def init()(implicit ctx: Context) = {
this.ctx = ctx
if (!_isInitialized) {
makeScalaSpecial()

// force initialization of every symbol that is synthesized or hijacked by the compiler
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses()

Expand Down
46 changes: 31 additions & 15 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ package core

import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation }
import Contexts.{Context, ContextBase}
import Names.{Name, PreName}
import Names.TypeName
import Names._
import NameOps._
import NameKinds._
import StdNames._
import Symbols.NoSymbol
import Symbols._
Expand Down Expand Up @@ -1171,27 +1172,42 @@ object Denotations {
* if generateStubs is set, generates stubs for missing top-level symbols
*/
def staticRef(path: Name, generateStubs: Boolean = true)(implicit ctx: Context): Denotation = {
def recur(path: Name, len: Int): Denotation = {
val point = path.lastIndexOf('.', len - 1)
val owner =
if (point > 0) recur(path.toTermName, point).disambiguate(_.info.isParameterless)
else if (path.isTermName) defn.RootClass.denot
else defn.EmptyPackageClass.denot
def select(prefix: Denotation, selector: Name): Denotation = {
val owner = prefix.disambiguate(_.info.isParameterless)
if (owner.exists) {
val name = path slice (point + 1, len)
val result = owner.info.member(name)
if (result ne NoDenotation) result
val result = owner.info.member(selector)
if (result.exists) result
else {
val alt =
if (generateStubs) missingHook(owner.symbol.moduleClass, name)
if (generateStubs) missingHook(owner.symbol.moduleClass, selector)
else NoSymbol
if (alt.exists) alt.denot
else MissingRef(owner, name)
if (alt.exists) alt.denot else MissingRef(owner, selector)
}
}
else owner
}
recur(path, path.length)
def recur(path: Name, wrap: TermName => Name = identity): Denotation = path match {
case path: TypeName =>
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 qn @ AnyQualifiedName(prefix, _) =>
recur(prefix, n => wrap(qn.info.mkString(n).toTermName))
case path: SimpleTermName =>
def recurSimple(len: Int, wrap: TermName => Name): Denotation = {
val point = path.lastIndexOf('.', len - 1)
val selector = wrap(path.slice(point + 1, len).asTermName)
val prefix =
if (point > 0) recurSimple(point, identity)
else if (selector.isTermName) defn.RootClass.denot
else defn.EmptyPackageClass.denot
select(prefix, selector)
}
recurSimple(path.length, wrap)
}
recur(path)
}

/** If we are looking for a non-existing term name in a package,
Expand Down
Loading