Minor. Fix review remarks

This commit is contained in:
Mikhael Bogdanov
2017-05-16 14:21:05 +02:00
parent fd561c6cb9
commit d9dc2bd443
9 changed files with 110 additions and 10 deletions
@@ -183,7 +183,7 @@ class AnonymousObjectTransformer(
capturedBuilder: ParametersBuilder,
isConstructor: Boolean
): InlineResult {
val typeParametersToReify = inliningContext.root.inlineMethodReificator.reifyInstructions(sourceNode)
val typeParametersToReify = inliningContext.root.inlineMethodReifier.reifyInstructions(sourceNode)
val parameters = if (isConstructor) capturedBuilder.buildParameters() else getMethodParametersWithCaptured(capturedBuilder, sourceNode)
val remapper = RegeneratedLambdaFieldRemapper(
@@ -25,7 +25,7 @@ class RootInliningContext(
nameGenerator: NameGenerator,
val callElement: KtElement,
override val callSiteInfo: InlineCallSiteInfo,
val inlineMethodReificator: ReifiedTypeInliner,
val inlineMethodReifier: ReifiedTypeInliner,
typeParameterMappings: TypeParameterMappings
) : InliningContext(
null, expressionMap, state, nameGenerator, TypeRemapper.createRoot(typeParameterMappings), null, false
@@ -75,11 +75,9 @@ class MethodInliner(
): InlineResult {
//analyze body
var transformedNode = markPlacesForInlineAndRemoveInlinable(node, labelOwner, finallyDeepShift)
if (inliningContext.isInliningLambda &&
inliningContext.lambdaInfo is DefaultLambda &&
inliningContext.lambdaInfo.needReification) {
if (inliningContext.isInliningLambda && isDefaultLambdaWithReification(inliningContext.lambdaInfo!!)) {
//TODO maybe move reification in one place
inliningContext.root.inlineMethodReificator.reifyInstructions(transformedNode)
inliningContext.root.inlineMethodReifier.reifyInstructions(transformedNode)
}
//substitute returns with "goto end" instruction to keep non local returns in lambdas
@@ -277,9 +275,7 @@ class MethodInliner(
super.visitMethodInsn(opcode, owner, name, desc, itf)
}
}
else if ((!inliningContext.isInliningLambda ||
inliningContext.lambdaInfo is DefaultLambda &&
inliningContext.lambdaInfo.needReification) &&
else if ((!inliningContext.isInliningLambda || isDefaultLambdaWithReification(inliningContext.lambdaInfo!!)) &&
ReifiedTypeInliner.isNeedClassReificationMarker(MethodInsnNode(opcode, owner, name, desc, false))) {
//we shouldn't process here content of inlining lambda it should be reified at external level except default lambdas
}
@@ -306,6 +302,9 @@ class MethodInliner(
return resultNode
}
private fun isDefaultLambdaWithReification(lambdaInfo: LambdaInfo) =
lambdaInfo is DefaultLambda && lambdaInfo.needReification
private fun prepareNode(node: MethodNode, finallyDeepShift: Int): MethodNode {
node.instructions.resetLabels()
@@ -26,7 +26,7 @@ class TypeRemapper private constructor(
val parent: TypeRemapper? = null,
val isRootInlineLambda: Boolean = false
) {
private var additionalMappings = hashMapOf<String, String>()
private val additionalMappings = hashMapOf<String, String>()
private val typeParametersMapping = hashMapOf<String, TypeParameter>()
fun addMapping(type: String, newType: String) {