diff options
author | Martin Odersky <odersky@gmail.com> | 2007-07-25 12:15:20 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-07-25 12:15:20 +0000 |
commit | 7f2f04c2f84c5ec07571fd8ff7af0570132e08c5 (patch) | |
tree | 2971dcc30fd30f79f2628bb72d960d1282c0cb4c /src/compiler/scala/tools/nsc/typechecker/Typers.scala | |
parent | 39b0a1fbf3406861f0386bdec52b606dbb2c534d (diff) | |
download | scala-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.scala | 25 |
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 |