Added canRemoveAfterTransformation method
This commit is contained in:
+7
-3
@@ -87,6 +87,13 @@ public class AnonymousObjectRegenerationInfo extends RegenerationInfo {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRemoveAfterTransformation() {
|
||||||
|
// Note: It is unsafe to remove anonymous class that is referenced by GETSTATIC within lambda
|
||||||
|
// because it can be local function from outer scope
|
||||||
|
return !isStaticOrigin;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<Integer, LambdaInfo> getLambdasToInline() {
|
public Map<Integer, LambdaInfo> getLambdasToInline() {
|
||||||
return lambdasToInline;
|
return lambdasToInline;
|
||||||
}
|
}
|
||||||
@@ -130,7 +137,4 @@ public class AnonymousObjectRegenerationInfo extends RegenerationInfo {
|
|||||||
return constructorDesc;
|
return constructorDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStaticOrigin() {
|
|
||||||
return isStaticOrigin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,10 +196,8 @@ public class MethodInliner {
|
|||||||
result.addAllClassesToRemove(transformResult);
|
result.addAllClassesToRemove(transformResult);
|
||||||
result.addChangedType(oldClassName, newClassName);
|
result.addChangedType(oldClassName, newClassName);
|
||||||
|
|
||||||
if (inliningContext.isInliningLambda && !anonymousObjectGen.isStaticOrigin()) {
|
if (inliningContext.isInliningLambda && anonymousObjectGen.canRemoveAfterTransformation()) {
|
||||||
// this class is transformed and original not used so we should remove original one after inlining
|
// this class is transformed and original not used so we should remove original one after inlining
|
||||||
// Note: It is unsafe to remove anonymous class that is referenced by GETSTATIC within lambda
|
|
||||||
// because it can be local function from outer scope
|
|
||||||
result.addClassToRemove(oldClassName);
|
result.addClassToRemove(oldClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,14 +19,21 @@ package org.jetbrains.kotlin.codegen.inline
|
|||||||
abstract class RegenerationInfo() {
|
abstract class RegenerationInfo() {
|
||||||
|
|
||||||
abstract fun getOldClassName(): String
|
abstract fun getOldClassName(): String
|
||||||
|
|
||||||
abstract fun getNewClassName(): String
|
abstract fun getNewClassName(): String
|
||||||
|
|
||||||
abstract fun shouldRegenerate(sameModule: Boolean): Boolean
|
abstract fun shouldRegenerate(sameModule: Boolean): Boolean
|
||||||
|
|
||||||
|
abstract fun canRemoveAfterTransformation(): Boolean
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class WhenMappingRegenerationInfo(val oldName: String, val nameGenerator: NameGenerator) : RegenerationInfo() {
|
class WhenMappingRegenerationInfo(val oldName: String, val nameGenerator: NameGenerator) : RegenerationInfo() {
|
||||||
|
|
||||||
|
val newName by lazy {
|
||||||
|
nameGenerator.genLambdaClassName() + oldName
|
||||||
|
}
|
||||||
|
|
||||||
override fun shouldRegenerate(sameModule: Boolean): Boolean {
|
override fun shouldRegenerate(sameModule: Boolean): Boolean {
|
||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
@@ -36,6 +43,10 @@ class WhenMappingRegenerationInfo(val oldName: String, val nameGenerator: NameGe
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getNewClassName(): String {
|
override fun getNewClassName(): String {
|
||||||
return nameGenerator.genLambdaClassName() + oldName
|
return newName
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun canRemoveAfterTransformation(): Boolean {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user