diff options
author | Paul Phillips <paulp@improving.org> | 2009-07-20 21:38:13 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2009-07-20 21:38:13 +0000 |
commit | 04ed00053ec03848f3409e090d818418c19a8541 (patch) | |
tree | 7123e1cab2042b306a81d83c7a97ea8e6e884503 | |
parent | 9fcf6dc3c6b32e03c64d340e285e1d7886593d20 (diff) | |
download | scala-04ed00053ec03848f3409e090d818418c19a8541.tar.gz scala-04ed00053ec03848f3409e090d818418c19a8541.tar.bz2 scala-04ed00053ec03848f3409e090d818418c19a8541.zip |
Fix and test case for #2168.
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeDSL.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/matching/ParallelMatching.scala | 3 | ||||
-rw-r--r-- | test/files/pos/bug2168.scala | 5 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala index 9c12ac6bd5..97869d5ea5 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeDSL.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeDSL.scala @@ -114,6 +114,8 @@ trait TreeDSL { /** Casting & type tests -- working our way toward understanding exactly * what differs between the different forms of IS and AS. + * + * See ticket #2168 for one illustration of AS vs. AS_ANY. */ def AS(tpe: Type) = TypeApply(Select(target, Any_asInstanceOf), List(TypeTree(tpe))) def AS_ANY(tpe: Type) = gen.mkAsInstanceOf(target, tpe) diff --git a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala index 22df6d1bda..cd140e7c49 100644 --- a/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala +++ b/src/compiler/scala/tools/nsc/matching/ParallelMatching.scala @@ -988,9 +988,10 @@ trait ParallelMatching extends ast.TreeDSL { // dig out case field accessors that were buried in (***) val cfa = if (pats.isCaseHead) casted.accessors else Nil val caseTemps = srep.tvars match { case x :: xs if x == casted.sym => xs ; case x => x } - def castedScrut = typedValDef(casted.sym, scrut.id AS castedTpe) + def castedScrut = typedValDef(casted.sym, scrut.id AS_ANY castedTpe) def needCast = if (casted.sym ne scrut.sym) List(castedScrut) else Nil + val vdefs = needCast ::: ( for ((tmp, accessor) <- caseTemps zip cfa) yield typedValDef(tmp, typer typed fn(casted.id, accessor)) diff --git a/test/files/pos/bug2168.scala b/test/files/pos/bug2168.scala new file mode 100644 index 0000000000..42224236db --- /dev/null +++ b/test/files/pos/bug2168.scala @@ -0,0 +1,5 @@ +object Test extends Application { + def foo1(x: AnyRef) = x match { case x: Function0[_] => x() } + def foo2(x: AnyRef) = x match { case x: Function0[Any] => x() } +} + |