summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2009-12-20 18:11:24 +0000
committerMartin Odersky <odersky@gmail.com>2009-12-20 18:11:24 +0000
commit4faa918259ae61798e7c144db0309e723f827cc8 (patch)
treeb6b71e3346966b09e0aeec982baf072088266ae5 /src/compiler
parent7ddabed25a5e559d660a9de53ddf2a3ddabf209c (diff)
downloadscala-4faa918259ae61798e7c144db0309e723f827cc8.tar.gz
scala-4faa918259ae61798e7c144db0309e723f827cc8.tar.bz2
scala-4faa918259ae61798e7c144db0309e723f827cc8.zip
Closed #2718 and #2765. review by extempore.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Types.scala2
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala29
2 files changed, 12 insertions, 19 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala
index 513ed34ff9..7350410eeb 100644
--- a/src/compiler/scala/tools/nsc/symtab/Types.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Types.scala
@@ -1942,7 +1942,7 @@ A type's typeSymbol should never be inspected directly.
}
private def wildcardArgsString(available: Set[Symbol], args: List[Type]): List[String] = args match {
- case TypeRef(_, sym, _) :: args1 if (quantified contains sym) =>
+ case TypeRef(_, sym, _) :: args1 if (available contains sym) =>
("_"+sym.infoString(sym.info)) :: wildcardArgsString(available - sym, args1)
case arg :: args1 if !(quantified exists (arg contains _)) =>
arg.toString :: wildcardArgsString(available, args1)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 542b2d04c2..c43d9c8788 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2474,9 +2474,17 @@ trait Typers { self: Analyzer =>
}
val (unappFormal, freeVars) = freshArgType(unappType)
val context1 = context.makeNewScope(context.tree, context.owner)
- freeVars foreach(sym => context1.scope.enter(sym))
+ freeVars foreach context1.scope.enter
val typer1 = newTyper(context1)
- arg.tpe = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe)
+ val pattp = typer1.infer.inferTypedPattern(tree.pos, unappFormal, arg.tpe)
+ // turn any unresolved type variables in freevars into existential skolems
+ val skolems = freeVars map { fv =>
+ val skolem = new TypeSkolem(context1.owner, fun.pos, fv.name, fv)
+ skolem.setInfo(fv.info.cloneInfo(skolem))
+ .setFlag(fv.flags | EXISTENTIAL).resetFlag(PARAM)
+ skolem
+ }
+ arg.tpe = pattp.substSym(freeVars, skolems)
//todo: replace arg with arg.asInstanceOf[inferTypedPattern(unappFormal, arg.tpe)] instead.
argDummy.setInfo(arg.tpe) // bq: this line fixed #1281. w.r.t. comment ^^^, maybe good enough?
}
@@ -2523,25 +2531,10 @@ trait Typers { self: Analyzer =>
if (formals1.length == args.length) {
val args1 = typedArgs(args, mode, formals0, formals1)
if (!isFullyDefined(pt)) assert(false, tree+" ==> "+UnApply(fun1, args1)+", pt = "+pt)
- // <pending-change>
- // this would be a better choice (from #1196), but fails due to (broken?) refinements
val itype = glb(List(pt, arg.tpe))
- // </pending-change>
// restore old type (arg is a dummy tree, just needs to pass typechecking)
arg.tpe = oldArgType
- UnApply(fun1, args1) setPos tree.pos setType itype //pt
- //
- // if you use the better itype, then the following happens.
- // the required type looks wrong...
- //
- ///files/pos/bug0646.scala [FAILED]
- //
- //failed with type mismatch;
- // found : scala.xml.NodeSeq{ ... }
- // required: scala.xml.NodeSeq{ ... } with scala.xml.NodeSeq{ ... } with scala.xml.Node on: temp3._data().==("Blabla").&&({
- // exit(temp0);
- // true
- //})
+ UnApply(fun1, args1) setPos tree.pos setType itype
} else {
errorTree(tree, "wrong number of arguments for "+treeSymTypeMsg(fun))
}