aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-04-18 11:31:11 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-05-08 21:47:59 +0200
commit92c02ee9d514c197221fd4c4a027fe0e70e081f2 (patch)
treef67fca6c3ee91658257b960e3e4a39c1bb50d4c3 /src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
parent5c11da2148412f36416ad6998909138323ae4894 (diff)
downloaddotty-92c02ee9d514c197221fd4c4a027fe0e70e081f2.tar.gz
dotty-92c02ee9d514c197221fd4c4a027fe0e70e081f2.tar.bz2
dotty-92c02ee9d514c197221fd4c4a027fe0e70e081f2.zip
Removing duplication between Any and Object methods
We cannot have same named methods defined in Object and Any because after erasure the Any references get remapped to the Object methods which would result in a double binding assertion failure. Instead we do the following: - Have some methods exist only in Any, and remap them with the Erasure denotation transformer to be owned by Object. - Have other methods exist only in Object. To achieve this, we synthesize all Any and Object methods; Objetc methods no longer get loaded from a classfile. There's a complication with getClass. We need to reconsider what the best treatment of getClass is. Right now there's too much magic going on for my taste. It might be better to leave getClass on Object only as it is in Java, forget about the special treatement of its type, and have another getClass like method in an decorator on class Any. That could produce the right types and could also work for primitive types.
Diffstat (limited to 'src/dotty/tools/dotc/core/pickling/ClassfileParser.scala')
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
index f5942dac2..0ed301732 100644
--- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
+++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala
@@ -891,8 +891,10 @@ class ClassfileParser(
def getType(index: Int)(implicit ctx: Context): Type =
sigToType(getExternalName(index))
- def getSuperClass(index: Int)(implicit ctx: Context): Symbol =
- if (index == 0) defn.AnyClass else getClassSymbol(index)
+ def getSuperClass(index: Int)(implicit ctx: Context): Symbol = {
+ assert(index != 0, "attempt to parse java.lang.Object from classfile")
+ getClassSymbol(index)
+ }
def getConstant(index: Int)(implicit ctx: Context): Constant = {
if (index <= 0 || len <= index) errorBadIndex(index)