为什么我在REPL中收到格式错误的类名错误?
定义父类
scala> class Fruit {
| def FruitMethod = "f"
| }
defined class Fruit
定义子类
scala> class Orange extends Fruit {
| def OrangeMethod = "o"
| }
defined class Orange
测试差异
scala> class MyContainer[+A](val a: A)(implicit manifest: scala.reflect.Manifest[A]) {
| def contents = manifest.runtimeClass.getSimpleName
| }
defined class MyContainer
scala> val fruitBasket: MyContainer[Fruit] = new MyContainer[Orange](new Orange())
fruitBasket: MyContainer[Fruit] = MyContainer@7546be68
scala> fruitBasket.contents
java.lang.InternalError: Malformed class name
at java.lang.Class.getSimpleName(Class.java:1330)
at MyContainer.contents(<console>:13)
... 29 elided