NumberFour / n4js

Type-Safety of Java & Javascript Flexibility
http://numberfour.github.io/n4js/
38 stars 8 forks source link

Initializer field structural typing is broken #379

Closed qtran-n4 closed 6 years ago

qtran-n4 commented 7 years ago

The following example reproduces the error.

class C {
    public set s(value: int) {}
}
let c: ~i~C;
c.s; // PROBLEM: we receive an error message "The accessor s is write-only." here even though c should have a getter s !
qtran-n4 commented 7 years ago

The bug also affects the error messages for structural type check:

class C {
    public set s(value: int) {}
}

class D {
    //public get s(): int { return null; }
    public set s(value: int) {}
}

let d: D;

//let c1: ~w~C;
//c1.s = 1;

let c: ~i~C = d; // WRONG ERROR MESSAGE: D is not a structural subtype of ~i~C: missing setter s; s failed: non-optional writable field requires a readable field or a getter in subtype.      

missing setter s is WRONG. It must be "missing getter s".

mmews-n4 commented 6 years ago

continued here https://github.com/eclipse/n4js/issues/552