summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-07-25 12:15:20 +0000
committerMartin Odersky <odersky@gmail.com>2007-07-25 12:15:20 +0000
commit7f2f04c2f84c5ec07571fd8ff7af0570132e08c5 (patch)
tree2971dcc30fd30f79f2628bb72d960d1282c0cb4c /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent39b0a1fbf3406861f0386bdec52b606dbb2c534d (diff)
downloadscala-7f2f04c2f84c5ec07571fd8ff7af0570132e08c5.tar.gz
scala-7f2f04c2f84c5ec07571fd8ff7af0570132e08c5.tar.bz2
scala-7f2f04c2f84c5ec07571fd8ff7af0570132e08c5.zip
fixed bug1234
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index bed72e52a9..701b2fe245 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -1302,14 +1302,23 @@ trait Typers { self: Analyzer =>
var body1: Tree = typed(cdef.body, pt)
if (!context.savedTypeBounds.isEmpty) {
body1.tpe = context.restoreTypeBounds(body1.tpe)
- if (isFullyDefined(pt) && !(body1.tpe <:< pt))
- // the following is a hack to make the pattern matcher work !!! (still needed?)
- body1 =
- typed {
- atPos(body1.pos) {
- TypeApply(Select(body1, Any_asInstanceOf), List(TypeTree(pt))) // @M no need for pt.normalize here, is done in erasure
- }
- }
+ if (isFullyDefined(pt)) {
+ // the following is a hack to make the pattern matcher work:
+ // add an .asInstanceOf[pt] unless there is already one.
+ // (the ...unless... part is necessary to make type checking idempotent).
+ body1 match {
+ case TypeApply(qual, List(targ))
+ if (qual.symbol == Any_asInstanceOf && targ.tpe <:< pt) =>
+ ;
+ case _ =>
+ body1 =
+ typed {
+ atPos(body1.pos) {
+ TypeApply(Select(body1, Any_asInstanceOf), List(TypeTree(pt))) // @M no need for pt.normalize here, is done in erasure
+ }
+ }
+ }
+ }
}
// body1 = checkNoEscaping.locals(context.scope, pt, body1)
copy.CaseDef(cdef, pat1, guard1, body1) setType body1.tpe