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 | |
parent | fdd7b82c5a6fe2fb2c9ac1520d28f0dffc7580fa (diff) | |
download | scala-5a0c92b0796c2e8453495b7c8086926466ce3bd2.tar.gz scala-5a0c92b0796c2e8453495b7c8086926466ce3bd2.tar.bz2 scala-5a0c92b0796c2e8453495b7c8086926466ce3bd2.zip |
Fix and test case for #1843.
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/PatternNodes.scala | 18 | ||||
-rw-r--r-- | test/files/pos/bug1843.scala | 25 |
2 files changed, 40 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) diff --git a/test/files/pos/bug1843.scala b/test/files/pos/bug1843.scala new file mode 100644 index 0000000000..cc73353b75 --- /dev/null +++ b/test/files/pos/bug1843.scala @@ -0,0 +1,25 @@ +/** +* Scala Compiler Will Crash On this File +* ... Or Will It? +* +*/ + +object Crash { + trait UpdateType[A] + case class StateUpdate[A](updateType : UpdateType[A], value : A) + case object IntegerUpdateType extends UpdateType[Integer] + + //However this method will cause a crash + def crash(updates: List[StateUpdate[_]]) { + updates match { + case Nil => + case u::us => + u match { + //Line below seems to be the crashing line + case StateUpdate(key, newValue) if (key == IntegerUpdateType) => + println("Requires a statement to induce the crash") + case _ => + } + } + } +} |