aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/core/Denotations.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-23 17:14:39 +0100
committerMartin Odersky <odersky@gmail.com>2017-04-11 09:33:10 +0200
commitc27cbd16e6fd3cc00e603aebef95f477684b3390 (patch)
tree5a2a039e2249812253014ddd5fe4381ad817dd53 /compiler/src/dotty/tools/dotc/core/Denotations.scala
parentbbc84eabcd244179299ad435b6e9d7473e5ff892 (diff)
downloaddotty-c27cbd16e6fd3cc00e603aebef95f477684b3390.tar.gz
dotty-c27cbd16e6fd3cc00e603aebef95f477684b3390.tar.bz2
dotty-c27cbd16e6fd3cc00e603aebef95f477684b3390.zip
Bug fixes
nameddefaults.scala now compiles without crashing
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/Denotations.scala')
-rw-r--r--compiler/src/dotty/tools/dotc/core/Denotations.scala43
1 files changed, 28 insertions, 15 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/Denotations.scala b/compiler/src/dotty/tools/dotc/core/Denotations.scala
index 7341b96af..a679cad6f 100644
--- a/compiler/src/dotty/tools/dotc/core/Denotations.scala
+++ b/compiler/src/dotty/tools/dotc/core/Denotations.scala
@@ -4,8 +4,8 @@ package core
import SymDenotations.{ SymDenotation, ClassDenotation, NoDenotation }
import Contexts.{Context, ContextBase}
-import Names.{Name, PreName}
-import Names.TypeName
+import Names._
+import NameOps._
import StdNames._
import Symbols.NoSymbol
import Symbols._
@@ -1171,27 +1171,40 @@ 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: Name => 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.Qualified(selector, ".")) =>
+ select(recur(prefix), wrap(selector))
+ case path: SimpleTermName =>
+ def recurSimple(len: Int, wrap: Name => Name): Denotation = {
+ val point = path.lastIndexOf('.', len - 1)
+ val selector = wrap(path.slice(point + 1, len))
+ 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.unmangleClassName)
}
/** If we are looking for a non-existing term name in a package,