Skip to content

Commit

Permalink
[cs] Consider String as basic type (#8387)
Browse files Browse the repository at this point in the history
* Add failing tests

* [cs] Consider String as basic type too

* HxObject.getParams() returns an Array<{}>

* Add tests for #5434
  • Loading branch information
kLabz authored and Simn committed Jun 9, 2019
1 parent c218710 commit c3d8e8a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/codegen/gencommon/enumToClass2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module EnumToClass2Modf = struct
let e_pack, e_name = en.e_path in
let cl_enum_t = TInst (cl_enum, []) in
let cf_getTag_t = tfun [] basic.tstring in
let cf_getParams_ret = basic.tarray basic.tstring in
let cf_getParams_ret = basic.tarray (mk_anon PMap.empty) in
let cf_getParams_t = tfun [] cf_getParams_ret in
let static_ctors = ref [] in
let ctors_map = ref PMap.empty in
Expand Down
1 change: 1 addition & 0 deletions src/generators/gencs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ let generate con =
Null<> type parameters will be transformed into Dynamic.
*)
| true, TInst ( { cl_path = (["haxe";"lang"], "Null") }, _ ) -> dynamic_anon
| true, TInst ( { cl_path = ([], "String") }, _ ) -> t
| true, TInst ( { cl_kind = KTypeParameter _ }, _ ) -> t
| true, TInst _
| true, TEnum _
Expand Down
6 changes: 6 additions & 0 deletions tests/misc/projects/Issue5434/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface ITest<K, V> {
function keys():Array<K>;
function values():Array<V>;
}

interface ISubTest extends ITest<String, String> {}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue5434/compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Main
-cs bin
22 changes: 22 additions & 0 deletions tests/misc/projects/Issue8361/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class SortedStringMapImpl<V> extends haxe.ds.BalancedTree<String, V> implements haxe.Constraints.IMap<String,V> {

var cmp:String -> String -> Int;

public function new(?comparator:String -> String -> Int) {
super();
this.cmp = comparator == null ? haxe.Utf8.compare : comparator;
}

override
function compare(s1:String, s2:String):Int {
return cmp(s1, s2);
}
}

class Main {
static function main() {
var m = new SortedStringMapImpl<String>();
m.set("foo", "bar");
trace(m);
}
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue8361/compile.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-main Main
-cs bin

0 comments on commit c3d8e8a

Please sign in to comment.