Add -Xsanitize-parentheses to workaround ASM 6.1 issue in frame computation

#KT-29475 Fixed
This commit is contained in:
Alexander Udalov
2019-01-30 14:27:56 +01:00
parent dfb379d999
commit db487a622a
17 changed files with 163 additions and 3 deletions
@@ -20,6 +20,8 @@ import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.context.RootContext;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.config.JvmAnalysisFlags;
import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
@@ -380,4 +382,13 @@ public class JvmCodegenUtil {
public static boolean isPolymorphicSignature(@NotNull FunctionDescriptor descriptor) {
return descriptor.getAnnotations().hasAnnotation(new FqName("java.lang.invoke.MethodHandle.PolymorphicSignature"));
}
@NotNull
public static String sanitizeNameIfNeeded(@NotNull String name, @NotNull LanguageVersionSettings languageVersionSettings) {
if (languageVersionSettings.getFlag(JvmAnalysisFlags.getSanitizeParentheses())) {
return name.replace("(", "$_").replace(")", "$_");
}
return name;
}
}
@@ -443,7 +443,8 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
@NotNull
private MutableClosure recordClosure(@NotNull ClassDescriptor classDescriptor, @NotNull String name) {
return CodegenBinding.recordClosure(bindingTrace, classDescriptor, getProperEnclosingClass(), Type.getObjectType(name));
Type type = Type.getObjectType(JvmCodegenUtil.sanitizeNameIfNeeded(name, languageVersionSettings));
return CodegenBinding.recordClosure(bindingTrace, classDescriptor, getProperEnclosingClass(), type);
}
@Nullable
@@ -1156,6 +1156,8 @@ public class KotlinTypeMapper {
name += JvmAbi.IMPL_SUFFIX_FOR_INLINE_CLASS_MEMBERS;
}
name = JvmCodegenUtil.sanitizeNameIfNeeded(name, languageVersionSettings);
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
if (Visibilities.isPrivate(descriptor.getVisibility()) && !(descriptor instanceof ConstructorDescriptor) && !"<clinit>".equals(name)) {
String partName = getPartSimpleNameForMangling(descriptor);