summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-07-22 18:34:47 -0700
committerJason Zaugg <jzaugg@gmail.com>2016-08-13 13:26:50 +1000
commitad67700b1cc685f115da14a5af759b8859f1e9c2 (patch)
treece4b1028ddc45281d9e87be8508e7a7204a3eeb3 /src/compiler
parent4e822d74be9c21377189428ca474ec990af6cc87 (diff)
downloadscala-ad67700b1cc685f115da14a5af759b8859f1e9c2.tar.gz
scala-ad67700b1cc685f115da14a5af759b8859f1e9c2.tar.bz2
scala-ad67700b1cc685f115da14a5af759b8859f1e9c2.zip
Javadoc: fix problems in community build
- fix initialization NPE in doc headers - fix assertion errors for java fields - ignore comments when deciding where to put interface methods - consider DocDefs when checking for constructors
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeInfo.scala8
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala20
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala2
3 files changed, 21 insertions, 9 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 22460b6ca8..e4bc055da4 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -117,11 +117,8 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
atPos(pkg.pos) { PackageDef(pkg, stats) }
def makeTemplate(parents: List[Tree], stats: List[Tree]) =
- Template(
- parents,
- noSelfType,
- if (treeInfo.firstConstructor(stats) == EmptyTree) makeConstructor(List()) :: stats
- else stats)
+ 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)
@@ -586,7 +583,7 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
case CLASS | ENUM | INTERFACE | AT =>
typeDecl(if (definesInterface(parentToken)) mods | Flags.STATIC else mods)
case _ =>
- joinComment(termDecl(mods, parentToken))
+ termDecl(mods, parentToken)
}
def makeCompanionObject(cdef: ClassDef, statics: List[Tree]): Tree =
@@ -708,8 +705,15 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners {
in.nextToken()
} else {
if (in.token == ENUM || definesInterface(in.token)) mods |= Flags.STATIC
- val decls = memberDecl(mods, parentToken)
- (if (mods.hasStaticFlag || inInterface && !(decls exists (_.isInstanceOf[DefDef])))
+ val decls = joinComment(memberDecl(mods, parentToken))
+
+ def isDefDef(tree: Tree): Boolean = tree match {
+ case _: DefDef => true
+ case DocDef(_, defn) => isDefDef(defn)
+ case _ => false
+ }
+
+ (if (mods.hasStaticFlag || inInterface && !(decls exists isDefDef))
statics
else
members) ++= decls
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
index ea323d0fba..99ef4ed373 100644
--- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala
@@ -201,7 +201,7 @@ trait MethodSynthesis {
import AnnotationInfo.{mkFilter => annotationFilter}
def addDerivedTrees(typer: Typer, stat: Tree): List[Tree] = stat match {
- case vd @ ValDef(mods, name, tpt, rhs) if deriveAccessors(vd) && !vd.symbol.isModuleVar =>
+ case vd @ ValDef(mods, name, tpt, rhs) if deriveAccessors(vd) && !vd.symbol.isModuleVar && !vd.symbol.isJava =>
stat.symbol.initialize // needed!
val getter = Getter(vd)