manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.43k stars 125 forks source link

Default method in structural interface applied to a Map does not yield to override in map instance #436

Closed rsmckinney closed 1 year ago

rsmckinney commented 1 year ago
  @Structural
  interface Dog {
    String getBreed();
    void setBreed(String breed);
    default boolean likes(String thing) {
      return true;
    }
  }
    Dog dog = (Dog)new HashMap<>();
    dog.setBreed("Foxhound");
    ((Map)dog).put("likes", (Function<String,Boolean>)(thing -> !thing.equals("relaxation")));
    String breed = dog.getBreed();
    out.println(breed);
    out.println(dog.likes("ball"));
    out.println(dog.likes("relaxation")); // Bug: prints true, does not call override ^^
rsmckinney commented 1 year ago

Fixed available with release 2023.1.5