Fix: Reset Unique field counters on Mixin application. (#136)

They previously caused hotswaps to fail due to the number increasing on each application.
This commit is contained in:
LlamaLad7 authored and GitHub committed 2024-04-11 13:52:14 +01:00
1 parent a2091792e8
commit 320b74c2d4
2 files changed
+10 -1

No files matched your search

@@ -76,6 +76,14 @@ class MethodMapper {
public ClassInfo getClassInfo() {
return this.info;
}
/**
* Resets the counters to prepare for application, which can happen multiple times due to hotswap.
*/
public void reset() {
this.nextUniqueMethodIndex = 0;
this.nextUniqueFieldIndex = 0;
}
/**
* Conforms an injector handler method
@@ -407,9 +407,10 @@ final class TargetClassContext extends ClassContext implements ITargetClassConte
}
/**
* Run extensions before apply
* Run extensions before apply and clean up any global state in case this is a hotswap
*/
private void preApply() {
this.getClassInfo().getMethodMapper().reset();
this.extensions.preApply(this);
}