Skip to content

ScalaDoc fails to recognize inherited inner enum #8993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue Nov 18, 2014 · 5 comments
Closed

ScalaDoc fails to recognize inherited inner enum #8993

scabug opened this issue Nov 18, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Nov 18, 2014

The ScalaDoc tool is breaking on a mixed Java/Scala project because it seems unable to properly parse Java code with an inherited inner enum. I have recreated the problem with a very small test project.

Consider the two classes:

public abstract class AbstractPolygon {

    public static enum Color {
        RED,
        GREEN,
        BLUE;
    }

    private final Color color;
    private final int sides;

    public AbstractPolygon (final Color color, final int sides) {
        this.color = color;
        this.sides = sides;
    }
}

public class Triangle extends AbstractPolygon {

    private final double angle1;
    private final double angle2;

    public Triangle (final Color color, final double angle1, final double angle2) {
        super(color, 3);
        this.angle1 = angle1;
        this.angle2 = angle2;
    }
}

The above java code is valid, yet the ScalaDoc tool will complain processing Triangle.java saying:
{quote}error: not found: type Color{quote}

I have attached a sample project that recreates the issue. Simply do the following to reproduce: mvn clean install site

Note that a workaround is to explicitly import the enum. So, for Triangle.java, ScalaDoc will work if the following is added:

import com.acme.AbstractPolygon.Color;

(Unfortunately, then this creates a style issue in the Java code since that import is not necessary.)

@scabug
Copy link
Author

scabug commented Nov 18, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8993?orig=1
Reporter: Anthony Whitford (awhitford)
Affected Versions: 2.11.4
See #1409, #1211
Attachments:

@scabug
Copy link
Author

scabug commented Jul 22, 2015

Alessandro Vermeulen (Spockz) said:
We have the same issue with enums imported directly through implements SomeInterface. The import 'fixes' the issue but is fragile as it will be removed by auto-layout.

Any ideas on whether, and if yes, when, this will be fixed?

@scabug
Copy link
Author

scabug commented Sep 9, 2015

Nathan Blomquist (nblomquist) said:
I just ran into this with Java8's Stream Collector. This may become more of a problem as it is now happening with a Java standard library interface.

Example:

import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
public class MyCollector implements Collector<Object, Object, Object> {
    @Override
    public Supplier<Object> supplier() {
        return null;
    }

    @Override
    public BiConsumer<Object, Object> accumulator() {
        return null;
    }

    @Override
    public BinaryOperator<Object> combiner() {
        return null;
    }

    @Override
    public Function<Object, Object> finisher() {
        return null;
    }

    /***
     * This breaks, because of Characteristics isn't directly imported.
     * 
     */
    @Override
    public Set<Characteristics> characteristics() {
        return null;
    }
}

@scabug
Copy link
Author

scabug commented Sep 9, 2015

@SethTisue said:
probably related to #1409

@som-snytt
Copy link

Scaladoc runs to completion, but doesn't emit a companion object for the enclosing Java class, though hover over Color correctly says AbstractPolygon.Color.

Since that would be a (possibly dubious) enhancement, closing this ticket.

@som-snytt som-snytt closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2023
@SethTisue SethTisue removed this from the Backlog milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants