summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jakob@odersky.com>2016-08-01 15:07:18 -0700
committerJakob Odersky <jakob@odersky.com>2016-08-01 15:14:13 -0700
commitf5c939e3af56755f16053ce434ed6a91f47ca852 (patch)
treeec2e5c534e358e9ef422bc69e57cb25b21d8071f
parent5eb19785c3d89b21919725a46375324890e993e7 (diff)
downloadscala-f5c939e3af56755f16053ce434ed6a91f47ca852.tar.gz
scala-f5c939e3af56755f16053ce434ed6a91f47ca852.tar.bz2
scala-f5c939e3af56755f16053ce434ed6a91f47ca852.zip
Javadoc: ignore comments when deciding where to put interface methods
-rw-r--r--src/compiler/scala/tools/nsc/javac/JavaParsers.scala13
-rw-r--r--test/scaladoc/resources/SI-4826.java214
-rw-r--r--test/scaladoc/run/SI-4826.scala2
3 files changed, 225 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
index 01ca8033ac..e1e14d9016 100644
--- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
+++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala
@@ -586,7 +586,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 =
@@ -726,8 +726,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/test/scaladoc/resources/SI-4826.java b/test/scaladoc/resources/SI-4826.java
index 34e55ab26e..24454e88b2 100644
--- a/test/scaladoc/resources/SI-4826.java
+++ b/test/scaladoc/resources/SI-4826.java
@@ -82,3 +82,217 @@ public class JavaComments {
}
}
+
+// The following snippet is taken from Akka, it mainly tests interfaces
+
+/**
+ * Class that encapsulates all the Functional Interfaces
+ * used for creating partial functions.
+ *
+ * This is an EXPERIMENTAL feature and is subject to change until it has received more real world testing.
+ */
+public final class FI {
+ private FI() {
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I> the input type, that this Apply will be applied to
+ * @param <R> the return type, that the results of the application will have
+ */
+ public static interface Apply<I, R> {
+ /**
+ * The application to perform.
+ *
+ * @param i an instance that the application is performed on
+ * @return the result of the application
+ */
+ public R apply(I i) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <R> the return type, that the results of the application will have
+ */
+ public static interface Apply2<I1, I2, R> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @return the result of the application
+ */
+ public R apply(I1 i1, I2 i2) throws Exception;
+ }
+
+ /**
+ * Functional interface for a predicate.
+ *
+ * @param <T> the type that the predicate will operate on.
+ */
+ public static interface TypedPredicate<T> {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param t an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(T t);
+ }
+
+ /**
+ * Functional interface for a predicate.
+ *
+ * @param <T> the type that the predicate will operate on.
+ * @param <U> the type that the predicate will operate on.
+ */
+ public static interface TypedPredicate2<T, U> {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param t an instance that the predicate is evaluated on.
+ * @param u an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(T t, U u);
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I> the input type, that this Apply will be applied to
+ */
+ public static interface UnitApply<I> {
+ /**
+ * The application to perform.
+ *
+ * @param i an instance that the application is performed on
+ */
+ public void apply(I i) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ */
+ public static interface UnitApply2<I1, I2> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <I3> the third input type, that this Apply will be applied to
+ */
+ public static interface UnitApply3<I1, I2, I3> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @param i3 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2, I3 i3) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <I3> the third input type, that this Apply will be applied to
+ * @param <I4> the fourth input type, that this Apply will be applied to
+ */
+ public static interface UnitApply4<I1, I2, I3, I4> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @param i3 an instance that the application is performed on
+ * @param i4 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2, I3 i3, I4 i4) throws Exception;
+ }
+
+ /**
+ * Functional interface for an application.
+ */
+ public static interface UnitApplyVoid {
+ /**
+ * The application to perform.
+ */
+ public void apply() throws Exception;
+ }
+
+ /**
+ * Package scoped functional interface for a predicate. Used internally to match against arbitrary types.
+ */
+ static interface Predicate {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param o an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(Object o);
+ }
+
+}
+
+/**
+ * Functional interface for an application.
+ *
+ * @param <I1> the first input type, that this Apply will be applied to
+ * @param <I2> the second input type, that this Apply will be applied to
+ * @param <I3> the third input type, that this Apply will be applied to
+ * @param <I4> the fourth input type, that this Apply will be applied to
+ */
+public interface UnitApply4<I1, I2, I3, I4> {
+ /**
+ * The application to perform.
+ *
+ * @param i1 an instance that the application is performed on
+ * @param i2 an instance that the application is performed on
+ * @param i3 an instance that the application is performed on
+ * @param i4 an instance that the application is performed on
+ */
+ public void apply(I1 i1, I2 i2, I3 i3, I4 i4) throws Exception;
+}
+
+/**
+ * Functional interface for an application.
+ */
+public interface UnitApplyVoid {
+ /**
+ * The application to perform.
+ */
+ public void apply() throws Exception;
+}
+
+/**
+ * Package scoped functional interface for a predicate. Used internally to match against arbitrary types.
+ */
+interface Predicate {
+ /**
+ * The predicate to evaluate.
+ *
+ * @param o an instance that the predicate is evaluated on.
+ * @return the result of the predicate
+ */
+ public boolean defined(Object o);
+}
diff --git a/test/scaladoc/run/SI-4826.scala b/test/scaladoc/run/SI-4826.scala
index 50e4468002..277ff37692 100644
--- a/test/scaladoc/run/SI-4826.scala
+++ b/test/scaladoc/run/SI-4826.scala
@@ -14,7 +14,7 @@ object Test extends ScaladocModelTest {
}
// no need for special settings
- def scaladocSettings = ""
+ override def scaladocSettings = ""
def testModel(rootPackage: Package) = {
import access._