Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: X10 2.2.1
-
Fix Version/s: X10 2.3.2
-
Component/s: X10 Compiler: Front-end
-
Labels:None
-
Number of attachments :
Description
In the program below, Child typechecks, but Child2 does not. The problem is that Bin2 is not being found when checking the constraint on Child2. Child typechecks because Bin is being explicitly qualified and this appears to avoid the bug. This is a somewhat common idiom when writing code that uses generic frameworks in X10, so it should be fixed. Only marking as major priority since there is an easy workaround.
abstract class M[S,T] { abstract def m(x:S, y:T):void; } abstract class Parent[S,T]{S<:Comparable[S]} { abstract def makeM():M[S,T]; } class Child extends Parent[Child.Bin, Int] { static struct Bin implements Comparable[Bin] { public def compareTo(y:Bin):Int = 1; } def makeM() = new M[Bin,Int]() { def m(b:Bin, x:Int) {} }; } class Child2 extends Parent[Bin2, Int] { static struct Bin2 implements Comparable[Bin2] { public def compareTo(y:Bin2):Int = 1; } def makeM() = new M[Bin2,Int]() { def m(b:Bin2, x:Int) {} }; } public class StaticStruct { public static def main(Array[String]) { } }
The error messages are:
/home/dgrove/x10-trunk/myTests/StaticStruct.x10:18: Could not find type "Bin2". /home/dgrove/x10-trunk/myTests/StaticStruct.x10:18: Cannot instantiate type container since type guard was not entailed. Type Container: Parent[Bin2, x10.lang.Int] Type Guard: [S <: x10.lang.Comparable[S]] /home/dgrove/x10-trunk/myTests/StaticStruct.x10:18: Type is inconsistent. Type: Parent[Bin2, x10.lang.Int] /home/dgrove/x10-trunk/myTests/StaticStruct.x10:22-24: Method A in container A cannot override method B in container B; attempting to use incompatible return type. Method A: makeM(): <anonymous class>{self!=null} Container A: Child2 Method B: makeM(): M[Bin2, x10.lang.Int] Container B: Parent[Bin2, x10.lang.Int] Expected Type: M[Bin2, x10.lang.Int] Found Type: <anonymous class>{self!=null} 4 errors.
I think the key is the first messages. Compiler was unable to find the type Bin2.
Activity
David Grove
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Fix Version/s | X10 2.2.3 [ 18146 ] | |
| Fix Version/s | X10 2.2.2 [ 17639 ] |
David Grove
made changes -
| Fix Version/s | X10 2.3 [ 17009 ] | |
| Fix Version/s | X10 2.2.3 [ 18146 ] |
David Grove
made changes -
| Fix Version/s | X10 2.3.1 [ 18657 ] | |
| Fix Version/s | X10 2.3 [ 17009 ] |
David Grove
made changes -
| Fix Version/s | X10 2.3.2 [ 19010 ] | |
| Fix Version/s | X10 2.3.1 [ 18657 ] |