Skip to content

Java type name resolution with wildcard imports is incorrect #18529

Closed
@andrew-boyarshin

Description

@andrew-boyarshin

Compiler version

3.3.1

Minimized code

Repo (branch 1)

TLDR:

package bug.code;

import bug.util.List;
import bug.util.*;
import java.util.*;

public class Code {
    public List<Long> work(List<Integer> list) {
        return null;
    }
}

Output

-- [E049] Reference Error: .\src\code\Code.java:8:27 ---------------------------
8 |    public List<Long> work(List<Integer> list) {
  |                           ^^^^
  |                           Reference to List is ambiguous.
  |                           It is both imported by import bug.util._
  |                           and imported subsequently by import java.util._
  |
  | longer explanation available when compiling with `-explain`
-- [E049] Reference Error: .\src\code\Code.java:8:11 ---------------------------
8 |    public List<Long> work(List<Integer> list) {
  |           ^^^^
  |           Reference to List is ambiguous.
  |           It is both imported by import bug.util._
  |           and imported subsequently by import java.util._
  |
  | longer explanation available when compiling with `-explain`

Expectation

Scala code compiles successfully in mixed mode, like in Scala 2.13.11.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions