diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-25 18:10:28 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-25 18:17:30 -0700 |
commit | 5499e41157cdb6a81772728525e9c1f44401e7cc (patch) | |
tree | 7e38850eedcee43cdcb0b14c656f5b4b0c236f7e | |
parent | 0b8dcfe93fe07acf16b4a8a585579b57432f07ab (diff) | |
download | scala-5499e41157cdb6a81772728525e9c1f44401e7cc.tar.gz scala-5499e41157cdb6a81772728525e9c1f44401e7cc.tar.bz2 scala-5499e41157cdb6a81772728525e9c1f44401e7cc.zip |
Pass a more precise type to checkCheckable when it's available.
Without it, one cannot assess the checkability of any
aspect of the pattern for which static verifiability
depends on knowledge of the scrutinee.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index af89af74d0..e14dda9f12 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3768,9 +3768,13 @@ trait Typers extends Modes with Adaptations with Tags { if (fun.symbol == Predef_classOf) typedClassOf(tree, args.head, true) else { - if (!isPastTyper && fun.symbol == Any_isInstanceOf && !targs.isEmpty) - checkCheckable(tree, targs.head, AnyClass.tpe, inPattern = false) - + if (!isPastTyper && fun.symbol == Any_isInstanceOf && targs.nonEmpty) { + val scrutineeType = fun match { + case Select(qual, _) => qual.tpe + case _ => AnyClass.tpe + } + checkCheckable(tree, targs.head, scrutineeType, inPattern = false) + } val resultpe = restpe.instantiateTypeParams(tparams, targs) //@M substitution in instantiateParams needs to be careful! //@M example: class Foo[a] { def foo[m[x]]: m[a] = error("") } (new Foo[Int]).foo[List] : List[Int] @@ -3780,7 +3784,8 @@ trait Typers extends Modes with Adaptations with Tags { //println("instantiating type params "+restpe+" "+tparams+" "+targs+" = "+resultpe) treeCopy.TypeApply(tree, fun, args) setType resultpe } - } else { + } + else { TypedApplyWrongNumberOfTpeParametersError(tree, fun) } case ErrorType => |