diff options
Diffstat (limited to 'test/files')
25 files changed, 177 insertions, 377 deletions
diff --git a/test/files/neg/t5031.check b/test/files/neg/t5031.check new file mode 100644 index 0000000000..8983d8daf9 --- /dev/null +++ b/test/files/neg/t5031.check @@ -0,0 +1,5 @@ +Id.scala:3: error: Companions 'class Test' and 'object Test' must be defined in same file: + Found in t5031/package.scala and t5031/Id.scala +object Test + ^ +one error found diff --git a/test/files/neg/t5031/Id.scala b/test/files/neg/t5031/Id.scala new file mode 100644 index 0000000000..2f0db002d2 --- /dev/null +++ b/test/files/neg/t5031/Id.scala @@ -0,0 +1,4 @@ +package t5031 + +object Test + diff --git a/test/files/neg/t5031/package.scala b/test/files/neg/t5031/package.scala new file mode 100644 index 0000000000..17b63220be --- /dev/null +++ b/test/files/neg/t5031/package.scala @@ -0,0 +1,3 @@ +package object t5031 { + class Test +} diff --git a/test/files/neg/t5799.check b/test/files/neg/t5799.check new file mode 100644 index 0000000000..10e2658d56 --- /dev/null +++ b/test/files/neg/t5799.check @@ -0,0 +1,4 @@ +t5799.scala:2: error: value class may not have secondary constructors + def this(s: String) = this(s.toDouble) + ^ +one error found diff --git a/test/files/neg/t5799.scala b/test/files/neg/t5799.scala new file mode 100644 index 0000000000..9bd6ab7dd1 --- /dev/null +++ b/test/files/neg/t5799.scala @@ -0,0 +1,8 @@ +class Foo(val bar: Double) extends AnyVal { + def this(s: String) = this(s.toDouble) +} +object Test { + def main(args: Array[String]): Unit = + new Foo("") + } + diff --git a/test/files/neg/t5882.check b/test/files/neg/t5882.check new file mode 100644 index 0000000000..df01c7bc0a --- /dev/null +++ b/test/files/neg/t5882.check @@ -0,0 +1,15 @@ +t5882.scala:2: warning: case classes without a parameter list have been deprecated; +use either case objects or case classes with `()' as parameter list. + case class Scope + ^ +t5882.scala:2: error: value class may not have nested class definitions + case class Scope + ^ +t5882.scala:3: error: value class may not have nested class definitions + class Foo + ^ +t5882.scala:4: error: value class may not have nested module definitions + object Bar + ^ +one warning found +three errors found diff --git a/test/files/neg/t5882.scala b/test/files/neg/t5882.scala new file mode 100644 index 0000000000..1233eb636f --- /dev/null +++ b/test/files/neg/t5882.scala @@ -0,0 +1,5 @@ +class NodeOps(val n: Any) extends AnyVal { + case class Scope + class Foo + object Bar +} diff --git a/test/files/pos/t2038.scala b/test/files/pos/t2038.scala new file mode 100644 index 0000000000..17b1a702dd --- /dev/null +++ b/test/files/pos/t2038.scala @@ -0,0 +1,5 @@ +class Test { + List(Some(classOf[java.lang.Integer]), Some(classOf[Int])).map { + case Some(f: Class[_]) => f.cast(???) + } +}
\ No newline at end of file diff --git a/test/files/pos/t5031/Id.scala b/test/files/pos/t5031/Id.scala new file mode 100644 index 0000000000..7bc3ebd348 --- /dev/null +++ b/test/files/pos/t5031/Id.scala @@ -0,0 +1,4 @@ +package t5031 + +object ID + diff --git a/test/files/pos/t5031/package.scala b/test/files/pos/t5031/package.scala new file mode 100644 index 0000000000..c02e69db8e --- /dev/null +++ b/test/files/pos/t5031/package.scala @@ -0,0 +1,3 @@ +package object t5031 { + type ID = Int +} diff --git a/test/files/pos/t5031_2.scala b/test/files/pos/t5031_2.scala new file mode 100644 index 0000000000..ded3e82301 --- /dev/null +++ b/test/files/pos/t5031_2.scala @@ -0,0 +1,7 @@ +package object t5031 { + class ID +} + +package t5031 { + object ID +} diff --git a/test/files/run/classtags_core.check b/test/files/run/classtags_core.check index 6519db2178..2241108ba0 100644 --- a/test/files/run/classtags_core.check +++ b/test/files/run/classtags_core.check @@ -1,30 +1,30 @@ -true
-ClassTag[byte]
-true
-ClassTag[short]
-true
-ClassTag[char]
-true
-ClassTag[int]
-true
-ClassTag[long]
-true
-ClassTag[float]
-true
-ClassTag[double]
-true
-ClassTag[boolean]
-true
-ClassTag[void]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class java.lang.Object]
-true
-ClassTag[class scala.runtime.Null$]
-true
-ClassTag[class scala.runtime.Nothing$]
+true +ClassTag[byte] +true +ClassTag[short] +true +ClassTag[char] +true +ClassTag[int] +true +ClassTag[long] +true +ClassTag[float] +true +ClassTag[double] +true +ClassTag[boolean] +true +ClassTag[void] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class java.lang.Object] +true +ClassTag[class scala.runtime.Null$] +true +ClassTag[Nothing] diff --git a/test/files/run/reflect-resolveoverload-bynameparam.scala b/test/files/run/reflect-resolveoverload-bynameparam.scala deleted file mode 100644 index 7fb8c82ab8..0000000000 --- a/test/files/run/reflect-resolveoverload-bynameparam.scala +++ /dev/null @@ -1,32 +0,0 @@ - -class A -class B extends A - -class C { - def foo(x: => Int)(y: String) = x - def foo(x: String)(y: List[_]) = x - def foo(x: => A)(y: Array[_]) = 1 - def foo(x: A)(y: Seq[_]) = 2 - def foo(x: B)(y: Map[_, _]) = 4 -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - val c = new C - val im = cm.reflect(c) - val t = u.typeOf[C] member u.newTermName("foo") asTermSymbol - val f1 = t.resolveOverloaded(posVargs = List(u.typeOf[Int])) asMethodSymbol - val f2 = t.resolveOverloaded(posVargs = List(u.typeOf[String])) asMethodSymbol - val f3 = t.resolveOverloaded(posVargs = List(u.typeOf[A])) asMethodSymbol - val f4 = t.resolveOverloaded(posVargs = List(u.typeOf[B])) asMethodSymbol - val m1 = im.reflectMethod(f1) - val m2 = im.reflectMethod(f2) - val m3 = im.reflectMethod(f3) - val m4 = im.reflectMethod(f4) - assert(m1(() => 1, null) == c.foo(1)(null)) - assert(m2("a", null) == c.foo("a")(null)) - assert(m3(new A, null) == c.foo(new A)(null)) - assert(m4(new B, null) == c.foo(new B)(null)) -} - diff --git a/test/files/run/reflect-resolveoverload-expected.scala b/test/files/run/reflect-resolveoverload-expected.scala deleted file mode 100644 index 1378090309..0000000000 --- a/test/files/run/reflect-resolveoverload-expected.scala +++ /dev/null @@ -1,43 +0,0 @@ - -class A { - override def equals(x: Any) = { - x.isInstanceOf[A] && !x.isInstanceOf[B] - } -} -class B extends A { - override def equals(x: Any) = { - x.isInstanceOf[B] - } -} - -class C { - def a(x: String) = 1 - def a(x: Array[_]) = "a" - def b(x: String) = new A - def b(x: Array[_]) = new B - def c(x: String) = new B - def c(x: Array[_]) = "a" -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - val c = new C - val im = cm.reflect(c) - def invoke(s: String, expectedType: u.Type, expectedResult: Any) { - val ol = (u.typeOf[C] member u.newTermName(s)).asTermSymbol - val methodSym = ol.resolveOverloaded(posVargs = List(u.typeOf[Null]), expected = expectedType).asMethodSymbol - val sig = methodSym.typeSignature.asInstanceOf[u.MethodType] - val method = im.reflectMethod(methodSym) - assert(method(null) == expectedResult) - } - - invoke("a", u.typeOf[Int], c.a(null): Int) - invoke("a", u.typeOf[String], c.a(null): String) - invoke("b", u.typeOf[B], c.b(null): B) - invoke("c", u.typeOf[A], c.c(null): A) - invoke("c", u.typeOf[A], c.c(null): A) - invoke("c", u.typeOf[B], c.c(null): B) - invoke("c", u.typeOf[String], c.c(null): String) - -} diff --git a/test/files/run/reflect-resolveoverload-invalid.scala b/test/files/run/reflect-resolveoverload-invalid.scala deleted file mode 100644 index 8c5dc9f94b..0000000000 --- a/test/files/run/reflect-resolveoverload-invalid.scala +++ /dev/null @@ -1,43 +0,0 @@ - -class A -class B extends A - -class C { - def a(x: Int) = 1 - def a(x: String) = 2 - def b(x: B) = 3 - def c(x: A, y: B) = 4 - def c(x: B, y: A) = 5 - def d[T](x: Int) = 6 - def d(x: String) = 7 - def e(x: A) = 8 - def e(x: =>B) = 9 -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - - val x = new C - val t = u.typeOf[C] - - val a = t member u.newTermName("a") asTermSymbol - val b = t member u.newTermName("b") asTermSymbol - val c = t member u.newTermName("c") asTermSymbol - val d = t member u.newTermName("d") asTermSymbol - val e = t member u.newTermName("e") asTermSymbol - - val n1 = a.resolveOverloaded(posVargs = List(u.typeOf[Long])) - val n2 = b.resolveOverloaded(posVargs = List(u.typeOf[A])) - val n3 = c.resolveOverloaded(posVargs = List(u.typeOf[B], u.typeOf[B])) - val n4 = d.resolveOverloaded(targs = List(u.typeOf[Int])) - val n5 = d.resolveOverloaded() - val n6 = e.resolveOverloaded(posVargs = List(u.typeOf[B])) - - assert(n1 == u.NoSymbol) - assert(n2 == u.NoSymbol) - assert(n3 == u.NoSymbol) - assert(n4 == u.NoSymbol) - assert(n5 == u.NoSymbol) - assert(n6 == u.NoSymbol) -} diff --git a/test/files/run/reflect-resolveoverload-named.scala b/test/files/run/reflect-resolveoverload-named.scala deleted file mode 100644 index 017ec85c0d..0000000000 --- a/test/files/run/reflect-resolveoverload-named.scala +++ /dev/null @@ -1,26 +0,0 @@ - -class A { - def foo(x: String, y: Int) = 1 - def foo(x: Int, y: String) = 2 -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - val a = new A - val im = cm.reflect(a) - val tpe = u.typeOf[A] - val overloaded = tpe member u.newTermName("foo") asTermSymbol - val ms1 = - overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("x"), u.typeOf[String]), (u.newTermName("y"), u.typeOf[Int]))) - val ms2 = - overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("y"), u.typeOf[Int]), (u.newTermName("x"), u.typeOf[String]))) - val ms3 = - overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("x"), u.typeOf[Int]), (u.newTermName("y"), u.typeOf[String]))) - val ms4 = - overloaded resolveOverloaded(nameVargs = Seq((u.newTermName("y"), u.typeOf[String]), (u.newTermName("x"), u.typeOf[Int]))) - assert(im.reflectMethod(ms1 asMethodSymbol)("A", 1) == 1) - assert(im.reflectMethod(ms2 asMethodSymbol)("A", 1) == 1) - assert(im.reflectMethod(ms3 asMethodSymbol)(1, "A") == 2) - assert(im.reflectMethod(ms4 asMethodSymbol)(1, "A") == 2) -} diff --git a/test/files/run/reflect-resolveoverload-targs.scala b/test/files/run/reflect-resolveoverload-targs.scala deleted file mode 100644 index 888b2f0c15..0000000000 --- a/test/files/run/reflect-resolveoverload-targs.scala +++ /dev/null @@ -1,29 +0,0 @@ - -import reflect.runtime.{universe=>u} -import scala.reflect.runtime.{currentMirror => cm} - -class C { - def foo[T: u.TypeTag](x: String) = 1 - def foo[T: u.TypeTag, S: u.TypeTag](x: String) = 2 -} - -object Test extends App { - val c = new C - val im = cm.reflect(c) - val foo = u.typeOf[C] member u.newTermName("foo") asTermSymbol - val f1 = foo.resolveOverloaded( - targs = Seq(u.typeOf[Int]), - posVargs = Seq(u.typeOf[String]) - ) - - val f2 = foo.resolveOverloaded( - targs = Seq(u.typeOf[Int], - u.typeOf[Int]), posVargs = Seq(u.typeOf[String]) - ) - - val m1 = im.reflectMethod(f1 asMethodSymbol) - val m2 = im.reflectMethod(f2 asMethodSymbol) - - assert(m1("a", u.typeTag[Int]) == c.foo[Int]("a")) - assert(m2("a", u.typeTag[Int], u.typeTag[Int]) == c.foo[Int, Int]("a")) -} diff --git a/test/files/run/reflect-resolveoverload-tparm-substitute.scala b/test/files/run/reflect-resolveoverload-tparm-substitute.scala deleted file mode 100644 index 22e7bcd40a..0000000000 --- a/test/files/run/reflect-resolveoverload-tparm-substitute.scala +++ /dev/null @@ -1,77 +0,0 @@ - -class A -class B extends A - -class C { - def foo[T](x: T) = x - def foo(x: Int) = "a" - def foo(x: A) = x -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - val c = new C - val im = cm.reflect(c) - val term = u.typeOf[C] member u.newTermName("foo") asTermSymbol - - val f1 = term.resolveOverloaded( - posVargs = List(u.typeOf[Int]), - expected = u.typeOf[String] - ) - - val f2 = term.resolveOverloaded( - targs = List(u.typeOf[String]), - posVargs = List(u.typeOf[String]), - expected = u.typeOf[String] - ) - - val f3 = term.resolveOverloaded( - posVargs = List(u.typeOf[A]), - expected = u.typeOf[A] - ) - - val f4 = term.resolveOverloaded( - targs = List(u.typeOf[A]), - posVargs = List(u.typeOf[A]), - expected = u.typeOf[A] - ) - - val f5 = term.resolveOverloaded( - targs = List(u.typeOf[B]), - posVargs = List(u.typeOf[B]), - expected = u.typeOf[B] - ) - - val f6 = term.resolveOverloaded( - targs = List(u.typeOf[B]), - posVargs = List(u.typeOf[B]), - expected = u.typeOf[A] - ) - - val f7 = term.resolveOverloaded( - targs = List(u.typeOf[A]), - posVargs = List(u.typeOf[B]), - expected = u.typeOf[A] - ) - - val m1 = im.reflectMethod(f1 asMethodSymbol) - val m2 = im.reflectMethod(f2 asMethodSymbol) - val m3 = im.reflectMethod(f3 asMethodSymbol) - val m4 = im.reflectMethod(f4 asMethodSymbol) - val m5 = im.reflectMethod(f5 asMethodSymbol) - val m6 = im.reflectMethod(f6 asMethodSymbol) - val m7 = im.reflectMethod(f7 asMethodSymbol) - - val a = new A - val b = new B - assert(m1(2) == (c.foo(2): String)) - assert(m2("xyz") == (c.foo[String]("xyz"): String)) - assert(m3(a) == (c.foo(a): A)) - assert(m4(a) == (c.foo[A](a): A)) - assert(m5(b) == (c.foo[B](b): B)) - assert(m6(b) == (c.foo[B](b): A)) - assert(m7(b) == (c.foo[A](b): A)) - - -} diff --git a/test/files/run/reflect-resolveoverload-variadic.scala b/test/files/run/reflect-resolveoverload-variadic.scala deleted file mode 100644 index 8e2e15600f..0000000000 --- a/test/files/run/reflect-resolveoverload-variadic.scala +++ /dev/null @@ -1,27 +0,0 @@ - -class C { - def foo(x: Int*) = 1 + x.sum - def foo(x: String) = 2 -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - val c = new C - val im = cm.reflect(c) - val foo = u.typeOf[C] member u.newTermName("foo") asTermSymbol - val f0 = foo.resolveOverloaded() - val f1 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[Int])) - val f2 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[Int], u.typeOf[Int])) - val f3 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[String])) - - val m0 = im.reflectMethod(f0 asMethodSymbol) - val m1 = im.reflectMethod(f1 asMethodSymbol) - val m2 = im.reflectMethod(f2 asMethodSymbol) - val m3 = im.reflectMethod(f3 asMethodSymbol) - - assert(m0(Seq()) == c.foo()) - assert(m1(Seq(1)) == c.foo(1)) - assert(m2(Seq(4, 9)) == c.foo(4, 9)) - assert(m3("abc") == c.foo("abc")) -} diff --git a/test/files/run/reflect-resolveoverload1.scala b/test/files/run/reflect-resolveoverload1.scala deleted file mode 100644 index a859a0ec4e..0000000000 --- a/test/files/run/reflect-resolveoverload1.scala +++ /dev/null @@ -1,19 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.runtime.{currentMirror => cm} - -object Test extends App { - - val s = "hello world" - val m = cm.reflect(s) - val sc = m.symbol - val st = sc.asType - val meth = (st member newTermName("indexOf")).asTermSymbol - val IntType = definitions.IntClass.asType - val indexOf = (meth resolveOverloaded(posVargs = List(IntType))).asMethodSymbol - assert(m.reflectMethod(indexOf)('w') == 6) - assert((m.reflectMethod(indexOf)('w') match { case x: Int => x }) == 6) - - val meth2 = (st member newTermName("substring")).asTermSymbol - val substring = (meth2 resolveOverloaded(posVargs = List(IntType, IntType))).asMethodSymbol - assert(m.reflectMethod(substring)(2, 6) == "llo ") -} diff --git a/test/files/run/reflect-resolveoverload2.scala b/test/files/run/reflect-resolveoverload2.scala deleted file mode 100644 index a800a3e92c..0000000000 --- a/test/files/run/reflect-resolveoverload2.scala +++ /dev/null @@ -1,51 +0,0 @@ -class A -class B extends A - -class C { - def a(x: Int) = 1 - def a(x: String) = 2 - //def b(x: => Int)(s: String) = 1 - //def b(x: => String)(a: Array[_]) = 2 - def c(x: A) = 1 - def c(x: B) = 2 - //def d(x: => A)(s: String) = 1 - //def d(x: => B)(a: Array[_]) = 2 - def e(x: A) = 1 - def e(x: B = new B) = 2 - def f(x: Int) = 1 - def f(x: String) = 2 - def f(x: Long) = 3 - def f(x: Double) = 4 -} - -object Test extends App { - val cm = reflect.runtime.currentMirror - val u = cm.universe - val c = new C - val im = cm.reflect(c) - def invoke(s: String, arg: Any, argType: u.Type): Int = { - val ol = u.typeOf[C] member u.newTermName(s) asTermSymbol - val methodSym = ol.resolveOverloaded(posVargs = List(argType)) asMethodSymbol - val sig = methodSym.typeSignature.asInstanceOf[u.MethodType] - val method = im.reflectMethod(methodSym) - if (sig.resultType.kind == "MethodType") method(arg, null).asInstanceOf[Int] - else method(arg).asInstanceOf[Int] - } - assert(c.a(1) == invoke("a", 1, u.typeOf[Int])) - assert(c.a("a") == invoke("a", "a", u.typeOf[String])) - assert(c.a('a') == invoke("a", 'a', u.typeOf[Char])) - assert(c.a(3: Byte) == invoke("a", 3: Byte, u.typeOf[Byte])) - //assert(c.b(1)(null) == invoke("b", 1, u.typeOf[Int])) - //assert(c.b("a")(null) == invoke("b", "a", u.typeOf[String])) - assert(c.c(new A) == invoke("c", new A, u.typeOf[A])) - assert(c.c(new B) == invoke("c", new B, u.typeOf[B])) - //assert(c.d(new A)(null) == invoke("d", new A, u.typeOf[A])) - //assert(c.d(new B)(null) == invoke("d", new B, u.typeOf[B])) - assert(c.e(new A) == invoke("e", new A, u.typeOf[A])) - assert(c.e(new B) == invoke("e", new B, u.typeOf[B])) - assert(c.f(1: Short) == invoke("f", 1: Short, u.typeOf[Short])) - assert(c.f(2) == invoke("f", 2, u.typeOf[Int])) - assert(c.f(3L) == invoke("f", 3L, u.typeOf[Long])) - assert(c.f(4f) == invoke("f", 4f, u.typeOf[Float])) - assert(c.f(5d) == invoke("f", 5d, u.typeOf[Double])) -} diff --git a/test/files/run/t5603.check b/test/files/run/t5603.check new file mode 100644 index 0000000000..5127d3c1c7 --- /dev/null +++ b/test/files/run/t5603.check @@ -0,0 +1,29 @@ +[[syntax trees at end of parser]] // newSource1 +[0:241]package [0:0]<empty> { + [0:82]abstract trait Greeting extends [15:82][83]scala.AnyRef { + [15]def $init$() = [15]{ + [15]() + }; + [23:39]val name: [33:39]String; + [46:76]val msg = [56:76][56:72][56:71]"How are you, ".$plus([72:76]name) + }; + [87:209]class C extends [94:209][151:159]Greeting { + [119:139]val nameElse = _; + [95:101]<paramaccessor> private[this] val i: [98:101]Int = _; + <119:139>def <init>([95]i: [98]Int) = <119:139>{ + <119:139>val nameElse = <134:139>"Bob"; + [94][94][94]super.<init>(); + [94]() + }; + [168:184]val name = [179:184]"avc"; + [191:203][191:198]println([199:202]msg) + }; + [215:241]object Test extends [227:241][235:238]App { + [227]def <init>() = [227]{ + [227][227][227]super.<init>(); + [227]() + }; + [NoPosition]<empty> + } +} + diff --git a/test/files/run/t5603.scala b/test/files/run/t5603.scala new file mode 100644 index 0000000000..60dfd01fee --- /dev/null +++ b/test/files/run/t5603.scala @@ -0,0 +1,42 @@ +import scala.tools.partest._ +import java.io._ +import scala.tools.nsc._ +import scala.tools.nsc.util.CommandLineParser +import scala.tools.nsc.{Global, Settings, CompilerCommand} +import scala.tools.nsc.reporters.ConsoleReporter + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Xprint:parser -Ystop-after:parser -d " + testOutput.path + + override def code = """ + trait Greeting { + val name: String + val msg = "How are you, "+name + } + class C(i: Int) extends { + val nameElse = "Bob" + } with Greeting { + val name = "avc" + println(msg) + } + + object Test extends App {} + """.trim + + override def show(): Unit = { + // redirect err to out, for logging + val prevErr = System.err + System.setErr(System.out) + compile() + System.setErr(prevErr) + } + + override def newCompiler(args: String*): Global = { + + val settings = new Settings() + settings.Xprintpos.value = true + val command = new CompilerCommand((CommandLineParser tokenize extraSettings) ++ args.toList, settings) + new Global(command.settings, new ConsoleReporter(settings)) with interactive.RangePositions + } +} diff --git a/test/files/run/t5866.check b/test/files/run/t5866.check new file mode 100644 index 0000000000..9f4ec729a7 --- /dev/null +++ b/test/files/run/t5866.check @@ -0,0 +1,2 @@ +0.0 +Foo(0.0) 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) + } +} |