@ilya.chernikov I see two options, one is to pop back off the class loader, descriptor and history replcodeline so that it is truly isolated and do not need to worry about class names being duplicated. so each level gets a class loader delegating on faillure to find class to the parent, a chain.
the other is to leave the orphaned classes and disassociate the line number from the actual class naming, just make it informational, so the class always has a unique name during compilation regardless of line number which is used only for error reporting.