summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-09-25 18:10:28 -0700
committerPaul Phillips <paulp@improving.org>2012-09-25 18:17:30 -0700
commit5499e41157cdb6a81772728525e9c1f44401e7cc (patch)
tree7e38850eedcee43cdcb0b14c656f5b4b0c236f7e /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent0b8dcfe93fe07acf16b4a8a585579b57432f07ab (diff)
downloadscala-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.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
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 =>