diff options
author | Paul Phillips <paulp@improving.org> | 2011-09-22 19:33:47 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-09-22 19:33:47 +0000 |
commit | afe1d6fa6293465b8f97d2ca4699640fe4d09bad (patch) | |
tree | 621f6d99453e4fcca1157d2944e2aa6df2228e05 /src | |
parent | 5e501977f8ef72efda884d6190eeb532703d4275 (diff) | |
download | scala-afe1d6fa6293465b8f97d2ca4699640fe4d09bad.tar.gz scala-afe1d6fa6293465b8f97d2ca4699640fe4d09bad.tar.bz2 scala-afe1d6fa6293465b8f97d2ca4699640fe4d09bad.zip |
fixes variance of param in type constructor
when determining in which variance position a symbol occurs in a type,
there's no need to look at the args of a type constructor, since it
doesn't have any therefore, the symbol could not occur in a variance
position corresponding to the typeref's (non-existent) type arguments
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Variances.scala | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Variances.scala b/src/compiler/scala/tools/nsc/typechecker/Variances.scala index f68f9cc140..1ba0de0192 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Variances.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Variances.scala @@ -71,11 +71,9 @@ trait Variances { varianceInType(pre)(tparam) case TypeRef(pre, sym, args) => if (sym == tparam) COVARIANT - else varianceInType(pre)(tparam) & { - // @PP to @AM: please give this a higher dose of correctness. - val actualArgs = if (args.isEmpty) sym.typeParams map (_.typeConstructor) else args - varianceInArgs(actualArgs, sym.typeParams)(tparam) - } + // tparam cannot occur in tp's args if tp is a type constructor (those don't have args) + else if (tp.isHigherKinded) varianceInType(pre)(tparam) + else varianceInType(pre)(tparam) & varianceInArgs(args, sym.typeParams)(tparam) case TypeBounds(lo, hi) => flip(varianceInType(lo)(tparam)) & varianceInType(hi)(tparam) case RefinedType(parents, defs) => |