From d852c9b8b4f261bff3bd32127f70378225bb6831 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Thu, 5 Jul 2012 14:59:26 +0200 Subject: SI-6022 model type-test-implication better we use subtyping as a model for implication between instanceof tests i.e., when S <:< T we assume x.isInstanceOf[S] implies x.isInstanceOf[T] unfortunately this is not true in general. SI-6022 expects instanceOfTpImplies(ProductClass.tpe, AnyRefClass.tpe), but ProductClass.tpe <:< AnyRefClass.tpe does not hold because Product extends Any however, if x.isInstanceOf[Product] holds, so does x.isInstanceOf[AnyRef], and that's all we care about when modeling type tests --- test/files/pos/t6022.flags | 1 + test/files/pos/t6022.scala | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 test/files/pos/t6022.flags create mode 100644 test/files/pos/t6022.scala (limited to 'test/files/pos') diff --git a/test/files/pos/t6022.flags b/test/files/pos/t6022.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t6022.flags @@ -0,0 +1 @@ +-Xfatal-warnings \ No newline at end of file diff --git a/test/files/pos/t6022.scala b/test/files/pos/t6022.scala new file mode 100644 index 0000000000..522c3352c7 --- /dev/null +++ b/test/files/pos/t6022.scala @@ -0,0 +1,7 @@ +class Test { + (null: Any) match { + case x: AnyRef if false => + case list: Option[_] => + case product: Product => // change Product to String and it's all good + } +} \ No newline at end of file -- cgit v1.2.3