diff options
author | Martin Odersky <odersky@gmail.com> | 2008-10-09 13:34:06 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2008-10-09 13:34:06 +0000 |
commit | 2e770c31b64c61317ea405f1030293ef6c65b380 (patch) | |
tree | 181e22c23a62e47eeb066820eb11aae30f5000ff | |
parent | 8f1a65cb9735dff2c51e4f0f3b0e3a075ff9ebeb (diff) | |
download | scala-2e770c31b64c61317ea405f1030293ef6c65b380.tar.gz scala-2e770c31b64c61317ea405f1030293ef6c65b380.tar.bz2 scala-2e770c31b64c61317ea405f1030293ef6c65b380.zip |
attempt at fixing t1409
-rwxr-xr-x | src/compiler/scala/tools/nsc/javac/JavaParsers.scala | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index a0ee29edc9..6920028e28 100755 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -685,7 +685,7 @@ trait JavaParsers extends JavaScanners { javaLangObject() } val interfaces = interfacesOpt() - val (statics, body) = typeBody(CLASS) + val (statics, body) = typeBody(CLASS, name) addCompanionObject(statics, atPos(pos) { ClassDef(mods, name, tparams, makeTemplate(superclass :: interfaces, body)) }) @@ -703,7 +703,7 @@ trait JavaParsers extends JavaScanners { } else { List(javaLangObject) } - val (statics, body) = typeBody(INTERFACE) + val (statics, body) = typeBody(INTERFACE, name) addCompanionObject(statics, atPos(pos) { ClassDef(mods | Flags.TRAIT | Flags.INTERFACE | Flags.ABSTRACT, name, tparams, @@ -711,14 +711,14 @@ trait JavaParsers extends JavaScanners { }) } - def typeBody(leadingToken: Int): (List[Tree], List[Tree]) = { + def typeBody(leadingToken: Int, parentName: Name): (List[Tree], List[Tree]) = { accept(LBRACE) - val defs = typeBodyDecls(leadingToken) + val defs = typeBodyDecls(leadingToken, parentName) accept(RBRACE) defs } - def typeBodyDecls(parentToken: Int): (List[Tree], List[Tree]) = { + def typeBodyDecls(parentToken: Int, parentName: Name): (List[Tree], List[Tree]) = { val inInterface = definesInterface(parentToken) val statics = new ListBuffer[Tree] val members = new ListBuffer[Tree] @@ -738,7 +738,18 @@ trait JavaParsers extends JavaScanners { members) ++= decls } } - (statics.toList, members.toList) + def forwarders(sdef: Tree): List[Tree] = sdef match { + case ClassDef(mods, name, tparams, _) if (parentToken == INTERFACE) => + val tparams1: List[TypeDef] = tparams map (_.duplicate) + var rhs: Tree = Select(Ident(parentName.toTermName), name) + if (!tparams1.isEmpty) rhs = AppliedTypeTree(rhs, tparams1 map (tp => Ident(tp.name))) + List(TypeDef(Modifiers(Flags.PROTECTED), name, tparams1, rhs)) + case _ => + List() + } + val sdefs = statics.toList + val idefs = members.toList ::: (sdefs flatMap forwarders) + (sdefs, idefs) } def annotationDecl(mods: Modifiers): List[Tree] = { @@ -749,7 +760,7 @@ trait JavaParsers extends JavaScanners { val parents = List(scalaDot(newTypeName("Annotation")), Select(javaLangDot(newTermName("annotation")), newTypeName("Annotation")), scalaDot(newTypeName("ClassfileAnnotation"))) - val (statics, body) = typeBody(AT) + val (statics, body) = typeBody(AT, name) def getValueMethodType(tree: Tree) = tree match { case DefDef(_, nme.value, _, _, tpt, _) => Some(tpt.duplicate) case _ => None @@ -784,7 +795,7 @@ trait JavaParsers extends JavaScanners { val (statics, body) = if (in.token == SEMI) { in.nextToken - typeBodyDecls(ENUM) + typeBodyDecls(ENUM, name) } else { (List(), List()) } |