From d6e20eb987bb725ad5c4ea3d130b3d415bc70623 Mon Sep 17 00:00:00 2001 From: player-03 Date: Fri, 6 Dec 2024 16:14:58 -0500 Subject: [PATCH] Don't run `embedBytes()` if `embedByteArray()` is also running. (#1871) * Don't run `embedBytes()` if `embedByteArray()` is also running. Both functions insert a constructor, and one class can't have two constructors, much less call `super()` with two different signatures. I can only assume a bug in Haxe that prevented this from being an issue until now, and that Haxe 5 is fixing the bug. * Check for `@:autoBuild` only after checking for embed data. If we ever decide to handle the case of the embed functions being called for non-classes (meaning `getLocalClass()` would return null), we'd handle it in `embedData()`. Therefore `embedData()` should happen first. --- src/lime/_internal/macros/AssetsMacro.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lime/_internal/macros/AssetsMacro.hx b/src/lime/_internal/macros/AssetsMacro.hx index 5871daa800..a5b403ee86 100644 --- a/src/lime/_internal/macros/AssetsMacro.hx +++ b/src/lime/_internal/macros/AssetsMacro.hx @@ -31,6 +31,16 @@ class AssetsMacro var fields = embedData(":file"); if (fields == null) return null; + for (autoBuild in Context.getLocalClass().get().meta.extract(":autoBuild")) + { + switch (autoBuild.params[0]) + { + case macro lime._internal.macros.AssetsMacro.embedByteArray(): + return null; + default: + } + } + var superCall = Context.defined("html5") ? macro super(bytes.b.buffer) : Context.defined("hl") ? macro super(bytes.b, bytes.length) : macro super(bytes.length, bytes.b);