diff options
author | Martin Odersky <odersky@gmail.com> | 2008-01-21 22:19:58 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-01-21 22:19:58 +0000 |
commit | fdd9bd04ed7eddf942474624e41eeb0490146527 (patch) | |
tree | 4a67d68fad13e01ab116224506683133a64dc529 /src/compiler | |
parent | 966d503017a375a03ab0fc21dd7fb9788077f5c0 (diff) | |
download | scala-fdd9bd04ed7eddf942474624e41eeb0490146527.tar.gz scala-fdd9bd04ed7eddf942474624e41eeb0490146527.tar.bz2 scala-fdd9bd04ed7eddf942474624e41eeb0490146527.zip |
fixed t0392; un-deprecated Iterator.fromArray (...
fixed t0392; un-deprecated Iterator.fromArray (I don't see a good
alternative?)
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/Types.scala | 26 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 13 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Types.scala b/src/compiler/scala/tools/nsc/symtab/Types.scala index 8e754b95cd..0e37ef6dc5 100644 --- a/src/compiler/scala/tools/nsc/symtab/Types.scala +++ b/src/compiler/scala/tools/nsc/symtab/Types.scala @@ -421,8 +421,10 @@ trait Types { } */ case tp => - //Console.println("" + this + ".memberType(" + sym +":" + sym.tpe +")" + sym.ownerChain);//debug - tp.asSeenFrom(this, sym.owner) +// if (sym.name.toString == "c") print(this + ".memberType(" + sym +":" + sym.tpe +")" + sym.ownerChain);//debug + val res = tp.asSeenFrom(this, sym.owner) +// if (sym.name.toString == "c") println(" = "+res) + res } } @@ -651,7 +653,7 @@ trait Types { (bcs eq bcs0) || sym.getFlag(PRIVATE | LOCAL) != (PRIVATE | LOCAL) || (bcs0.head.hasTransOwner(bcs.head)))) { - if (name.isTypeName || stableOnly) { + if (name.isTypeName || stableOnly && sym.isStable) { checkMalformedSwitch = savedCheckMalformedSwitch if (util.Statistics.enabled) findMemberMillis = findMemberMillis + currentTime - startTime @@ -1701,7 +1703,7 @@ A type's typeSymbol should never be inspected directly. val tvars = quantified map (tparam => new TypeVar(tparam.tpe, new TypeConstraint)) val underlying1 = underlying.instantiateTypeParams(quantified, tvars) op(underlying1) && { - solve(tvars, quantified, quantified map (x => 0), false) + solve(tvars, quantified, quantified map (x => 0), false) && isWithinBounds(NoPrefix, NoSymbol, quantified, tvars map (_.constr.inst)) } } @@ -3066,7 +3068,7 @@ A type's typeSymbol should never be inspected directly. } val rebind = rebind0.suchThat(sym => sym.isType || sym.isStable) if (rebind == NoSymbol) { - if (settings.debug.value) Console.println("" + phase + " " + phase.flatClasses+sym.owner+sym.name) + if (settings.debug.value) Console.println("" + phase + " " +phase.flatClasses+sym.owner+sym.name+" "+sym.isType) throw new MalformedType(pre, sym.nameString) } rebind @@ -3585,6 +3587,10 @@ A type's typeSymbol should never be inspected directly. skolemizationLevel -= 1 } case (_, et: ExistentialType) => +// println("<<< "+tp1+" with "+tp2) +// settings.explaintypes.value = true +// et.withTypeVars { x => explainTypes(tp1, x); true } +// settings.explaintypes.value = false et.withTypeVars(tp1 <:< _) case (RefinedType(parents1, ref1), _) => parents1 exists (_ <:< tp2) @@ -3722,7 +3728,7 @@ A type's typeSymbol should never be inspected directly. * @throws NoInstance */ def solve(tvars: List[TypeVar], tparams: List[Symbol], - variances: List[Int], upper: Boolean) { + variances: List[Int], upper: Boolean): Boolean = { val config = tvars zip (tparams zip variances) def solveOne(tvar: TypeVar, tparam: Symbol, variance: Int) { @@ -3769,6 +3775,14 @@ A type's typeSymbol should never be inspected directly. } for ((tvar, (tparam, variance)) <- config) solveOne(tvar, tparam, variance) + + var ok = true + for (tvar <- tvars) + if (!(tvar.constr.lobounds forall (_ <:< tvar.constr.inst)) || + !(tvar.constr.hibounds forall (tvar.constr.inst <:< _))) { + ok = false + } + ok } /** Do type arguments `targs' conform to formal parameters diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index ea2a4c59c8..5e16274eed 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -137,7 +137,16 @@ trait Infer { */ private def solvedTypes(tvars: List[TypeVar], tparams: List[Symbol], variances: List[Int], upper: Boolean): List[Type] = { - solve(tvars, tparams, variances, upper) + def boundsString(tvar: TypeVar) = + "\n "+ + ((tvar.constr.lobounds map (_ + " <: " + tvar.origin.typeSymbol.name)) ::: + (tvar.constr.hibounds map (tvar.origin.typeSymbol.name + " <: " + _)) mkString ", ") + if (!solve(tvars, tparams, variances, upper)) { +// no panic, it's good enough to just guess a solution, we'll find out +// later whether it works. +// throw new DeferredNoInstance(() => +// "no solution exists for constraints"+(tvars map boundsString)) + } for (val tvar <- tvars) assert(tvar.constr.inst != tvar, tvar.origin) tvars map instantiate } @@ -952,7 +961,7 @@ trait Infer { } catch { case ex: NoInstance => errorTree(tree, "constructor of type " + restpe + - " can be instantiated in more than one way to expected type " + pt + + " cannot be uniquely instantiated to expected type " + pt + "\n --- because ---\n" + ex.getMessage()) } def instError = { |