Skip to content

Regression compiling Java in 0.5.0 #2979

@dfabulich

Description

@dfabulich

This repository https://github.com/dfabulich/raw-list-bug builds without error in Bazel 0.4.5 when I run bazel build example, but fails to build in Bazel 0.5.0rc3

build failure message
ERROR: /private/tmp/raw-list-bug/BUILD:1:1: Building example.jar (1 source file) failed: Worker process sent response with exit code: 1.
src/main/java/com/redfin/Example.java:8: error: reference to newArrayList is ambiguous
		newArrayList(newLinkedHashSet(new ArrayList()));
		^
  both method <E#1>newArrayList(Iterable<? extends E#1>) in Example and method <E#2>newArrayList(Iterator<? extends E#2>) in Example match
  where E#1,E#2 are type-variables:
    E#1 extends Object declared in method <E#1>newArrayList(Iterable<? extends E#1>)
    E#2 extends Object declared in method <E#2>newArrayList(Iterator<? extends E#2>)
Target //:example failed to build

It seems like this must be a bug in the compiler; the code is using a raw LinkedHashSet, which is an Iterable, but it is not an Iterator.

The code compiles just fine with Oracle's javac compiler javac 1.8.0_112

Environment info

  • Operating System:
    macOS Sierra 10.12.4

  • Bazel version (output of bazel info release):
    release 0.5rc3 (it works with release 0.4.5)

I tried both the 0.5 version with an embedded JDK and without an embedded JDK, to see if that has an effect; it failed in both versions of Bazel 0.5 with identical error messages.

Metadata

Metadata

Assignees

Labels

P1I'll work on this now. (Assignee required)under investigation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions