From 1a6f6aee960bb13057e9d33ebbe29b6f4e538a2e Mon Sep 17 00:00:00 2001 From: Hyper_ <40342021+NotHyper-474@users.noreply.github.com> Date: Sun, 19 Oct 2025 01:25:49 -0300 Subject: [PATCH] Fix a syntax error with the RegistryMacro and a partial fix for code completion --- source/funkin/data/BaseRegistry.hx | 2 +- source/funkin/util/macro/RegistryMacro.hx | 38 ++++++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/source/funkin/data/BaseRegistry.hx b/source/funkin/data/BaseRegistry.hx index ccbb16d77..d6cbf0f68 100644 --- a/source/funkin/data/BaseRegistry.hx +++ b/source/funkin/data/BaseRegistry.hx @@ -18,7 +18,7 @@ typedef EntryConstructorFunction = (String, ?Dynamic) -> Void; */ @:nullSafety @:generic -@:autoBuild(funkin.util.macro.DataRegistryMacro.buildRegistry()) +@:autoBuild(funkin.util.macro.RegistryMacro.buildRegistry()) abstract class BaseRegistry & Constructible), J, P> { /** diff --git a/source/funkin/util/macro/RegistryMacro.hx b/source/funkin/util/macro/RegistryMacro.hx index fbbd5c92d..adf8025f6 100644 --- a/source/funkin/util/macro/RegistryMacro.hx +++ b/source/funkin/util/macro/RegistryMacro.hx @@ -101,26 +101,34 @@ class RegistryMacro */ static function getTypeParams(cls:ClassType):RegistryTypeParams { + var params:Array = []; + var typeParams:Array = []; switch (cls.superClass.t.get().kind) { - case KGenericInstance(_, params): - var typeParams:Array = []; - for (param in params) - { - switch (param) - { - case TInst(t, _): - typeParams.push(t.get()); - case TType(t, _): - typeParams.push(t.get()); - default: - throw 'Not a class'; - } - } - return {entryType: typeParams[0], dataType: typeParams[1]}; + case KGenericInstance(_, _params): + params = _params; + case KGeneric: + // For some reason the only case where it's KGeneric + // is on the language server so we have to handle it too. + // This seems to be somehow related to the broken code completion. + params = cls.superClass.params; default: throw '${cls.name}: Could not interpret type parameters of Registry class.'; } + + for (param in params) + { + switch (param) + { + case TInst(t, _): + typeParams.push(t.get()); + case TType(t, _): + typeParams.push(t.get()); + default: + throw 'Not a class'; + } + } + return {entryType: typeParams[0], dataType: typeParams[1]}; } /**