Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifold-ext: integrate automatic structural type checking into compiler & IJ plugin #577

Open
rsmckinney opened this issue May 2, 2024 · 2 comments

Comments

@rsmckinney
Copy link
Member

rsmckinney commented May 2, 2024

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;
  }
}

Generics must be handled as well.

List<MyClass> list = ...;
foo(list); 
. . .
void foo(List<? extends MyIface> l) {
  . . .
}

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.

rsmckinney added a commit that referenced this issue May 3, 2024
- integrate automatic structural type checking into compiler
rsmckinney added a commit to manifold-systems/manifold-ij that referenced this issue May 3, 2024
- integrate automatic structural type checking into IJ plugin

plus
- fix a "slow operation" exception
- fix actions wrt update thread
- update description in plugin.xml to include delegation and sql
- bump version
@rsmckinney
Copy link
Member Author

Fix available with release 2023.1.13

@rsmckinney rsmckinney reopened this May 30, 2024
@rsmckinney
Copy link
Member Author

Reopened. See addendum in description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant