HaxeFoundation/haxe — pull request #3341 by Simn (2014-09-15 08:39:32+00:00)
Title: Rewrite of abstract cast and operator overloading

This pull request makes two important internal changes:

1. The current `a_to` is split into `a_to` (for `to X`) declarations and `a_to_field` (for `@:to` fields). Same with `a_from`.
2. Unification no longer respects `@:to` and `@:from` fields. Instead it is necessary to call `Codegen.AbstractCast.cast_or_unify`, which returns a cast expression if needed.

Additionally we now consistently support abstract variance (which we have to review because it might be necessary to require both `from` and `to`).

The second change _might_ move some errors from run-time to compile-time. These would be cases where the cast is currently missing which generally leads to wrong run-time behavior.

I had to change two unit tests:

1. tests/unit/issues/Issue2713.hx: This was clearly missing an `@:arrayAccess` metadata. It only worked because the type would unify with `Array` through a `@:to` field, which is nonsense.
2. tests/unit/TestType.hx: This is some Java/C# issue that I'll need @waneck to fix. I'll make a proper issue after merging this.

Other than that the behavior _should_ be the same, but I can't make a guarantee for a change as big as this.