aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeApplications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-02-20 09:50:07 +0100
committerMartin Odersky <odersky@gmail.com>2014-02-21 18:42:50 +0100
commit84c01ff493b81c0097d1707f64622ade028e53aa (patch)
treef08e31e36d50c41deec70c2b02285d8979acf5ee /src/dotty/tools/dotc/core/TypeApplications.scala
parent889bca2de4678194ef28e24dc3513e94b5363616 (diff)
downloaddotty-84c01ff493b81c0097d1707f64622ade028e53aa.tar.gz
dotty-84c01ff493b81c0097d1707f64622ade028e53aa.tar.bz2
dotty-84c01ff493b81c0097d1707f64622ade028e53aa.zip
Reverted: Avoid using TypeBounds in alias refinements.
The idea is to use the alias itself. This cuts down on # of typebounds created and makes operations on refined infos and applied types more direct. (reverted from commit 81f31f9b71bc4466d3f04f5ce28ef94051688ecd)
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeApplications.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeApplications.scala34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/dotty/tools/dotc/core/TypeApplications.scala b/src/dotty/tools/dotc/core/TypeApplications.scala
index 7ecabe6f5..9f742fcc2 100644
--- a/src/dotty/tools/dotc/core/TypeApplications.scala
+++ b/src/dotty/tools/dotc/core/TypeApplications.scala
@@ -92,7 +92,7 @@ class TypeApplications(val self: Type) extends AnyVal {
println(s"precomplete decls = ${self.typeSymbol.decls.toList.map(_.denot).mkString("\n ")}")
}
val tparam = tparams.head
- val tp1 = tp.paramRefinement(tparam, arg)
+ val tp1 = RefinedType(tp, tparam.name, arg.toBounds(tparam))
recur(tp1, tparams.tail, args1)
case nil => tp
}
@@ -122,20 +122,17 @@ class TypeApplications(val self: Type) extends AnyVal {
final def appliedTo(arg: Type)(implicit ctx: Context): Type = appliedTo(arg :: Nil)
final def appliedTo(arg1: Type, arg2: Type)(implicit ctx: Context): Type = appliedTo(arg1 :: arg2 :: Nil)
- /** Add a refinement to this type, which reflects `arg` being used as an argument for
- * type parameter `tparam`.
+ /** Turn this type, which is used as an argument for
+ * type parameter `tparam`, into a TypeBounds RHS
*/
- final def paramRefinement(tparam: Symbol, arg: Type)(implicit ctx: Context): RefinedType = arg match {
- case arg: TypeBounds => // this can happen for wildcard args
- RefinedType(self, tparam.name, arg)
+ final def toBounds(tparam: Symbol)(implicit ctx: Context): TypeBounds = self match {
+ case self: TypeBounds => // this can happen for wildcard args
+ self
case _ =>
val v = tparam.variance
- if (v > 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam))
- RefinedType(self, tparam.name, TypeBounds.upper(arg))
- else if (v < 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam))
- RefinedType(self, tparam.name, TypeBounds.lower(arg))
- else
- RefinedType.compact(self, tparam.name, arg, v)
+ if (v > 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam)) TypeBounds.upper(self)
+ else if (v < 0 && !(tparam is Local) && !(tparam is ExpandedTypeParam)) TypeBounds.lower(self)
+ else TypeAlias(self, v)
}
/** The type arguments of the base type instance wrt `base` of this type */
@@ -174,7 +171,7 @@ class TypeApplications(val self: Type) extends AnyVal {
if (tparams == null) tparams = tycon.typeParams
if (buf.size < tparams.length) {
val tparam = tparams(buf.size)
- if (name == tparam.name) buf += tp.argTypeOfRefinement(tparam)
+ if (name == tparam.name) buf += tp.refinedInfo.argType(tparam)
else null
} else null
}
@@ -213,17 +210,6 @@ class TypeApplications(val self: Type) extends AnyVal {
NoType
}
- /** If the refinement is the image of a type argument to type parameter `tparam`,
- * recover the type argument, otherwise NoType.
- */
- final def argTypeOfRefinement(tparam: Symbol)(implicit ctx: Context): Type = self match {
- case self: RefinedType =>
- if (self.isAliasRefinement) self.compactInfo
- else self.refinedInfo.argType(tparam)
- case _ =>
- NoType
- }
-
/** The element type of a sequence or array */
def elemType(implicit ctx: Context): Type =
firstBaseTypeArg(defn.SeqClass) orElse firstBaseTypeArg(defn.ArrayClass)