From 1c6543dc7dfd839cf11f54a8de1b7f6c7e1c9247 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 21 Aug 2012 15:13:01 +0200 Subject: Fix for SI-6264, crash in checkCheckable. The classic fail of assuming you will only receive a specific subclass of Type. --- src/compiler/scala/tools/nsc/typechecker/Infer.scala | 19 +++++++++++-------- test/files/neg/t6264.check | 4 ++++ test/files/neg/t6264.flags | 1 + test/files/neg/t6264.scala | 6 ++++++ 4 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 test/files/neg/t6264.check create mode 100644 test/files/neg/t6264.flags create mode 100644 test/files/neg/t6264.scala 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[_]]] + () + } +} -- cgit v1.2.3