summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-07-22 18:37:35 -0700
committerJakob Odersky <jakob@odersky.com>2016-07-26 11:42:26 -0700
commit5eb19785c3d89b21919725a46375324890e993e7 (patch)
treeccab81453491e0b10e81d0442a4f42a0231d5ac3
parentd39ce7a66ad1d24d620339a90293c6f4d86de1dc (diff)
downloadscala-5eb19785c3d89b21919725a46375324890e993e7.tar.gz
scala-5eb19785c3d89b21919725a46375324890e993e7.tar.bz2
scala-5eb19785c3d89b21919725a46375324890e993e7.zip
Javadoc: fix assertion errors for java fields
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala4
-rw-r--r--test/scaladoc/resources/SI-4826.java66
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 <T> some type
+ */
+ public class InnerTyped<T> {
+ }
+
/**
* 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 <A> the parameter type
+ * @param a parameter
+ * @return something
+ */
+ public <A> void tparams(A a) {
+ }
+ /**
+ * Typed parameter
+ * @param <A> the return type
+ * @param <B> the parameter typeA
+ * @param b parameter
+ * @return casts B to A
+ */
+ public <A, B extends A> A cast(B b) {
+ return (B) b;
+ }
+
+}