aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeOps.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-12-07 13:42:22 +0100
committerMartin Odersky <odersky@gmail.com>2015-12-14 14:30:07 +0100
commit083b949f5710d363859892cb94fa60527e7516cd (patch)
tree4888e6a435c04c1315fdb18a2d4d628064c84ea8 /src/dotty/tools/dotc/core/TypeOps.scala
parentef66db271c573adb0fc47dcce76bbac0fcc59ed7 (diff)
downloaddotty-083b949f5710d363859892cb94fa60527e7516cd.tar.gz
dotty-083b949f5710d363859892cb94fa60527e7516cd.tar.bz2
dotty-083b949f5710d363859892cb94fa60527e7516cd.zip
Make all arg bindings have flag BaseTypeArg.
It's unclear what the prupose of the previous restriction to Local only was. And we need it to be set for all arg bindings so that immutable.Set does not fail with a variance error.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeOps.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeOps.scala21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala
index f3884e11a..fae8df04d 100644
--- a/src/dotty/tools/dotc/core/TypeOps.scala
+++ b/src/dotty/tools/dotc/core/TypeOps.scala
@@ -384,10 +384,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
denot.info = info
}
}
- val typeArgFlag = if (formal is Local) TypeArgument else EmptyFlags
val sym = ctx.newSymbol(
cls, formal.name,
- formal.flagsUNSAFE & RetainedTypeArgFlags | typeArgFlag | Override,
+ formal.flagsUNSAFE & RetainedTypeArgFlags | BaseTypeArg | Override,
lazyInfo,
coord = cls.coord)
cls.enter(sym, decls)
@@ -463,14 +462,20 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
case to @ TypeBounds(lo1, hi1) if lo1 eq hi1 =>
for (pref <- prefs)
for (argSym <- pref.decls)
- if (argSym is TypeArgument)
+ if (argSym is BaseTypeArg)
forwardRef(argSym, from, to, cls, decls)
case _ =>
}
// println(s"normalizing $parents of $cls in ${cls.owner}") // !!! DEBUG
+
+ // A map consolidating all refinements arising from parent type parameters
var refinements: SimpleMap[TypeName, Type] = SimpleMap.Empty
- var formals: SimpleMap[TypeName, Symbol] = SimpleMap.Empty
+
+ // A map of all formal type parameters of base classes that get refined
+ var formals: SimpleMap[TypeName, Symbol] = SimpleMap.Empty // A map of all formal parent parameter
+
+ // Strip all refinements from parent type, populating `refinements` and `formals` maps.
def normalizeToRef(tp: Type): TypeRef = tp.dealias match {
case tp: TypeRef =>
tp
@@ -488,13 +493,17 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
throw new TypeError(s"unexpected parent type: $tp")
}
val parentRefs = parents map normalizeToRef
+
+ // Enter all refinements into current scope.
refinements foreachBinding { (name, refinedInfo) =>
assert(decls.lookup(name) == NoSymbol, // DEBUG
s"redefinition of ${decls.lookup(name).debugString} in ${cls.showLocated}")
enterArgBinding(formals(name), refinedInfo, cls, decls)
}
- // These two loops cannot be fused because second loop assumes that
- // all arguments have been entered in `decls`.
+ // Forward definitions in super classes that have one of the refined paramters
+ // as aliases directly to the refined info.
+ // Note that this cannot be fused bwith the previous loop because we now
+ // assume that all arguments have been entered in `decls`.
refinements foreachBinding { (name, refinedInfo) =>
forwardRefs(formals(name), refinedInfo, parentRefs)
}