From 18fd93b5ec7e439b59b75f96e976aad6025a76f4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 29 Sep 2012 13:34:25 -0700 Subject: Revert "SI-4881 infer variance from formals, then result" This reverts commit 5c5e8d4dcd151a6e2bf9e7c259c618b9b4eff00f. --- src/compiler/scala/tools/nsc/typechecker/Infer.scala | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 0c3dcb9342..cb5fc8df5a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -517,7 +517,7 @@ trait Infer extends Checkable { val tvars = tparams map freshVar if (isConservativelyCompatible(restpe.instantiateTypeParams(tparams, tvars), pt)) map2(tparams, tvars)((tparam, tvar) => - instantiateToBound(tvar, inferVariance(formals, restpe)(tparam))) + instantiateToBound(tvar, varianceInTypes(formals)(tparam))) else tvars map (tvar => WildcardType) } @@ -647,24 +647,13 @@ trait Infer extends Checkable { "argument expression's type is not compatible with formal parameter type" + foundReqMsg(tp1, pt1)) } } - val targs = solvedTypes( - tvars, tparams, tparams map inferVariance(formals, restpe), + tvars, tparams, tparams map varianceInTypes(formals), false, lubDepth(formals) max lubDepth(argtpes) ) adjustTypeArgs(tparams, tvars, targs, restpe) } - /** Determine which variance to assume for the type paraneter. We first chose the variance - * that minimizes any formal parameters. If that is still undetermined, because the type parameter - * does not appear as a formal parameter type, then we pick the variance so that it minimizes the - * method's result type instead. - */ - private def inferVariance(formals: List[Type], restpe: Type)(tparam: Symbol): Int = { - val v = varianceInTypes(formals)(tparam) - if (v != VarianceFlags) v else varianceInType(restpe)(tparam) - } - private[typechecker] def followApply(tp: Type): Type = tp match { case NullaryMethodType(restp) => val restp1 = followApply(restp) -- cgit v1.2.3