Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: X10 1.7 - JVM hosted
-
Fix Version/s: X10 1.7.1 - JVM Hosted
-
Component/s: X10 Compiler: Front-end
-
Labels:None
-
Number of attachments :
Description
class C {}
class Bug {
def foo(it:Iterator[C]) {
val c:C = it.next();
}
}
x10c: classes\Bug.java:90: incompatible types
found : java.lang.Object
required: C
/* } */).next();
^
1 error
Workaround: use for (...) syntax where possible; if not possible add a cast: it.next() as C.
Activity
Bruce Lucas
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Summary | handling of Iterator is broken | "incompatible types" using the next() function of an Iterator |
| Priority | Blocker [ 1 ] | Major [ 3 ] |
| Description |
{code} class C {} class Bug { def foo(it:Iterator[C]) { val c:C = it.next(); } } {code} x10c: classes\Bug.java:90: incompatible types found : java.lang.Object required: C /* } */).next(); ^ 1 error If we change the definition of x10.lang.Iterator to not have a NativeRep of java.util.Iterator the preceding code works, but I imagine this would break X10 library code written in Java that implements Iterators, and then also the following code breaks: \\ \\ {code} class C {} class D { incomplete def iterator(): Iterator[C]; } class Bug { def bar(d:D) { for (c:C in d); } } {code} x10c: classes\Bug.java:82: incompatible types found : x10.lang.Iterator<capture of ? extends C> required: java.util.Iterator for (java.util.Iterator c__ = (d).iterator(); c__.hasNext(); ) { ^ Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error |
{code} class C {} class Bug { def foo(it:Iterator[C]) { val c:C = it.next(); } } {code} x10c: classes\Bug.java:90: incompatible types found : java.lang.Object required: C /* } */).next(); ^ 1 error Workaround: use for (...) syntax where possible; if not possible add a cast: it.next() as C. |
Bruce Lucas
made changes -
| Resolution | Fixed [ 1 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |
Appears to have been fixed (per daily test run)