Skip to content

Commit 14af663

Browse files
removed premature abstract cast while typing against enum (fixes #10173)
1 parent 3705657 commit 14af663

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

extra/CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
all : fixed subtypes in `expr is Module.SubType` expressions (#10174)
1010
all : fixed typing chains of calls with constrained type params (#10198)
1111
all : fixed mixed constraints of anonymous structures and other types (#10162)
12+
all : fixed operator overloading for enum abstracts (#10173)
1213
hl : fixed debugging of `catch` blocks (#10109)
1314
jvm : fixed manifest generation for cases with a lot of jar libraries (#10157)
1415
js : fixed extending extern classes for es5 (#10192)

src/typing/typer.ml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,7 @@ let maybe_type_against_enum ctx f with_type iscall p =
108108
(try Type.unify t' t with Unify_error _ -> ());
109109
AKExpr e
110110
| _ ->
111-
if iscall then
112-
AKExpr e
113-
else begin
114-
AKExpr (AbstractCast.cast_or_unify ctx t e e.epos)
115-
end
111+
AKExpr e
116112
end
117113
| _ -> e (* ??? *)
118114
end
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package unit.issues;
2+
3+
class Issue10173 extends Test {
4+
function test() {
5+
var foo:Foo = Bar;
6+
var i = 9999;
7+
t(foo == i);
8+
foo = Baz;
9+
f(foo == i);
10+
}
11+
}
12+
13+
private enum abstract Foo(Int) to Int {
14+
var Bar;
15+
var Baz;
16+
17+
@:op(A == B) public static function eqInt(lhs:Foo, rhs:Int):Bool {
18+
return switch lhs {
19+
case Bar: true;
20+
case Baz: false;
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)