Skip to content

Commit

Permalink
[java/cs] Better fix for Issue HaxeFoundation#2835|
Browse files Browse the repository at this point in the history
  • Loading branch information
waneck committed Apr 12, 2014
1 parent 9b89fd9 commit 73d7891
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gencommon.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5714,6 +5714,9 @@ struct
mk_cast to_t e)
| TAbstract (a_to, _), TAbstract(a_from, _) when a_to == a_from ->
e
| TAbstract _, TInst({ cl_kind = KTypeParameter _ }, _)
| TInst({ cl_kind = KTypeParameter _ }, _), TAbstract _ ->
do_unsafe_cast()
| TAbstract _, _
| _, TAbstract _ ->
(try
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/issues/Issue2835.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class Issue2835 extends unit.Test
{
var t = new Test(42);
eq(42,t.get());
t.fromFloat(12);
eq(12,t.get());
eq(12.0,t.toFloat());
}
}

Expand All @@ -17,6 +20,16 @@ private class Test<T:(Float)>
this.value = value;
}

public function toFloat():Float
{
return value;
}

public function fromFloat(v:Float)
{
this.value = cast v;
}

public function get():T
{
return value;
Expand Down

0 comments on commit 73d7891

Please sign in to comment.