From 5eb19785c3d89b21919725a46375324890e993e7 Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Fri, 22 Jul 2016 18:37:35 -0700 Subject: Javadoc: fix assertion errors for java fields --- .../tools/nsc/typechecker/MethodSynthesis.scala | 4 +- test/scaladoc/resources/SI-4826.java | 66 +++++++++++++++++++++- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index c03094bc6a..d6176a15d5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -165,7 +165,8 @@ trait MethodSynthesis { } 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 => // If we don't save the annotations, they seem to wander off. val annotations = stat.symbol.initialize.annotations val trees = ( @@ -183,7 +184,6 @@ trait MethodSynthesis { if (!trees.exists(_.symbol hasAnnotation ann.symbol)) issueAnnotationWarning(vd, ann, GetterTargetClass) ) - trees case vd: ValDef => warnForDroppedAnnotations(vd) diff --git a/test/scaladoc/resources/SI-4826.java b/test/scaladoc/resources/SI-4826.java index f735ce6335..34e55ab26e 100644 --- a/test/scaladoc/resources/SI-4826.java +++ b/test/scaladoc/resources/SI-4826.java @@ -1,3 +1,6 @@ +/** + * A package header + */ package test.scaladoc; /** @@ -6,6 +9,29 @@ package test.scaladoc; */ public class JavaComments { + /** A field */ + public final int x; + /** A field */ + protected int y; + /** A field */ + private int z; + + /** + * Inner class + */ + public class Inner { + /** Inner method */ + public void foo() { + } + } + + /** + * A typed inner class + * @param some type + */ + public class InnerTyped { + } + /** * Compute the answer to the ultimate question of life, the * universe, and everything. :marker: @@ -16,5 +42,43 @@ public class JavaComments { return 42 * factor; } -} + /** Private */ + private double foo(double value) { + return value; + } + + /** Protected */ + protected double bar(double value) { + return value; + } + + /** No qualifier*/ + String noqualifier() { + return "something"; + } + + /** Void */ + public void voidmethod(boolean t) { + } + + /** + * Typed parameter + * @param the parameter type + * @param a parameter + * @return something + */ + public void tparams(A a) { + } + /** + * Typed parameter + * @param the return type + * @param the parameter typeA + * @param b parameter + * @return casts B to A + */ + public A cast(B b) { + return (B) b; + } + +} -- cgit v1.2.3