diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-06-09 12:13:55 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-06-09 12:13:55 -0700 |
commit | d01cc65a298924156b6d98af94d9bcbb334d69b6 (patch) | |
tree | ae6fa0b2016c51d2f40883f80c0570220cd6f06c /src | |
parent | 3597a402a12eecd1c761eb7c9881f2c86024a1f1 (diff) | |
parent | 8518709d83b98bed6cac8437c3964e59f2ba5cd6 (diff) | |
download | scala-d01cc65a298924156b6d98af94d9bcbb334d69b6.tar.gz scala-d01cc65a298924156b6d98af94d9bcbb334d69b6.tar.bz2 scala-d01cc65a298924156b6d98af94d9bcbb334d69b6.zip |
Merge pull request #2630 from retronym/ticket/6308
SI-6308 Specialize methods that have some unspecialized params
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index cc4b2d544b..f43e42c027 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -1388,10 +1388,26 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /* The specialized symbol of 'tree.symbol' for tree.tpe, if there is one */ def specSym(qual: Tree): Symbol = { val env = unify(symbol.tpe, tree.tpe, emptyEnv, false) - def isMatch(member: Symbol) = ( - doesConform(symbol, tree.tpe, qual.tpe memberType member, env) - && TypeEnv.includes(typeEnv(member), env) - ) + def isMatch(member: Symbol) = { + val memberType = qual.tpe memberType member + + val residualTreeType = tree match { + case TypeApply(fun, targs) if fun.symbol == symbol => + // SI-6308 Handle methods with only some type parameters specialized. + // drop the specialized type parameters from the PolyType, and + // substitute in the type environment. + val GenPolyType(tparams, tpe) = fun.tpe + val (from, to) = env.toList.unzip + val residualTParams = tparams.filterNot(env.contains) + GenPolyType(residualTParams, tpe).substituteTypes(from, to) + case _ => tree.tpe + } + + ( + doesConform(symbol, residualTreeType, memberType, env) + && TypeEnv.includes(typeEnv(member), env) + ) + } if (env.isEmpty) NoSymbol else qual.tpe member specializedName(symbol, env) suchThat isMatch } |