diff options
author | Paul Phillips <paulp@improving.org> | 2011-06-22 21:10:33 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-06-22 21:10:33 +0000 |
commit | 9853b5b8292650d8e192b500e636dc441550eef7 (patch) | |
tree | ec3a85b9b7af29c9fbd3bba17389791f083394cc /src/library/scala/Unit.scala | |
parent | e49ec10e93eeec1af775096de07dd46a7d0a1fad (diff) | |
download | scala-9853b5b8292650d8e192b500e636dc441550eef7.tar.gz scala-9853b5b8292650d8e192b500e636dc441550eef7.tar.bz2 scala-9853b5b8292650d8e192b500e636dc441550eef7.zip |
A total rewrite of "runtimeClass", discarding t...
A total rewrite of "runtimeClass", discarding the user-space approach in
favor of simply fixing getClass.
def f1 = 5.getClass // Class[Int]
def f2 = (5: AnyVal).getClass // Class[_ <: AnyVal]
def f3 = (5: java.lang.Integer).getClass // Class[_ <: java.lang.Integer]
class A
class B extends A
def f1 = (new B: Any).getClass().newInstance() // Any
def f2 = (new B: AnyRef).getClass().newInstance() // AnyRef
def f3 = (new B: A).getClass().newInstance() // A
def f4 = (new B: B).getClass().newInstance() // B
But that's not all!
def f0[T >: B] = (new B: T).getClass().newInstance()
def f5 = f0[Any] // Any
def f6 = f0[AnyRef] // AnyRef
def f7 = f0[A] // A
def f8 = f0[B] // B
Closes #490, #896, #4696. Review by moors. (Note: I think this is pretty
good, but picky review requested.)
Diffstat (limited to 'src/library/scala/Unit.scala')
-rwxr-xr-x | src/library/scala/Unit.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala index 58b024273b..c5d12afeba 100755 --- a/src/library/scala/Unit.scala +++ b/src/library/scala/Unit.scala @@ -15,8 +15,9 @@ package scala * not represented as objects by the underlying host system. There is * only one value of type Unit: `()`. */ -final class Unit extends AnyVal { } - +final class Unit extends AnyVal { + def getClass(): Class[Unit] = sys.error("stub") +} object Unit extends AnyValCompanion { |