aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Applications.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-03 17:50:26 +0100
committerMartin Odersky <odersky@gmail.com>2014-03-03 17:50:26 +0100
commitf3dacf968bc28f5f47612f75562a1a600e511815 (patch)
tree59f93971f168360b5bbc53a1934535620b6847db /src/dotty/tools/dotc/typer/Applications.scala
parentf0d5662e3f8668ed33bc7442951558d861e56073 (diff)
downloaddotty-f3dacf968bc28f5f47612f75562a1a600e511815.tar.gz
dotty-f3dacf968bc28f5f47612f75562a1a600e511815.tar.bz2
dotty-f3dacf968bc28f5f47612f75562a1a600e511815.zip
Fix of #34
The root cause of #34 was that we took a type argument which was an existential type. These are returned as type bounds, which make no sense in the calling context. To avoid that problem in the future, `typeArgs` got renamed to `argInfos`, so it is clear we get an info, not necessarily a value type. There are also added method `argTypes`, `argTypesLo`, `argTypesHi`, which return a type, but either throw an exception or return a lower/upper approximation of the argument is an existential type. There's another issue that the existential type only arose when compiling the same couple fo files the seciond time. We need to chase that one down separately.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 4b43aa8b7..4d7bc8976 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -24,6 +24,7 @@ import EtaExpansion._
import collection.mutable
import reflect.ClassTag
import config.Printers._
+import TypeApplications._
import language.implicitConversions
object Applications {
@@ -266,7 +267,7 @@ trait Applications extends Compatibility { self: Typer =>
case arg :: Nil if isVarArg(arg) =>
addTyped(arg, formal)
case _ =>
- val elemFormal = formal.typeArgs.head
+ val elemFormal = formal.argTypesLo.head
args foreach (addTyped(_, elemFormal))
makeVarArg(args.length, elemFormal)
}
@@ -609,7 +610,7 @@ trait Applications extends Compatibility { self: Typer =>
if (extractorMemberType(unapplyResult, nme.isDefined) isRef defn.BooleanClass) {
if (getTp.exists)
if (unapply.symbol.name == nme.unapplySeq) {
- val seqArg = getTp.firstBaseTypeArg(defn.SeqClass)
+ val seqArg = boundsToHi(getTp.firstBaseArgInfo(defn.SeqClass))
if (seqArg.exists) return args map Function.const(seqArg)
}
else return getSelectors(getTp)
@@ -683,6 +684,7 @@ trait Applications extends Compatibility { self: Typer =>
}
var argTypes = unapplyArgs(unapplyApp.tpe)
+ for (argType <- argTypes) assert(!argType.isInstanceOf[TypeBounds], unapplyApp.tpe.show)
val bunchedArgs = argTypes match {
case argType :: Nil if argType.isRepeatedParam => untpd.SeqLiteral(args) :: Nil
case _ => args
@@ -770,7 +772,7 @@ trait Applications extends Compatibility { self: Typer =>
val tparams = ctx.newTypeParams(alt1.symbol.owner, tp1.paramNames, EmptyFlags, bounds)
isAsSpecific(alt1, tp1.instantiate(tparams map (_.typeRef)), alt2, tp2)
case tp1: MethodType =>
- def repeatedToSingle(tp: Type) = if (tp.isRepeatedParam) tp.typeArgs.head else tp
+ def repeatedToSingle(tp: Type) = if (tp.isRepeatedParam) tp.argTypesHi.head else tp
isApplicable(alt2, tp1.paramTypes map repeatedToSingle, WildcardType) ||
tp1.paramTypes.isEmpty && tp2.isInstanceOf[MethodOrPoly]
case _ =>