diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/TreeInfo.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/javac/JavaParsers.scala | 18 |
2 files changed, 11 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala index 689e6405d0..b78c5acc4f 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeInfo.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeInfo.scala @@ -97,4 +97,12 @@ abstract class TreeInfo extends scala.reflect.internal.TreeInfo { case DocDef(_, definition) => isPureDef(definition) case _ => super.isPureDef(tree) } + + override def firstConstructor(stats: List[Tree]): Tree = { + def unwrap(stat: Tree): Tree = stat match { + case DocDef(_, defn) => unwrap(defn) + case tree => tree + } + super.firstConstructor(stats map unwrap) + } } diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index e6291934db..e4bc055da4 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -116,9 +116,9 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { def makePackaging(pkg: RefTree, stats: List[Tree]): PackageDef = atPos(pkg.pos) { PackageDef(pkg, stats) } - def makeTemplate(parents: List[Tree], stats: List[Tree]) = { - Template(parents, noSelfType, withConstructor(stats)) - } + def makeTemplate(parents: List[Tree], stats: List[Tree]) = + Template(parents, noSelfType, if (treeInfo.firstConstructor(stats) == EmptyTree) + makeConstructor(Nil) :: stats else stats) def makeSyntheticParam(count: Int, tpt: Tree): ValDef = makeParam(nme.syntheticParamName(count), tpt) @@ -132,18 +132,6 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { DefDef(Modifiers(Flags.JAVA), nme.CONSTRUCTOR, List(), List(vparams), TypeTree(), blankExpr) } - def withConstructor(stats: List[Tree]): List[Tree] = { - val pureStats = stats map { - case DocDef(_, defn) => defn - case defn => defn - } - if(treeInfo.firstConstructor(pureStats) == EmptyTree) { - makeConstructor(Nil) :: stats - } else { - stats - } - } - /** A hook for joining the comment associated with a definition. * Overridden by scaladoc. */ |