Skip to content

Commit c5acb84

Browse files
committed
simplify the method call
1 parent f10405b commit c5acb84

File tree

13 files changed

+1500
-1359
lines changed

13 files changed

+1500
-1359
lines changed

jscomp/.merlin

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ B ounit
1515
S ounit_tests
1616
B ounit_tests
1717

18+
S main
19+
B main
20+
1821
S depends
1922
B depends
2023

jscomp/core/lam_convert.ml

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -816,22 +816,32 @@ let convert (exports : Set_ident.t) (lam : Lambda.lambda) : Lam.t * Lam_module_i
816816
Lam.for_ id (convert_aux from_) (convert_aux to_) dir (convert_aux loop)
817817
| Lassign (id, body) ->
818818
Lam.assign id (convert_aux body)
819-
| Lsend (Public(Some name), _, obj, _, _loc) ->
819+
| Lsend (Public(Some name), _, obj, _, send_loc) ->
820820
(* Format.fprintf Format.err_formatter "%a@." Printlambda.lambda b ; *)
821821
(match convert_aux obj with
822-
| Lprim {primitive = Pjs_unsafe_downgrade _; args;loc}
822+
(* | Lprim {primitive = Pjs_unsafe_downgrade _; args;loc}
823823
->
824-
let setter = Ext_string.ends_with name Literals.setter_suffix in
825-
let property =
826-
if setter then
827-
Lam_methname.translate
828-
(String.sub name 0
829-
(String.length name - Literals.setter_suffix_len))
830-
else Lam_methname.translate name in
831-
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
832-
~args loc
833-
| _ ->
834-
assert false)
824+
let setter = Ext_string.ends_with name Literals.setter_suffix in
825+
let property =
826+
if setter then
827+
Lam_methname.translate
828+
(String.sub name 0
829+
(String.length name - Literals.setter_suffix_len))
830+
else Lam_methname.translate name in
831+
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
832+
~args loc *)
833+
| obj ->
834+
let args = [obj] in
835+
let setter = Ext_string.ends_with name Literals.setter_suffix in
836+
let property =
837+
if setter then
838+
Lam_methname.translate
839+
(String.sub name 0
840+
(String.length name - Literals.setter_suffix_len))
841+
else Lam_methname.translate name in
842+
prim ~primitive:(Pjs_unsafe_downgrade {name = property; setter})
843+
~args send_loc
844+
)
835845
| Lsend _ -> assert false
836846
| Levent _ ->
837847
(* disabled by upstream*)

jscomp/frontend/bs_ast_invariant.ml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,6 @@ let emit_external_warnings : iterator=
142142
| Pexp_new _ ->
143143
Location.raise_errorf ~loc:a.pexp_loc
144144
"OCaml style objects are not supported"
145-
| Pexp_send (obj, _) ->
146-
begin match obj with
147-
| {pexp_desc = Pexp_apply ({pexp_desc = Pexp_ident ({txt = Ldot(_,"unsafe_downgrade")})},_)} -> ()
148-
| _ -> Location.raise_errorf ~loc:a.pexp_loc
149-
"OCaml style objects are not supported"
150-
end
151145
| _ -> super.expr self a
152146
);
153147
label_declaration = (fun self lbl ->

jscomp/main/builtin_cmi_datasets.ml

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

jscomp/others/js_OO.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
[@@@bs.config {flags = [|"-unboxed-types"|]}]
2626
(**/**)
27-
external unsafe_downgrade : 'a -> 'a = "#unsafe_downgrade"
28-
external unsafe_to_method : 'a -> 'a = "#fn_method"
27+
external unsafe_downgrade : 'a -> 'a = "%identity"
28+
external unsafe_to_method : 'a -> 'a = "#fn_method"
2929
(**/**)
3030
module Callback = struct
3131
type 'a arity1 = {

jscomp/test/build.ninja

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ o test/gray_code_test.cmi test/gray_code_test.cmj : cc test/gray_code_test.ml |
335335
o test/guide_for_ext.cmi test/guide_for_ext.cmj : cc test/guide_for_ext.ml | $stdlib
336336
o test/hamming_test.cmi test/hamming_test.cmj : cc test/hamming_test.ml | test/mt.cmj $stdlib
337337
o test/hash_collision_test.cmi test/hash_collision_test.cmj : cc test/hash_collision_test.ml | test/mt.cmj $stdlib
338+
o test/hash_sugar_desugar.cmj : cc_cmi test/hash_sugar_desugar.ml | test/hash_sugar_desugar.cmi $stdlib
339+
o test/hash_sugar_desugar.cmi : cc test/hash_sugar_desugar.mli | $stdlib
338340
o test/hash_test.cmi test/hash_test.cmj : cc test/hash_test.ml | test/mt.cmj test/mt_global.cmj $stdlib
339341
o test/hashtbl_test.cmi test/hashtbl_test.cmj : cc test/hashtbl_test.ml | test/mt.cmj $stdlib
340342
o test/hello.foo.cmi test/hello.foo.cmj : cc test/hello.foo.ml | $stdlib

0 commit comments

Comments
 (0)