This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Sources for Value Classes

No replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

...is all done.

https://github.com/scala/scala/tree/anyval-sources
https://github.com/scala/scala/commit/6f67d461f73b78b76664b66d7c19787ad1...

It's thoroughly tested, but it seems like kind of a heavy thing to drop
on trunk without someone glancing at it. Would you like to glance at
it? There is more polish I would like to do but I already feel negligent
taking as much time for it as I did. It's using your generated source
files, so I'm taking it on faith that those are correct.

If there is an award for most taxing scala compiler bootstrapping
experience I would like to claim that now.

And the next time someone complains that Long has a >>>(Long) method
(unlikely? all complaints happen eventually) we can say "DELETE IT IF IT
DISPLEASES YOU."

% git diff
@@ -24,7 +24,7 @@ final class Long extends AnyVal {
def <<(x: Int): Long = throw new Error()
def <<(x: Long): Long = throw new Error()
def >>>(x: Int): Long = throw new Error()
- def >>>(x: Long): Long = throw new Error()
+ // def >>>(x: Long): Long = throw new Error()

Welcome to Scala version 2.9.0.r24027-b20110119221843 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

scala> 256L >>> 4
res0: Long = 16

scala> 256L >>> 4L
:6: error: type mismatch;
found : Long(4L)
required: Int
256L >>> 4L
^

Sadly you can't add methods unless you like VerifyErrors, but that could
change too...

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland