Przeglądaj źródła

[cpp] Fix typing of underlying type for abstracts (#9542)

Dmitrii Maganov 5 lat temu
rodzic
commit
6a43072ad6
2 zmienionych plików z 19 dodań i 1 usunięć
  1. 1 1
      src/generators/gencpp.ml
  2. 18 0
      tests/unit/src/unit/issues/Issue9542.hx

+ 1 - 1
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 () ->

+ 18 - 0
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<Int>) from cpp.Reference<Int> {}
+
+#else
+class Issue9542 extends unit.Test {}
+#end