From 0b656d54be6ac8144ea9885543926e60de4fef69 Mon Sep 17 00:00:00 2001 From: Dmitrii Maganov Date: Tue, 28 Jul 2020 16:42:35 +0300 Subject: [PATCH] [cpp] Fix typing of underlying type for abstracts (#9542) --- src/generators/gencpp.ml | 2 +- tests/unit/src/unit/issues/Issue9542.hx | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/unit/src/unit/issues/Issue9542.hx diff --git a/src/generators/gencpp.ml b/src/generators/gencpp.ml index 590f6221acb..18a71aa903b 100644 --- a/src/generators/gencpp.ml +++ b/src/generators/gencpp.ml @@ -1749,7 +1749,7 @@ let rec cpp_type_of stack ctx haxe_type = | TAbstract (abs,pl) when not (Meta.has Meta.CoreType abs.a_meta) -> cpp_type_from_path stack ctx abs.a_path pl (fun () -> - cpp_type_of stack ctx (Abstract.get_underlying_type abs pl) ) + cpp_type_of stack ctx (Abstract.get_underlying_type ~return_first:true abs pl) ) | TAbstract (a,params) -> cpp_type_from_path stack ctx a.a_path params (fun () -> diff --git a/tests/unit/src/unit/issues/Issue9542.hx b/tests/unit/src/unit/issues/Issue9542.hx new file mode 100644 index 00000000000..ea259b6ce6b --- /dev/null +++ b/tests/unit/src/unit/issues/Issue9542.hx @@ -0,0 +1,18 @@ +package unit.issues; +#if (cpp && !cppia) + +class Issue9542 extends unit.Test { + @:analyzer(no_optimize) + function test() { + var foo = 0; + var bar: Bar = foo; + foo += 1; + eq(bar, 1); + } +} + +private abstract Bar(cpp.Reference) from cpp.Reference {} + +#else +class Issue9542 extends unit.Test {} +#end