Skip to content

Method name clashes #50

@Simn

Description

@Simn

Since all classes implicitly inherit from java.lang.Object at run-time, we have to deal with name clashes. The following methods are final and have to be escaped:

  • Class<?> getClass()
  • void notify()
  • void notifyAll()
  • void wait(long timeout)
  • void wait(long timeout, int nanos)
  • void wait()

Note that the signature is relevant and we only have to escape if a method matches in both name and signature.

The following methods are not final and might be overridden:

  • int hashCode()
  • boolean equals(Object obj)
  • Object clone()
  • String toString()
  • void finalize()

The question here is what we want to do with those. We can treat toString as a separate case because it's defined in Haxe with the same semantics, so we always want to allow overriding it in classes. For the others, there are two options:

  1. Escape by default, allow to not-escape (and thus override) with metadata.
  2. Don't escape (and thus override) by default, allow to to escape with metadata.

Not sure which option is better. From a pragmatic point of view I'm leaning towards 2.


As for how to handle the escaping, I propose that we prefix with _hx_ and make sure reflection respects that. This should be a matter of stripping a leading _hx_ in some places, and adding it in some others. That's pretty annoying, but I don't think we can avoid it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions