Skip to content

Commit 1b5f190

Browse files
committed
Merge remote-tracking branch 'retronym/ticket/11365' into topic/pipeline-trace-macro-omnibus-rebase-all
2 parents 51fd636 + 43385c2 commit 1b5f190

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
131131
* (`owner` tells where the type occurs).
132132
*/
133133
def privates[T <: Tree](typer: Typer, owner: Symbol, tree: T): T =
134-
check(typer, owner, EmptyScope, WildcardType, tree)
134+
if (owner.isJavaDefined) tree else check(typer, owner, EmptyScope, WildcardType, tree)
135135

136136
private def check[T <: Tree](typer: Typer, owner: Symbol, scope: Scope, pt: Type, tree: T): T = {
137137
this.owner = owner
@@ -1759,7 +1759,9 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
17591759
checkStablePrefixClassType(parent)
17601760

17611761
if (psym != superclazz) {
1762-
if (psym.isTrait) {
1762+
if (context.unit.isJava && context.unit.isJava && psym.isJavaAnnotation) {
1763+
// allowed
1764+
} else if (psym.isTrait) {
17631765
val ps = psym.info.parents
17641766
if (!ps.isEmpty && !superclazz.isSubClass(ps.head.typeSymbol))
17651767
pending += ParentSuperSubclassError(parent, superclazz, ps.head.typeSymbol, psym)
@@ -1845,7 +1847,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
18451847
if (clazz.isTrait && clazz.info.parents.nonEmpty && clazz.info.firstParent.typeSymbol == AnyClass)
18461848
checkEphemeral(clazz, impl2.body)
18471849

1848-
if ((clazz isNonBottomSubClass ClassfileAnnotationClass) && (clazz != ClassfileAnnotationClass)) {
1850+
if (!clazz.isJavaDefined && (clazz isNonBottomSubClass ClassfileAnnotationClass) && (clazz != ClassfileAnnotationClass)) {
18491851
if (!clazz.owner.isPackageClass)
18501852
context.error(clazz.pos, "inner classes cannot be classfile annotations")
18511853
// Ignore @SerialVersionUID, because it is special-cased and handled completely differently.
@@ -2008,7 +2010,7 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
20082010
if (clazz.isTrait && hasSuperArgs(parents1.head))
20092011
ConstrArgsInParentOfTraitError(parents1.head, clazz)
20102012

2011-
if ((clazz isSubClass ClassfileAnnotationClass) && !clazz.isTopLevel)
2013+
if (!clazz.isJavaDefined && (clazz isSubClass ClassfileAnnotationClass) && !clazz.isTopLevel)
20122014
context.error(clazz.pos, "inner classes cannot be classfile annotations")
20132015

20142016
if (!phase.erasedTypes && !clazz.info.resultType.isError) // @S: prevent crash for duplicated type members

test/scaladoc/resources/t11365.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* A package header
3+
*/
4+
package test.scaladoc;
5+
6+
/**
7+
* Testing java comments don't flag Scala specific errors
8+
*/
9+
public class JavaComments {
10+
static @interface Annot {
11+
}
12+
13+
private class Route {}
14+
final java.util.List<Route> routes = null;
15+
16+
abstract class AnnotImpl implements Annot {}
17+
18+
}

test/scaladoc/run/t11365.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Done.

test/scaladoc/run/t11365.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import scala.tools.nsc.doc.Universe
2+
import scala.tools.nsc.doc.model._
3+
import scala.tools.partest.ScaladocJavaModelTest
4+
5+
object Test extends ScaladocJavaModelTest {
6+
7+
override def resourceFile = "t11365.java"
8+
override def scaladocSettings = ""
9+
10+
def testModel(rootPackage: Package) = {
11+
import access._
12+
val Tag = ":marker:"
13+
14+
val base = rootPackage._package("test")._package("scaladoc")
15+
val clazz = base._class("JavaComments")
16+
// Just testing that we haven't hit a compiler error.
17+
}
18+
}

0 commit comments

Comments
 (0)