diff options
author | Paul Phillips <paulp@improving.org> | 2012-08-21 15:13:01 +0200 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-08-21 15:15:54 +0200 |
commit | 1c6543dc7dfd839cf11f54a8de1b7f6c7e1c9247 (patch) | |
tree | 5139ea91fc3cf20e69823a45aa966e1a9c0d4b85 | |
parent | 1ab4994990a21c1ea4dadcf15368013d89456ca6 (diff) | |
download | scala-1c6543dc7dfd839cf11f54a8de1b7f6c7e1c9247.tar.gz scala-1c6543dc7dfd839cf11f54a8de1b7f6c7e1c9247.tar.bz2 scala-1c6543dc7dfd839cf11f54a8de1b7f6c7e1c9247.zip |
Fix for SI-6264, crash in checkCheckable.
The classic fail of assuming you will only receive a
specific subclass of Type.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 19 | ||||
-rw-r--r-- | test/files/neg/t6264.check | 4 | ||||
-rw-r--r-- | test/files/neg/t6264.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t6264.scala | 6 |
4 files changed, 22 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index aa1bc0ce9d..28636fc76e 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -1373,14 +1373,17 @@ trait Infer { else =:= ) (arg hasAnnotation UncheckedClass) || { - val TypeRef(_, sym, args) = arg.withoutAnnotations - - ( isLocalBinding(sym) - || arg.typeSymbol.isTypeParameterOrSkolem - || (sym.name == tpnme.WILDCARD) // avoid spurious warnings on HK types - || check(arg, param.tpeHK, conforms) - || warn("non-variable type argument " + arg) - ) + arg.withoutAnnotations match { + case TypeRef(_, sym, args) => + ( isLocalBinding(sym) + || arg.typeSymbol.isTypeParameterOrSkolem + || (sym.name == tpnme.WILDCARD) // avoid spurious warnings on HK types + || check(arg, param.tpeHK, conforms) + || warn("non-variable type argument " + arg) + ) + case _ => + warn("non-variable type argument " + arg) + } } } diff --git a/test/files/neg/t6264.check b/test/files/neg/t6264.check new file mode 100644 index 0000000000..438be4c39f --- /dev/null +++ b/test/files/neg/t6264.check @@ -0,0 +1,4 @@ +t6264.scala:3: error: non-variable type argument Tuple1[_] in type Tuple2[_, Tuple1[_]] is unchecked since it is eliminated by erasure + x.isInstanceOf[Tuple2[_, Tuple1[_]]] + ^ +one error found diff --git a/test/files/neg/t6264.flags b/test/files/neg/t6264.flags new file mode 100644 index 0000000000..85d8eb2ba2 --- /dev/null +++ b/test/files/neg/t6264.flags @@ -0,0 +1 @@ +-Xfatal-warnings diff --git a/test/files/neg/t6264.scala b/test/files/neg/t6264.scala new file mode 100644 index 0000000000..dc3b727934 --- /dev/null +++ b/test/files/neg/t6264.scala @@ -0,0 +1,6 @@ +class Foo { + def foo(x: AnyRef): Unit = { + x.isInstanceOf[Tuple2[_, Tuple1[_]]] + () + } +} |