Don't propagate reified markers for special enum functions
#KT-18254 Fixed
This commit is contained in:
@@ -4232,14 +4232,29 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
putReifiedOperationMarkerIfTypeIsReifiedParameter(type, operationKind, v, this);
|
||||
}
|
||||
|
||||
public static void putReifiedOperationMarkerIfTypeIsReifiedParameterWithoutPropagation(
|
||||
@NotNull KotlinType type, @NotNull ReifiedTypeInliner.OperationKind operationKind, @NotNull InstructionAdapter v
|
||||
) {
|
||||
putReifiedOperationMarkerIfTypeIsReifiedParameterImpl(type, operationKind, v, null);
|
||||
}
|
||||
|
||||
public static void putReifiedOperationMarkerIfTypeIsReifiedParameter(
|
||||
@NotNull KotlinType type, @NotNull ReifiedTypeInliner.OperationKind operationKind, @NotNull InstructionAdapter v,
|
||||
@NotNull BaseExpressionCodegen codegen
|
||||
) {
|
||||
putReifiedOperationMarkerIfTypeIsReifiedParameterImpl(type, operationKind, v, codegen);
|
||||
}
|
||||
|
||||
private static void putReifiedOperationMarkerIfTypeIsReifiedParameterImpl(
|
||||
@NotNull KotlinType type, @NotNull ReifiedTypeInliner.OperationKind operationKind, @NotNull InstructionAdapter v,
|
||||
@Nullable BaseExpressionCodegen codegen
|
||||
) {
|
||||
Pair<TypeParameterDescriptor, ReificationArgument> typeParameterAndReificationArgument = extractReificationArgument(type);
|
||||
if (typeParameterAndReificationArgument != null && typeParameterAndReificationArgument.getFirst().isReified()) {
|
||||
TypeParameterDescriptor typeParameterDescriptor = typeParameterAndReificationArgument.getFirst();
|
||||
codegen.consumeReifiedOperationMarker(typeParameterDescriptor);
|
||||
if (codegen != null) {
|
||||
codegen.consumeReifiedOperationMarker(typeParameterDescriptor);
|
||||
}
|
||||
v.iconst(operationKind.getId());
|
||||
v.visitLdcInsn(typeParameterAndReificationArgument.getSecond().asString());
|
||||
v.invokestatic(
|
||||
|
||||
@@ -166,7 +166,7 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
|
||||
var nodeAndSmap: SMAPAndMethodNode? = null
|
||||
try {
|
||||
nodeAndSmap = createInlineMethodNode(functionDescriptor, jvmSignature, codegen, callDefault, resolvedCall, state, sourceCompiler)
|
||||
nodeAndSmap = createInlineMethodNode(functionDescriptor, jvmSignature, callDefault, resolvedCall, state, sourceCompiler)
|
||||
endCall(inlineCall(nodeAndSmap, callDefault))
|
||||
}
|
||||
catch (e: CompilationException) {
|
||||
@@ -467,7 +467,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
internal fun createInlineMethodNode(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
jvmSignature: JvmMethodSignature,
|
||||
codegen: BaseExpressionCodegen,
|
||||
callDefault: Boolean,
|
||||
resolvedCall: ResolvedCall<*>?,
|
||||
state: GenerationState,
|
||||
@@ -478,7 +477,6 @@ abstract class InlineCodegen<out T: BaseExpressionCodegen>(
|
||||
val arguments = resolvedCall!!.typeArguments
|
||||
|
||||
val node = createSpecialEnumMethodBody(
|
||||
codegen,
|
||||
functionDescriptor.name.asString(),
|
||||
arguments.keys.single().defaultType,
|
||||
state.typeMapper
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ class InlineCodegenForDefaultBody(
|
||||
}
|
||||
|
||||
override fun genCallInner(callableMethod: Callable, resolvedCall: ResolvedCall<*>?, callDefault: Boolean, codegen: ExpressionCodegen) {
|
||||
val nodeAndSmap = InlineCodegen.createInlineMethodNode(functionDescriptor, jvmSignature, codegen, callDefault, null, state, sourceCompilerForInline)
|
||||
val nodeAndSmap = InlineCodegen.createInlineMethodNode(functionDescriptor, jvmSignature, callDefault, null, state, sourceCompilerForInline)
|
||||
val childSourceMapper = InlineCodegen.createNestedSourceMapper(nodeAndSmap, sourceMapper)
|
||||
|
||||
val node = nodeAndSmap.node
|
||||
|
||||
@@ -511,7 +511,6 @@ internal fun isSpecialEnumMethod(functionDescriptor: FunctionDescriptor): Boolea
|
||||
}
|
||||
|
||||
internal fun createSpecialEnumMethodBody(
|
||||
codegen: BaseExpressionCodegen,
|
||||
name: String,
|
||||
type: KotlinType,
|
||||
typeMapper: KotlinTypeMapper
|
||||
@@ -520,7 +519,7 @@ internal fun createSpecialEnumMethodBody(
|
||||
val invokeType = typeMapper.mapType(type)
|
||||
val desc = getSpecialEnumFunDescriptor(invokeType, isValueOf)
|
||||
val node = MethodNode(API, Opcodes.ACC_STATIC, "fake", desc, null, null)
|
||||
ExpressionCodegen.putReifiedOperationMarkerIfTypeIsReifiedParameter(type, ReifiedTypeInliner.OperationKind.ENUM_REIFIED, InstructionAdapter(node), codegen)
|
||||
ExpressionCodegen.putReifiedOperationMarkerIfTypeIsReifiedParameterWithoutPropagation(type, ReifiedTypeInliner.OperationKind.ENUM_REIFIED, InstructionAdapter(node))
|
||||
if (isValueOf) {
|
||||
node.visitInsn(Opcodes.ACONST_NULL)
|
||||
node.visitVarInsn(Opcodes.ALOAD, 0)
|
||||
|
||||
Reference in New Issue
Block a user