aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-11-14 18:45:01 +0100
committerMartin Odersky <odersky@gmail.com>2013-11-14 18:45:01 +0100
commitba87f4e2c5b911112e3f415e184c657241d47ad5 (patch)
tree91ba8de0d58ba0927c849f3d0c76f1ec0d458746 /src/dotty/tools
parent2e1f8ab9eb96a61ec5343a79d3a1d118113d308e (diff)
downloaddotty-ba87f4e2c5b911112e3f415e184c657241d47ad5.tar.gz
dotty-ba87f4e2c5b911112e3f415e184c657241d47ad5.tar.bz2
dotty-ba87f4e2c5b911112e3f415e184c657241d47ad5.zip
derivedNamedType -> derivedSelect
Performing refined/typeref reduction everywhere
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Substituters.scala18
-rw-r--r--src/dotty/tools/dotc/core/Types.scala9
-rw-r--r--src/dotty/tools/dotc/core/transform/Erasure.scala2
3 files changed, 17 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala
index 26095450e..27a2722f2 100644
--- a/src/dotty/tools/dotc/core/Substituters.scala
+++ b/src/dotty/tools/dotc/core/Substituters.scala
@@ -13,7 +13,7 @@ trait Substituters { this: Context =>
if (tp.binder eq from) tp.copy(to.asInstanceOf[tp.BT]) else tp
case tp: NamedType =>
if (tp.symbol.isStatic) tp
- else tp.derivedNamedType(subst(tp.prefix, from, to, map))
+ else tp.derivedSelect(subst(tp.prefix, from, to, map))
case _: ThisType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -29,7 +29,7 @@ trait Substituters { this: Context =>
val sym = tp.symbol
if (sym eq from) return to
if (sym.isStatic && !from.isStatic) tp
- else tp.derivedNamedType(subst1(tp.prefix, from, to, map))
+ else tp.derivedSelect(subst1(tp.prefix, from, to, map))
case _: ThisType | _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -47,7 +47,7 @@ trait Substituters { this: Context =>
if (sym eq from1) return to1
if (sym eq from2) return to2
if (sym.isStatic && !from1.isStatic && !from2.isStatic) tp
- else tp.derivedNamedType(subst2(tp.prefix, from1, to1, from2, to2, map))
+ else tp.derivedSelect(subst2(tp.prefix, from1, to1, from2, to2, map))
case _: ThisType | _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -70,7 +70,7 @@ trait Substituters { this: Context =>
ts = ts.tail
}
if (sym.isStatic && !existsStatic(from)) tp
- else tp.derivedNamedType(subst(tp.prefix, from, to, map))
+ else tp.derivedSelect(subst(tp.prefix, from, to, map))
case _: ThisType | _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -93,7 +93,7 @@ trait Substituters { this: Context =>
ts = ts.tail
}
if (sym.isStatic && !existsStatic(from)) tp
- else tp.derivedNamedType(substSym(tp.prefix, from, to, map))
+ else tp.derivedSelect(substSym(tp.prefix, from, to, map))
case _: ThisType | _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -109,7 +109,7 @@ trait Substituters { this: Context =>
if (clazz eq from) to else tp
case tp: NamedType =>
if (tp.symbol.isStaticOwner) tp
- else tp.derivedNamedType(substThis(tp.prefix, from, to, map))
+ else tp.derivedSelect(substThis(tp.prefix, from, to, map))
case _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -125,7 +125,7 @@ trait Substituters { this: Context =>
if (rt eq from) to else tp
case tp: NamedType =>
if (tp.symbol.isStatic) tp
- else tp.derivedNamedType(substThis(tp.prefix, from, to, map))
+ else tp.derivedSelect(substThis(tp.prefix, from, to, map))
case _: ThisType | _: BoundType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -141,7 +141,7 @@ trait Substituters { this: Context =>
if (tp == from) to else tp
case tp: NamedType =>
if (tp.symbol.isStatic) tp
- else tp.derivedNamedType(substParam(tp.prefix, from, to, map))
+ else tp.derivedSelect(substParam(tp.prefix, from, to, map))
case _: ThisType | NoPrefix =>
tp
case tp: RefinedType =>
@@ -157,7 +157,7 @@ trait Substituters { this: Context =>
if (tp.binder == from) to(tp.paramNum) else tp
case tp: NamedType =>
if (tp.symbol.isStatic) tp
- else tp.derivedNamedType(substParams(tp.prefix, from, to, map))
+ else tp.derivedSelect(substParams(tp.prefix, from, to, map))
case _: ThisType | NoPrefix | _: RefinedThis =>
tp
case tp: RefinedType =>
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 03b55736c..a230e9bbd 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -690,7 +690,7 @@ object Types {
if (res.exists) res else NamedType.withSym(this, sym)
}
- private def lookupRefined(pre: Type, name: Name)(implicit ctx: Context): Type = pre.stripTypeVar match {
+ protected def lookupRefined(pre: Type, name: Name)(implicit ctx: Context): Type = pre.stripTypeVar match {
case pre: RefinedType =>
if (pre.refinedName ne name) lookupRefined(pre.parent, name)
else pre.refinedInfo match {
@@ -1452,13 +1452,18 @@ object Types {
ctx.underlyingRecursions -= 1
}
+/* not needed
def derivedNamedType(prefix: Type)(implicit ctx: Context): NamedType =
if (prefix eq this.prefix) this
else newLikeThis(prefix)
+*/
def derivedSelect(prefix: Type)(implicit ctx: Context): Type =
if (prefix eq this.prefix) this
- else prefix select this.name
+ else {
+ val res = lookupRefined(this, name)
+ if (res.exists) res else newLikeThis(prefix)
+ }
/** Create a NamedType of the same kind as this type, if possible,
* but with a new prefix. For HasFixedSym instances another such
diff --git a/src/dotty/tools/dotc/core/transform/Erasure.scala b/src/dotty/tools/dotc/core/transform/Erasure.scala
index 201dd107f..a0438fc4f 100644
--- a/src/dotty/tools/dotc/core/transform/Erasure.scala
+++ b/src/dotty/tools/dotc/core/transform/Erasure.scala
@@ -38,7 +38,7 @@ object Erasure {
if (sym.isClass)
/*if (sym.isDerivedValueClass) eraseDerivedValueClassRef(tref)
else */if (sym.owner is Package) normalizeClass(sym.asClass).typeConstructor
- else tp.derivedNamedType(erasure(tp.prefix))
+ else tp.derivedSelect(erasure(tp.prefix))
else erasure(tp.info)
case tp: RefinedType =>
val parent = tp.parent