diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2009-11-30 16:42:35 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2009-11-30 16:42:35 +0000 |
commit | 706c86380e035a07a9f33eec20111b35368a6271 (patch) | |
tree | f6b7e42dbf116064264f5a8c805c2722a74e9c71 /src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | |
parent | 41253da6fbf3fb8aa755ebe8318a83795ced2547 (diff) | |
download | scala-706c86380e035a07a9f33eec20111b35368a6271.tar.gz scala-706c86380e035a07a9f33eec20111b35368a6271.tar.bz2 scala-706c86380e035a07a9f33eec20111b35368a6271.zip |
Closed #2726 and added test for #2464 (refs #2464)
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 2abaf50d10..dd6b5d4948 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -408,6 +408,25 @@ abstract class ClassfileParser { var nameIdx = in.nextChar externalName = pool.getClassName(nameIdx) val c = if (externalName.toString.indexOf('$') < 0) pool.getClassSymbol(nameIdx) else clazz + + /** Parse parents for Java classes. For Scala, return AnyRef, since the real type will be unpickled. + * Updates the read pointer of 'in'. */ + def parseParents: List[Type] = { + if (isScala) { + in.nextChar // skip superclass + val ifaces = in.nextChar + in.bp += ifaces * 2 // .. and iface count interfaces + List(definitions.AnyRefClass.tpe) // dummy superclass, will be replaced by pickled information + } else { + val superType = if (isAnnotation) { in.nextChar; definitions.AnnotationClass.tpe } + else pool.getSuperClass(in.nextChar).tpe + val ifaceCount = in.nextChar + var ifaces = for (i <- List.range(0, ifaceCount)) yield pool.getSuperClass(in.nextChar).tpe + if (isAnnotation) ifaces = definitions.ClassfileAnnotationClass.tpe :: ifaces + superType :: ifaces + } + } + if (c != clazz && externalName.toString.indexOf("$") < 0) { if ((clazz eq NoSymbol) && (c ne NoSymbol)) clazz = c else throw new IOException("class file '" + in.file + "' contains wrong " + c) @@ -415,16 +434,10 @@ abstract class ClassfileParser { addEnclosingTParams(clazz) parseInnerClasses() // also sets the isScala / isScalaRaw / hasMeta flags, see r15956 - val superType = if (isAnnotation) { in.nextChar; definitions.AnnotationClass.tpe } - else pool.getSuperClass(in.nextChar).tpe - val ifaceCount = in.nextChar - var ifaces = for (i <- List.range(0, ifaceCount)) yield pool.getSuperClass(in.nextChar).tpe - if (isAnnotation) ifaces = definitions.ClassfileAnnotationClass.tpe :: ifaces - val parents = superType :: ifaces // get the class file parser to reuse scopes. instanceDefs = new Scope staticDefs = new Scope - val classInfo = ClassInfoType(parents, instanceDefs, clazz) + val classInfo = ClassInfoType(parseParents, instanceDefs, clazz) val staticInfo = ClassInfoType(List(), staticDefs, statics) if (!isScala && !isScalaRaw) { @@ -945,7 +958,7 @@ abstract class ClassfileParser { in.skip(attrLen) case nme.ScalaATTR => isScalaRaw = true - case nme.InnerClassesATTR => + case nme.InnerClassesATTR if !isScala => val entries = in.nextChar.toInt for (i <- 0 until entries) { val innerIndex = in.nextChar.toInt |