eclipse-xtext / eclipse-xtext/xtext
Maven compilation failure for array with missing generics
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
I spent too much time chasing this error. I'm not sure what's causing it and the Xtend code that produces it compiles fine in Eclipse but fails during the Maven build. To be honest, I'm not even sure if it's the fault of Xtend or if something else is to blame.
Using:
- JDK 8
- Xtend 2.12.0
The error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project XXX: Compilation failure
[ERROR] XXX\target\generated-sources\xtend\ch\rswk\util\macro\AllAsListTest.java:[15,139] error: incompatible types: Object cannot be converted to List<String>
I'm able to reproduce it with this simple Xtend code:
package xxx
import com.google.common.util.concurrent.Futures
import com.google.common.util.concurrent.ListenableFuture
class AllAsListTest {
def void fail() {
val allAsList = Futures.allAsList(#[mockService, mockService, mockService]).get
}
def ListenableFuture<String> mockService() {}
}
I normally just use Futures.allAsList(mockService, mockService, mockService) but I somehow messed up some calls by wrapping them in a list.
The generated Java code and the line that causes the error:
final List<String> allAsList = Futures.<String>allAsList(new ListenableFuture[] { _mockService, _mockService_1, _mockService_2 }).get();
It should probably be new ListenableFuture<String>[]? But why does Eclipse not complain about it? Is there some additional inference going on?
-Chris
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sample Xtend code with JDK 8 and Xtend 2.12.0 through the Maven build, then inspect target/generated-sources/xtend/ch/rswk/util/macro/AllAsListTest.java and its failing allAsList call. Compare the generated Java with the Eclipse result to identify the generic-type mismatch. Done means the sample compiles through Maven without the Object-to-List error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100