Skip to content

Commit

Permalink
[typing] do not apply abstract field casts on static extensions
Browse files Browse the repository at this point in the history
closes #5924
  • Loading branch information
Simn committed Jun 6, 2018
1 parent bcea7ec commit 248f411
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 16 deletions.
1 change: 1 addition & 0 deletions extra/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ XXXX-XX-XX: 4.0.0-preview.4

all : implemented `for` loop unrolling (#3784)
all : metadata can now use `.`, e.g. `@:a.b`. This is represented as a string (#3959)
all : [breaking] disallow static extensions through abstract field casts (#5924)
js : added externs for js.Date (#6855)
js : respect `-D source-map` flag to generate source maps in release builds
js : enums are now generated as objects instead of arrays (#6350)
Expand Down
2 changes: 1 addition & 1 deletion src/typing/fields.ml
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ let rec using_field ctx mode e i p =
begin match follow t with
| TFun((_,_,(TType({t_path = ["haxe";"macro"],"ExprOf"},[t0]) | t0)) :: args,r) ->
if is_dynamic && follow t0 != t_dynamic then raise Not_found;
let e = AbstractCast.cast_or_unify_raise ctx t0 e p in
Type.unify e.etype t0;
(* early constraints check is possible because e.etype has no monomorphs *)
List.iter2 (fun m (name,t) -> match follow t with
| TInst ({ cl_kind = KTypeParameter constr },_) when constr <> [] && not (has_mono m) ->
Expand Down
21 changes: 21 additions & 0 deletions tests/misc/projects/Issue5924/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Main;

class Main {
static function main() {
0.bar();
}

static function bar(f:Foo)
f.bar();
}

abstract Foo(String) {

inline function new(v) this = v;

@:from static function ofInt(i:Int)
return new Foo('$i');

public function bar() {};
public function baz() {};
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue5924/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-main Main
--interp
1 change: 1 addition & 0 deletions tests/misc/projects/Issue5924/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:5: characters 9-14 : Int has no field bar
15 changes: 0 additions & 15 deletions tests/unit/src/unit/issues/Issue2152.hx

This file was deleted.

0 comments on commit 248f411

Please sign in to comment.