@@ -2523,11 +2523,38 @@ public void luaFunctionRefsReuseOneAdapterAndPreserveSingleReturn() {
25232523 assertEquals ("both Condition calls must reference the cached adapter" , 2 ,
25242524 countMatches (compiled , "Condition\\ (" + Pattern .quote (adapter ) + "\\ )" ));
25252525 String adapterBody = getFunctionBody (compiled , adapter );
2526- assertTrue (adapterBody .contains ("local _, result = xpcall(predicate," ));
2526+ assertTrue (adapterBody .contains ("_, result = xpcall(predicate," ));
25272527 assertTrue (adapterBody .contains ("return result" ));
25282528 assertFalse ("callback sites must not allocate anonymous wrappers" , compiled .contains ("Condition(function (" ));
25292529 }
25302530
2531+ @ Test
2532+ public void luaFunctionRefAdapterTracksLateClassFunctionRename () {
2533+ String compiled = compileLuaWithCUs (
2534+ "LuaTranslationTests_luaFunctionRefAdapterTracksLateClassFunctionRename" ,
2535+ false ,
2536+ Collections .emptyList (),
2537+ new RunArgs ().with ("-lua" ),
2538+ "package Test" ,
2539+ "@extern native consume(code callback)" ,
2540+ "@extern native CallbackOwner_staticCallback()" ,
2541+ "class CallbackOwner" ,
2542+ " function start()" ,
2543+ " consume(function staticCallback)" ,
2544+ " private static function staticCallback()" ,
2545+ " consume(function staticCallback)" ,
2546+ "init" ,
2547+ " CallbackOwner_staticCallback()" ,
2548+ " new CallbackOwner().start()"
2549+ );
2550+
2551+ String callbackName = singleMatch (compiled ,
2552+ "function\\ s+(CallbackOwner_[A-Za-z0-9_]*staticCallback[A-Za-z0-9_]*)\\ (\\ )" , 1 );
2553+ assertTrue ("adapter must track the class callback's final name:\n " + compiled ,
2554+ compiled .contains ("xpcall(" + callbackName + "," ));
2555+ assertFalse (compiled .contains ("xpcall(staticCallback," ));
2556+ }
2557+
25312558 @ Test
25322559 public void luaFunctionRefStacktraceHandlerUsesWurstStackPosition () throws IOException {
25332560 CU errorHandling = new CU ("ErrorHandling.wurst" , String .join ("\n " ,
0 commit comments