diff options
author | Paul Phillips <paulp@improving.org> | 2009-07-12 01:33:45 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-07-12 01:33:45 +0000 |
commit | 5a0c92b0796c2e8453495b7c8086926466ce3bd2 (patch) | |
tree | 2de1cbcddacf88bc4e3756aa50785e37826749da /src | |
parent | fdd7b82c5a6fe2fb2c9ac1520d28f0dffc7580fa (diff) | |
download | scala-5a0c92b0796c2e8453495b7c8086926466ce3bd2.tar.gz scala-5a0c92b0796c2e8453495b7c8086926466ce3bd2.tar.bz2 scala-5a0c92b0796c2e8453495b7c8086926466ce3bd2.zip |
Fix and test case for #1843.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternNodes.scala | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala index 256019721c..5c09de24ea 100644 --- a/src/compiler/scala/tools/nsc/matching/PatternNodes.scala +++ b/src/compiler/scala/tools/nsc/matching/PatternNodes.scala @@ -240,7 +240,7 @@ trait PatternNodes extends ast.TreeDSL * tvar: the temporary variable that holds the actual value */ case class Binding(pvar: Symbol, tvar: Symbol) { - override def toString() = "%s @ %s".format(pvar.name, tvar.name) + override def toString() = "%s: %s @ %s: %s".format(pvar.name, pvar.tpe, tvar.name, tvar.tpe) } case class Bindings(bindings: Binding*) extends Function1[Symbol, Option[Ident]] { @@ -248,8 +248,20 @@ trait PatternNodes extends ast.TreeDSL if (tvar.tpe <:< pvar.tpe) ID(tvar) else ID(tvar) AS_ANY pvar.tpe - def add(vs: Iterable[Symbol], tvar: Symbol): Bindings = - Bindings((vs.toList map (Binding(_: Symbol, tvar))) ++ bindings : _*) + def add(vs: Iterable[Symbol], tvar: Symbol): Bindings = { + def newBinding(v: Symbol) = { + // see bug #1843 for the consequences of not setting info. + // there is surely a better way to do this, especially since + // this looks to be the only usage of containsTp anywhere + // in the compiler, but it suffices for now. + if (tvar.info containsTp WildcardType) + tvar setInfo v.info + + Binding(v, tvar) + } + val newBindings = vs.toList map newBinding + Bindings(newBindings ++ bindings: _*) + } def apply(v: Symbol): Option[Ident] = bindings find (_.pvar eq v) map (x => Ident(x.tvar) setType v.tpe) |