diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2009-06-11 15:50:56 +0000 |
---|---|---|
committer | Iulian Dragos <jaguarul@gmail.com> | 2009-06-11 15:50:56 +0000 |
commit | e638fb866212108c09d4d09b9a26e24800b2b5f7 (patch) | |
tree | 8b81467a8022432890794c0d09e3888e1ad5173f /src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | |
parent | c762ae353b9ff8beec6ed9516b70134e1f04534d (diff) | |
download | scala-e638fb866212108c09d4d09b9a26e24800b2b5f7.tar.gz scala-e638fb866212108c09d4d09b9a26e24800b2b5f7.tar.bz2 scala-e638fb866212108c09d4d09b9a26e24800b2b5f7.zip |
Fixed a number of things in the icode reader, o...
Fixed a number of things in the icode reader, optimizations still not
fully functional.
Diffstat (limited to 'src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala index 8c49e68c25..10879e663e 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala @@ -245,19 +245,28 @@ abstract class ClassfileParser { f } - def getNameAndType(index: Int, ownerTpe: Type): (Name, Type) = { + /** Return a name and a type at the given index. If the type is a method + * type, a dummy symbol is created in 'ownerTpe', which is used as the + * owner of its value parameters. This might lead to inconsistencies, + * if a symbol of the given name already exists, and has a different + * type. + */ + private def getNameAndType(index: Int, ownerTpe: Type): (Name, Type) = { if (index <= 0 || len <= index) errorBadIndex(index) var p = values(index).asInstanceOf[(Name, Type)] if (p eq null) { val start = starts(index) if (in.buf(start) != CONSTANT_NAMEANDTYPE) errorBadTag(start) val name = getName(in.getChar(start + 1)) - var tpe = getType(in.getChar(start + 3)) + // create a dummy symbol for method types + val dummySym = ownerTpe.typeSymbol.newMethod(ownerTpe.typeSymbol.pos, name) + var tpe = getType(dummySym, in.getChar(start + 3)) + + // fix the return type, which is blindly set to the class currently parsed if (name == nme.CONSTRUCTOR) tpe match { - case MethodType(params, restpe) => - assert(restpe.typeSymbol == definitions.UnitClass) - tpe = MethodType(params, ownerTpe) + case MethodType(formals, restpe) => + tpe = MethodType(formals, ownerTpe) } p = (name, tpe) @@ -616,7 +625,7 @@ abstract class ClassfileParser { paramtypes += objToAny(sig2type(tparams, skiptvs)) } index += 1 - val restype = if (sym != null && sym.isConstructor) { + val restype = if (sym != null && sym.isClassConstructor) { accept('V') clazz.tpe } else |