Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
Currently, a structural interface via @Structural requires a cast if not nominally implemented.
MyIface x = (MyIface) new MyClass(); // :( go away cast
If MyClass satisfies MyIface structurally but not nominally, it still requires a cast. This was always a stopgap solution for true structural typing. Let's finally include structural type checking into the compiler and IDE plugin.
MyIface x = new MyClass(); // :)
CharSequence hi = x.echo("hi");
double one = x.echo(1);
where:
@Structural
public interface MyIface {
CharSequence echo(String s);
double echo(int i);
}
public class MyClass {
public String echo(CharSequence s) {
return s.toString();
}
public int echo(double d) {
return (int)d;
}
}
In addition to satisfying by method, type checking should also support the other ways of satisfying a structural interface, such as by field, by proxy, etc. See criteria in documentation.
Currently, a structural interface via
@Structural
requires a cast if not nominally implemented.If
MyClass
satisfiesMyIface
structurally but not nominally, it still requires a cast. This was always a stopgap solution for true structural typing. Let's finally include structural type checking into the compiler and IDE plugin.where:
Generics must be handled as well.
Update:
In addition to satisfying by method, type checking should also support the other ways of satisfying a structural interface, such as by field, by proxy, etc. See criteria in documentation.