diff --git a/gencommon.ml b/gencommon.ml index 182e37e72e2..acabdf37aae 100644 --- a/gencommon.ml +++ b/gencommon.ml @@ -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 diff --git a/tests/unit/issues/Issue2835.hx b/tests/unit/issues/Issue2835.hx index 809606b9786..bce4cfb2a2d 100644 --- a/tests/unit/issues/Issue2835.hx +++ b/tests/unit/issues/Issue2835.hx @@ -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()); } } @@ -17,6 +20,16 @@ private class Test this.value = value; } + public function toFloat():Float + { + return value; + } + + public function fromFloat(v:Float) + { + this.value = cast v; + } + public function get():T { return value;