diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-29 13:34:25 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-29 13:37:24 -0700 |
commit | 18fd93b5ec7e439b59b75f96e976aad6025a76f4 (patch) | |
tree | 504d50f1c157923fb529e6fb4d792a9381b8b8f0 /src | |
parent | be49f36154efa78c3dcbeba394aa6ec2b5e764ec (diff) | |
download | scala-18fd93b5ec7e439b59b75f96e976aad6025a76f4.tar.gz scala-18fd93b5ec7e439b59b75f96e976aad6025a76f4.tar.bz2 scala-18fd93b5ec7e439b59b75f96e976aad6025a76f4.zip |
Revert "SI-4881 infer variance from formals, then result"
This reverts commit 5c5e8d4dcd151a6e2bf9e7c259c618b9b4eff00f.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 15 |
1 files changed, 2 insertions, 13 deletions
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) |