3 ms·
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method upcast(Unsound.Constrain<U,B>, B) in the type Unsound.Bind<U> is not ap
by shamsmali 10y ago
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method upcast(Unsound.Constrain<U,B>, B) in the type Unsound.Bind<U> is not applicable for the arguments (Unsound.Constrain<U,capture#1-of ? super T>, T)
at Unsound.coerce(Unsound.java:13)
at Unsound.main(Unsound.java:17)
- theemathas 10y agoWhat version of Java are you using? My understanding is that the Java language specifications say that this code is valid. Some versions of Java "correctly" accept this code is valid, and some versions "incorrectly" don't accept this code, as an implementation quirk.
- aseipp 10y agoYou're using the default example, but the error is mostly a red herring. The paper explicitly acknowledges this problem, Section 3 pg. 3: > ... As a consequence, the method type-checks. Furthermore, even though type-argument inference in Java is undecidable, this type argument is identified by javac, version 1.8.0_25, which consequently accepts and compiles the code in Figure 1. However, constraint solving is generally a non-deterministic process, and type-argument inference itself is non-deterministic [35], so the Eclipse Compiler for Java, ecj version 3.11.1.v20150902-1521, and the current compiler for the upcoming Java 9, javac build 108, fail to type-check this code... Use the `Unsound9` example, which should work in multiple versions. These discrepancies are merely due to some deficiencies in the way type inference happens in Java, but the unsoundness principle is still valid, and you can still construct invalid `coerce` functions.