New name generation for transformed when classes

This commit is contained in:
Michael Bogdanov
2016-03-14 12:19:46 +03:00
parent a72636afb8
commit 92f1a20d5f
2 changed files with 12 additions and 3 deletions
@@ -23,7 +23,8 @@ public class NameGenerator {
private final String ownerMethod;
private int nextIndex = 1;
private int nextLambdaIndex = 1;
private int nextWhenIndex = 1;
private final Map<String, NameGenerator> subGenerators = new HashMap<String, NameGenerator>();
@@ -32,7 +33,11 @@ public class NameGenerator {
}
public String genLambdaClassName() {
return ownerMethod + "$" + nextIndex++;
return ownerMethod + "$" + nextLambdaIndex++;
}
public String genWhenClassNamePrefix() {
return ownerMethod + "$" + nextWhenIndex++;
}
public NameGenerator subGenerator(String inliningMethod) {
@@ -43,7 +43,7 @@ class WhenMappingTransformationInfo(
) : TransformationInfo {
override val newClassName by lazy {
nameGenerator.genLambdaClassName() + oldClassName.substringAfterLast("/")
nameGenerator.genWhenClassNamePrefix() + TRANSFORMED_WHEN_MAPPING_MARKER + oldClassName.substringAfterLast("/").substringAfterLast(TRANSFORMED_WHEN_MAPPING_MARKER)
}
override fun shouldRegenerate(sameModule: Boolean): Boolean {
@@ -57,6 +57,10 @@ class WhenMappingTransformationInfo(
override fun createTransformer(inliningContext: InliningContext, sameModule: Boolean): ObjectTransformer<*> {
return WhenMappingTransformer(this, inliningContext)
}
companion object {
const val TRANSFORMED_WHEN_MAPPING_MARKER = "\$wm$"
}
}
class AnonymousObjectTransformationInfo internal constructor(