Skip to content

Java parser can't properly handle chain of static imports #18532

Open
@andrew-boyarshin

Description

@andrew-boyarshin

Compiler version

3.3.1

Minimized code

Repo (branch 4)

TLDR:

package bug.code;

import static bug.code.TypeTag.NumericClasses.*;

public enum TypeTag {

    INT(INTEGER),
    LONG(INTEGER),
    FLOAT(FLOATING),
    DOUBLE(FLOATING);

    final int numericClass;

    TypeTag(int numericClass) {
        this.numericClass = numericClass;
    }

    public static class NumericClasses {
        public static final int INTEGER = 1;
        public static final int FLOATING = 2;
    }
}
package bug.code;

import static bug.code.TypeTag.INT;

public class Kinds {
}

Output

> C:\dev\scala3-3.3.1\bin\scalac.bat .\src\code\Kinds.java .\src\code\TypeTag.java
-- [E008] Not Found Error: .\src\code\TypeTag.java:3:46 ------------------------
3 |import static bug.code.TypeTag.NumericClasses.*;
  |                                              ^
  |           value NumericClasses is not a member of object bug.code.TypeTag
1 error found

Expectation

Scala code compiles successfully in mixed mode, like in Scala 2.13.11, or even if you swap the order of those 2 files in the command line:

> C:\dev\scala3-3.3.1\bin\scalac.bat .\src\code\TypeTag.java .\src\code\Kinds.java

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions