From 5589eeeb9a5e09352544efc629013caf2d18a842 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 30 Jul 2012 14:30:17 +0200 Subject: SI-5866 Support casting null to value classes The fix now supports null.asInstanceOf[C] where C is a value class that wraps a primitive type. --- test/files/run/t5866.scala | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/files/run/t5866.scala (limited to 'test/files/run/t5866.scala') diff --git a/test/files/run/t5866.scala b/test/files/run/t5866.scala new file mode 100644 index 0000000000..120773effa --- /dev/null +++ b/test/files/run/t5866.scala @@ -0,0 +1,11 @@ +class Foo(val d: Double) extends AnyVal { + override def toString = s"Foo($d)" +} +object Test { + def main(args: Array[String]): Unit = { + val d: Double = null.asInstanceOf[Double] + println(d) + val f: Foo = null.asInstanceOf[Foo] + println(f) + } +} -- cgit v1.2.3