Use Java 8 lambdas instead of anonymous classes in compiler modules
This commit is contained in:
@@ -21,7 +21,6 @@ import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
@@ -501,14 +500,11 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
public static StackValue genToString(StackValue receiver, Type receiverType) {
|
||||
return StackValue.operation(JAVA_STRING_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
Type type = stringValueOfType(receiverType);
|
||||
receiver.put(type, v);
|
||||
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false);
|
||||
return null;
|
||||
}
|
||||
return StackValue.operation(JAVA_STRING_TYPE, v -> {
|
||||
Type type = stringValueOfType(receiverType);
|
||||
receiver.put(type, v);
|
||||
v.invokestatic("java/lang/String", "valueOf", "(" + type.getDescriptor() + ")Ljava/lang/String;", false);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -573,18 +569,15 @@ public class AsmUtil {
|
||||
return StackValue.cmp(opToken, leftType, left, right);
|
||||
}
|
||||
|
||||
return StackValue.operation(Type.BOOLEAN_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
left.put(leftType, v);
|
||||
right.put(rightType, v);
|
||||
genAreEqualCall(v);
|
||||
return StackValue.operation(Type.BOOLEAN_TYPE, v -> {
|
||||
left.put(leftType, v);
|
||||
right.put(rightType, v);
|
||||
genAreEqualCall(v);
|
||||
|
||||
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
|
||||
genInvertBoolean(v);
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
if (opToken == KtTokens.EXCLEQ || opToken == KtTokens.EXCLEQEQEQ) {
|
||||
genInvertBoolean(v);
|
||||
}
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -130,12 +128,7 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
|
||||
@NotNull
|
||||
public List<OutputFile> getCurrentOutput() {
|
||||
return ContainerUtil.map(generators.keySet(), new Function<String, OutputFile>() {
|
||||
@Override
|
||||
public OutputFile fun(String relativeClassFilePath) {
|
||||
return new OutputClassFile(relativeClassFilePath);
|
||||
}
|
||||
});
|
||||
return CollectionsKt.map(generators.keySet(), OutputClassFile::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,16 +176,13 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
|
||||
private PackagePartRegistry buildNewPackagePartRegistry(@NotNull FqName packageFqName) {
|
||||
String packageFqNameAsString = packageFqName.asString();
|
||||
return new PackagePartRegistry() {
|
||||
@Override
|
||||
public void addPart(@NotNull String partShortName, @Nullable String facadeShortName) {
|
||||
PackageParts packageParts = partsGroupedByPackage.get(packageFqNameAsString);
|
||||
if (packageParts == null) {
|
||||
packageParts = new PackageParts(packageFqNameAsString);
|
||||
partsGroupedByPackage.put(packageFqNameAsString, packageParts);
|
||||
}
|
||||
packageParts.addPart(partShortName, facadeShortName);
|
||||
return (partShortName, facadeShortName) -> {
|
||||
PackageParts packageParts = partsGroupedByPackage.get(packageFqNameAsString);
|
||||
if (packageParts == null) {
|
||||
packageParts = new PackageParts(packageFqNameAsString);
|
||||
partsGroupedByPackage.put(packageFqNameAsString, packageParts);
|
||||
}
|
||||
packageParts.addPart(partShortName, facadeShortName);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.intellij.util.ArrayUtil;
|
||||
import kotlin.Pair;
|
||||
import kotlin.Unit;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
|
||||
@@ -49,7 +48,6 @@ import org.jetbrains.kotlin.serialization.ProtoBuf;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils;
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
@@ -241,12 +239,9 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
|
||||
ProtoBuf.Function functionProto = serializer.functionProto(freeLambdaDescriptor).build();
|
||||
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0, new Function1<AnnotationVisitor, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(AnnotationVisitor av) {
|
||||
writeAnnotationData(av, serializer, functionProto);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0, av -> {
|
||||
writeAnnotationData(av, serializer, functionProto);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -284,22 +279,19 @@ public class ClosureCodegen extends MemberCodegen<KtElement> {
|
||||
public StackValue putInstanceOnStack(@NotNull ExpressionCodegen codegen, @Nullable StackValue functionReferenceReceiver) {
|
||||
return StackValue.operation(
|
||||
functionReferenceTarget != null ? K_FUNCTION : asmType,
|
||||
new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
if (isConst(closure)) {
|
||||
v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
|
||||
}
|
||||
else {
|
||||
v.anew(asmType);
|
||||
v.dup();
|
||||
|
||||
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator, functionReferenceReceiver);
|
||||
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
|
||||
}
|
||||
|
||||
return Unit.INSTANCE;
|
||||
v -> {
|
||||
if (isConst(closure)) {
|
||||
v.getstatic(asmType.getInternalName(), JvmAbi.INSTANCE_FIELD, asmType.getDescriptor());
|
||||
}
|
||||
else {
|
||||
v.anew(asmType);
|
||||
v.dup();
|
||||
|
||||
codegen.pushClosureOnStack(classDescriptor, true, codegen.defaultCallGenerator, functionReferenceReceiver);
|
||||
v.invokespecial(asmType.getInternalName(), "<init>", constructor.getDescriptor(), false);
|
||||
}
|
||||
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -17,15 +17,11 @@
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
public interface CompilationErrorHandler {
|
||||
|
||||
CompilationErrorHandler THROW_EXCEPTION = new CompilationErrorHandler() {
|
||||
@Override
|
||||
public void reportException(Throwable exception, String fileUrl) {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
throw new IllegalStateException(exception);
|
||||
CompilationErrorHandler THROW_EXCEPTION = (exception, fileUrl) -> {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException) exception;
|
||||
}
|
||||
throw new IllegalStateException(exception);
|
||||
};
|
||||
|
||||
void reportException(Throwable exception, String fileUrl);
|
||||
|
||||
@@ -22,19 +22,11 @@ import org.jetbrains.kotlin.psi.KtParameter;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
|
||||
public interface DefaultParameterValueLoader {
|
||||
|
||||
StackValue genValue(ValueParameterDescriptor descriptor, ExpressionCodegen codegen);
|
||||
|
||||
DefaultParameterValueLoader DEFAULT = new DefaultParameterValueLoader() {
|
||||
@Override
|
||||
public StackValue genValue(
|
||||
ValueParameterDescriptor descriptor,
|
||||
ExpressionCodegen codegen
|
||||
) {
|
||||
KtParameter jetParameter = (KtParameter) descriptorToDeclaration(descriptor);
|
||||
assert jetParameter != null;
|
||||
return codegen.gen(jetParameter.getDefaultValue());
|
||||
}
|
||||
DefaultParameterValueLoader DEFAULT = (descriptor, codegen) -> {
|
||||
KtParameter ktParameter = (KtParameter) descriptorToDeclaration(descriptor);
|
||||
assert ktParameter != null;
|
||||
return codegen.gen(ktParameter.getDefaultValue());
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -20,8 +20,8 @@ import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.Trinity;
|
||||
import gnu.trove.TObjectIntHashMap;
|
||||
import gnu.trove.TObjectIntIterator;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -115,15 +115,7 @@ public class FrameMap {
|
||||
descriptors.add(Trinity.create(descriptor, varIndex, varSize));
|
||||
}
|
||||
|
||||
Collections.sort(descriptors, new Comparator<Trinity<DeclarationDescriptor, Integer, Integer>>() {
|
||||
@Override
|
||||
public int compare(
|
||||
Trinity<DeclarationDescriptor, Integer, Integer> left,
|
||||
Trinity<DeclarationDescriptor, Integer, Integer> right
|
||||
) {
|
||||
return left.second - right.second;
|
||||
}
|
||||
});
|
||||
Collections.sort(descriptors, Comparator.comparingInt(left -> left.second));
|
||||
|
||||
sb.append("size=").append(myMaxIndex);
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ package org.jetbrains.kotlin.codegen;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.Unit;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -65,6 +62,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.kotlin.utils.StringsKt;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
@@ -79,7 +77,8 @@ import java.util.Set;
|
||||
|
||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.isNullableAny;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isAnnotationOrJvmInterfaceWithoutDefaults;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.isJvm8InterfaceWithDefaultsMember;
|
||||
import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.METHOD_FOR_FUNCTION;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
import static org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget.*;
|
||||
@@ -277,20 +276,17 @@ public class FunctionCodegen {
|
||||
v, "Default Impl delegate in interface", Opcodes.ACC_SYNTHETIC | Opcodes.ACC_STATIC | Opcodes.ACC_PUBLIC,
|
||||
new Method(defaultImplMethod.getName() + JvmAbi.DEFAULT_IMPLS_DELEGATE_SUFFIX, defaultImplMethod.getDescriptor()),
|
||||
element, JvmDeclarationOrigin.NO_ORIGIN,
|
||||
state, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter adapter) {
|
||||
Method interfaceMethod = typeMapper.mapAsmMethod(functionDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
Type type = typeMapper.mapOwner(functionDescriptor);
|
||||
generateDelegateToMethodBody(
|
||||
-1, adapter,
|
||||
interfaceMethod,
|
||||
type.getInternalName(),
|
||||
Opcodes.INVOKESPECIAL,
|
||||
true
|
||||
);
|
||||
return null;
|
||||
}
|
||||
state, adapter -> {
|
||||
Method interfaceMethod = typeMapper.mapAsmMethod(functionDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
Type type = typeMapper.mapOwner(functionDescriptor);
|
||||
generateDelegateToMethodBody(
|
||||
-1, adapter,
|
||||
interfaceMethod,
|
||||
type.getInternalName(),
|
||||
Opcodes.INVOKESPECIAL,
|
||||
true
|
||||
);
|
||||
return null;
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -642,14 +638,11 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
private static String joinParameterNames(@NotNull List<VariableDescriptor> variables) {
|
||||
return org.jetbrains.kotlin.utils.StringsKt.join(CollectionsKt.map(variables, new Function1<VariableDescriptor, String>() {
|
||||
@Override
|
||||
public String invoke(VariableDescriptor descriptor) {
|
||||
// stub for anonymous destructuring declaration entry
|
||||
if (descriptor.getName().isSpecial()) return "$_$";
|
||||
return descriptor.getName().asString();
|
||||
}
|
||||
}), "_");
|
||||
// stub for anonymous destructuring declaration entry
|
||||
return StringsKt.join(
|
||||
CollectionsKt.map(variables, descriptor -> descriptor.getName().isSpecial() ? "$_$" : descriptor.getName().asString()),
|
||||
"_"
|
||||
);
|
||||
}
|
||||
|
||||
private static void generateFacadeDelegateMethodBody(
|
||||
@@ -815,23 +808,16 @@ public class FunctionCodegen {
|
||||
}
|
||||
|
||||
public static boolean isThereOverriddenInKotlinClass(@NotNull CallableMemberDescriptor descriptor) {
|
||||
return CollectionsKt.any(getAllOverriddenDescriptors(descriptor), new Function1<CallableMemberDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(CallableMemberDescriptor descriptor) {
|
||||
return !(descriptor.getContainingDeclaration() instanceof JavaClassDescriptor) &&
|
||||
isClass(descriptor.getContainingDeclaration());
|
||||
}
|
||||
});
|
||||
return CollectionsKt.any(
|
||||
getAllOverriddenDescriptors(descriptor),
|
||||
overridden -> !(overridden.getContainingDeclaration() instanceof JavaClassDescriptor) &&
|
||||
isClass(overridden.getContainingDeclaration())
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Function1<FunctionDescriptor, Method> getSignatureMapper(@NotNull KotlinTypeMapper typeMapper) {
|
||||
return new Function1<FunctionDescriptor, Method>() {
|
||||
@Override
|
||||
public Method invoke(FunctionDescriptor descriptor) {
|
||||
return typeMapper.mapAsmMethod(descriptor);
|
||||
}
|
||||
};
|
||||
return typeMapper::mapAsmMethod;
|
||||
}
|
||||
|
||||
public static boolean isMethodOfAny(@NotNull FunctionDescriptor descriptor) {
|
||||
@@ -862,18 +848,15 @@ public class FunctionCodegen {
|
||||
if (!(value instanceof ArrayValue)) return ArrayUtil.EMPTY_STRING_ARRAY;
|
||||
ArrayValue arrayValue = (ArrayValue) value;
|
||||
|
||||
List<String> strings = ContainerUtil.mapNotNull(
|
||||
List<String> strings = CollectionsKt.mapNotNull(
|
||||
arrayValue.getValue(),
|
||||
new Function<ConstantValue<?>, String>() {
|
||||
@Override
|
||||
public String fun(ConstantValue<?> constant) {
|
||||
if (constant instanceof KClassValue) {
|
||||
KClassValue classValue = (KClassValue) constant;
|
||||
ClassDescriptor classDescriptor = DescriptorUtils.getClassDescriptorForType(classValue.getValue());
|
||||
return mapper.mapClass(classDescriptor).getInternalName();
|
||||
}
|
||||
return null;
|
||||
(ConstantValue<?> constant) -> {
|
||||
if (constant instanceof KClassValue) {
|
||||
KClassValue classValue = (KClassValue) constant;
|
||||
ClassDescriptor classDescriptor = DescriptorUtils.getClassDescriptorForType(classValue.getValue());
|
||||
return mapper.mapClass(classDescriptor).getInternalName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
);
|
||||
return ArrayUtil.toStringArray(strings);
|
||||
|
||||
@@ -21,8 +21,6 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.Unit;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.jvm.functions.Function2;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -395,12 +393,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
KotlinBuiltIns builtIns = DescriptorUtilsKt.getBuiltIns(descriptor);
|
||||
if (!isSubclass(descriptor, builtIns.getCollection())) return;
|
||||
|
||||
if (CollectionsKt.any(DescriptorUtilsKt.getAllSuperclassesWithoutAny(descriptor), new Function1<ClassDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(ClassDescriptor classDescriptor) {
|
||||
return !(classDescriptor instanceof JavaClassDescriptor) && isSubclass(classDescriptor, builtIns.getCollection());
|
||||
}
|
||||
})) return;
|
||||
if (CollectionsKt.any(DescriptorUtilsKt.getAllSuperclassesWithoutAny(descriptor),
|
||||
classDescriptor -> !(classDescriptor instanceof JavaClassDescriptor) &&
|
||||
isSubclass(classDescriptor, builtIns.getCollection()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
Collection<SimpleFunctionDescriptor> functions = descriptor.getDefaultType().getMemberScope().getContributedFunctions(
|
||||
Name.identifier("toArray"), NoLookupLocation.FROM_BACKEND
|
||||
@@ -735,15 +732,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
functionCodegen.generateDefaultIfNeeded(
|
||||
context.intoFunction(function), function, OwnerKind.IMPLEMENTATION,
|
||||
new DefaultParameterValueLoader() {
|
||||
@Override
|
||||
public StackValue genValue(ValueParameterDescriptor valueParameter, ExpressionCodegen codegen) {
|
||||
assert ((ClassDescriptor) function.getContainingDeclaration()).isData()
|
||||
: "Function container must have [data] modifier: " + function;
|
||||
PropertyDescriptor property = bindingContext.get(BindingContext.VALUE_PARAMETER_AS_PROPERTY, valueParameter);
|
||||
assert property != null : "Copy function doesn't correspond to any property: " + function;
|
||||
return codegen.intermediateValueForProperty(property, false, null, StackValue.LOCAL_0);
|
||||
}
|
||||
(valueParameter, codegen) -> {
|
||||
assert ((ClassDescriptor) function.getContainingDeclaration()).isData()
|
||||
: "Function container must have [data] modifier: " + function;
|
||||
PropertyDescriptor property = bindingContext.get(BindingContext.VALUE_PARAMETER_AS_PROPERTY, valueParameter);
|
||||
assert property != null : "Copy function doesn't correspond to any property: " + function;
|
||||
return codegen.intermediateValueForProperty(property, false, null, StackValue.LOCAL_0);
|
||||
},
|
||||
null
|
||||
);
|
||||
@@ -785,14 +779,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
private void generateEnumValueOfMethod() {
|
||||
FunctionDescriptor valueOfFunction =
|
||||
CollectionsKt.single(descriptor.getStaticScope().getContributedFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND), new Function1<FunctionDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(FunctionDescriptor descriptor) {
|
||||
return DescriptorUtilsKt.isEnumValueOfMethod(descriptor);
|
||||
}
|
||||
});
|
||||
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(myClass, valueOfFunction), ACC_PUBLIC | ACC_STATIC, ENUM_VALUE_OF.asString(),
|
||||
"(Ljava/lang/String;)" + classAsmType.getDescriptor(), null, null);
|
||||
CollectionsKt.single(descriptor.getStaticScope().getContributedFunctions(ENUM_VALUE_OF, NoLookupLocation.FROM_BACKEND),
|
||||
DescriptorUtilsKt::isEnumValueOfMethod);
|
||||
MethodVisitor mv =
|
||||
v.newMethod(JvmDeclarationOriginKt.OtherOrigin(myClass, valueOfFunction), ACC_PUBLIC | ACC_STATIC, ENUM_VALUE_OF.asString(),
|
||||
"(Ljava/lang/String;)" + classAsmType.getDescriptor(), null, null);
|
||||
if (!state.getClassBuilderMode().generateBodies) return;
|
||||
|
||||
mv.visitCode();
|
||||
@@ -991,13 +982,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
if (JvmAbi.isCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||
ImplementationBodyCodegen parentCodegen = (ImplementationBodyCodegen) getParentCodegen();
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
public ExpressionCodegen invoke() {
|
||||
return parentCodegen.createOrGetClInitCodegen();
|
||||
}
|
||||
});
|
||||
generateInitializers(((ImplementationBodyCodegen) getParentCodegen())::createOrGetClInitCodegen);
|
||||
}
|
||||
else {
|
||||
generateInitializers(codegen);
|
||||
@@ -1061,12 +1046,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
private void generateInitializers(@NotNull ExpressionCodegen codegen) {
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
public ExpressionCodegen invoke() {
|
||||
return codegen;
|
||||
}
|
||||
});
|
||||
generateInitializers(() -> codegen);
|
||||
}
|
||||
|
||||
private void generateClosureInitialization(@NotNull InstructionAdapter iv) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.codegen;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -176,14 +175,10 @@ public class JvmCodegenUtil {
|
||||
}
|
||||
|
||||
public static boolean hasAbstractMembers(@NotNull ClassDescriptor classDescriptor) {
|
||||
return CollectionsKt.any(DescriptorUtils.getAllDescriptors(classDescriptor.getDefaultType().getMemberScope()),
|
||||
new Function1<DeclarationDescriptor, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof CallableMemberDescriptor &&
|
||||
((CallableMemberDescriptor) descriptor).getModality() == ABSTRACT;
|
||||
}
|
||||
}
|
||||
return CollectionsKt.any(
|
||||
DescriptorUtils.getAllDescriptors(classDescriptor.getDefaultType().getMemberScope()),
|
||||
descriptor -> descriptor instanceof CallableMemberDescriptor &&
|
||||
((CallableMemberDescriptor) descriptor).getModality() == ABSTRACT
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -816,12 +816,9 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
|
||||
int flags = isScript ? JvmAnnotationNames.METADATA_SCRIPT_FLAG : 0;
|
||||
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.CLASS, flags, new Function1<AnnotationVisitor, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(AnnotationVisitor av) {
|
||||
writeAnnotationData(av, serializer, classProto);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.CLASS, flags, av -> {
|
||||
writeAnnotationData(av, serializer, classProto);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.annotation.AnnotatedSimple;
|
||||
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext;
|
||||
@@ -38,7 +36,6 @@ import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer;
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -100,12 +97,7 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
|
||||
}
|
||||
|
||||
if (state.getClassBuilderMode().generateBodies) {
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
public ExpressionCodegen invoke() {
|
||||
return createOrGetClInitCodegen();
|
||||
}
|
||||
});
|
||||
generateInitializers(this::createOrGetClInitCodegen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,12 +123,9 @@ public class PackagePartCodegen extends MemberCodegen<KtFile> {
|
||||
DescriptorSerializer.createTopLevel(new JvmSerializerExtension(v.getSerializationBindings(), state));
|
||||
ProtoBuf.Package packageProto = serializer.packagePartProto(element.getPackageFqName(), members).build();
|
||||
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.FILE_FACADE, 0, new Function1<AnnotationVisitor, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(AnnotationVisitor av) {
|
||||
writeAnnotationData(av, serializer, packageProto);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
WriteAnnotationUtilKt.writeKotlinMetadata(v, state, KotlinClassHeader.Kind.FILE_FACADE, 0, av -> {
|
||||
writeAnnotationData(av, serializer, packageProto);
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext;
|
||||
import org.jetbrains.kotlin.codegen.context.MethodContext;
|
||||
@@ -202,12 +201,7 @@ public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
|
||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, methodContext, state, this);
|
||||
|
||||
generateInitializers(new Function0<ExpressionCodegen>() {
|
||||
@Override
|
||||
public ExpressionCodegen invoke() {
|
||||
return codegen;
|
||||
}
|
||||
});
|
||||
generateInitializers(() -> codegen);
|
||||
|
||||
iv.areturn(Type.VOID_TYPE);
|
||||
}
|
||||
|
||||
@@ -65,12 +65,9 @@ public abstract class StackValue {
|
||||
private static final String NULLABLE_LONG_TYPE_NAME = "java/lang/Long";
|
||||
|
||||
public static final StackValue.Local LOCAL_0 = local(0, OBJECT_TYPE);
|
||||
private static final StackValue UNIT = operation(UNIT_TYPE, new Function1<InstructionAdapter, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(InstructionAdapter v) {
|
||||
v.visitFieldInsn(GETSTATIC, UNIT_TYPE.getInternalName(), JvmAbi.INSTANCE_FIELD, UNIT_TYPE.getDescriptor());
|
||||
return null;
|
||||
}
|
||||
private static final StackValue UNIT = operation(UNIT_TYPE, v -> {
|
||||
v.visitFieldInsn(GETSTATIC, UNIT_TYPE.getInternalName(), JvmAbi.INSTANCE_FIELD, UNIT_TYPE.getDescriptor());
|
||||
return null;
|
||||
});
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-7
@@ -22,7 +22,6 @@ import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.containers.Stack;
|
||||
import kotlin.Pair;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.ReflectionTypes;
|
||||
@@ -675,12 +674,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
expression,
|
||||
bindingContext,
|
||||
shouldInlineConstVals,
|
||||
new Function1<ConstantValue<?>, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(@NotNull ConstantValue<?> constant) {
|
||||
return constant instanceof EnumValue || constant instanceof NullValue;
|
||||
}
|
||||
}
|
||||
constant -> constant instanceof EnumValue || constant instanceof NullValue
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.context;
|
||||
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.ReadOnly;
|
||||
@@ -160,12 +159,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
this.closure = closure;
|
||||
this.thisDescriptor = thisDescriptor;
|
||||
this.enclosingLocalLookup = localLookup;
|
||||
this.outerExpression = LockBasedStorageManager.NO_LOCKS.createNullableLazyValue(new Function0<StackValue.Field>() {
|
||||
@Override
|
||||
public StackValue.Field invoke() {
|
||||
return computeOuterExpression();
|
||||
}
|
||||
});
|
||||
this.outerExpression = LockBasedStorageManager.NO_LOCKS.createNullableLazyValue(this::computeOuterExpression);
|
||||
|
||||
if (parentContext != null) {
|
||||
parentContext.addChild(this);
|
||||
|
||||
+4
-10
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.codegen.inline;
|
||||
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil;
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilder;
|
||||
@@ -350,15 +349,10 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
||||
original.access, original.name, original.desc, original.signature,
|
||||
ArrayUtil.toStringArray(original.exceptions)
|
||||
),
|
||||
new Function0<MethodVisitor>() {
|
||||
@Override
|
||||
public MethodVisitor invoke() {
|
||||
return builder.newMethod(
|
||||
NO_ORIGIN, original.access, original.name, original.desc, original.signature,
|
||||
ArrayUtil.toStringArray(original.exceptions)
|
||||
);
|
||||
}
|
||||
}
|
||||
() -> builder.newMethod(
|
||||
NO_ORIGIN, original.access, original.name, original.desc, original.signature,
|
||||
ArrayUtil.toStringArray(original.exceptions)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
||||
@@ -272,15 +271,12 @@ public class InlineCodegen extends CallGenerator {
|
||||
}
|
||||
|
||||
SMAPAndMethodNode resultInCache = InlineCacheKt.getOrPut(
|
||||
state.getInlineCache().getMethodNodeById(), methodId, new Function0<SMAPAndMethodNode>() {
|
||||
@Override
|
||||
public SMAPAndMethodNode invoke() {
|
||||
SMAPAndMethodNode result = doCreateMethodNodeFromCompiled(directMember, state, asmMethod);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Couldn't obtain compiled function body for " + functionDescriptor);
|
||||
}
|
||||
return result;
|
||||
state.getInlineCache().getMethodNodeById(), methodId, () -> {
|
||||
SMAPAndMethodNode result = doCreateMethodNodeFromCompiled(directMember, state, asmMethod);
|
||||
if (result == null) {
|
||||
throw new IllegalStateException("Couldn't obtain compiled function body for " + functionDescriptor);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -315,13 +311,8 @@ public class InlineCodegen extends CallGenerator {
|
||||
) {
|
||||
if (isBuiltInArrayIntrinsic(callableDescriptor)) {
|
||||
ClassId classId = IntrinsicArrayConstructorsKt.getClassId();
|
||||
byte[] bytes = InlineCacheKt.getOrPut(state.getInlineCache().getClassBytes(), classId, new Function0<byte[]>() {
|
||||
@Override
|
||||
public byte[] invoke() {
|
||||
return IntrinsicArrayConstructorsKt.getBytecode();
|
||||
}
|
||||
});
|
||||
|
||||
byte[] bytes =
|
||||
InlineCacheKt.getOrPut(state.getInlineCache().getClassBytes(), classId, IntrinsicArrayConstructorsKt::getBytecode);
|
||||
return InlineCodegenUtil.getMethodNode(bytes, asmMethod.getName(), asmMethod.getDescriptor(), classId);
|
||||
}
|
||||
|
||||
@@ -332,23 +323,19 @@ public class InlineCodegen extends CallGenerator {
|
||||
|
||||
ClassId containerId = containingClasses.getImplClassId();
|
||||
|
||||
byte[] bytes = InlineCacheKt.getOrPut(state.getInlineCache().getClassBytes(), containerId, new Function0<byte[]>() {
|
||||
@Override
|
||||
public byte[] invoke() {
|
||||
VirtualFile file = InlineCodegenUtil.findVirtualFile(state, containerId);
|
||||
if (file == null) {
|
||||
throw new IllegalStateException("Couldn't find declaration file for " + containerId);
|
||||
}
|
||||
try {
|
||||
return file.contentsToByteArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
byte[] bytes = InlineCacheKt.getOrPut(state.getInlineCache().getClassBytes(), containerId, () -> {
|
||||
VirtualFile file = InlineCodegenUtil.findVirtualFile(state, containerId);
|
||||
if (file == null) {
|
||||
throw new IllegalStateException("Couldn't find declaration file for " + containerId);
|
||||
}
|
||||
try {
|
||||
return file.contentsToByteArray();
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return InlineCodegenUtil.getMethodNode(bytes, asmMethod.getName(), asmMethod.getDescriptor(), containerId);
|
||||
}
|
||||
|
||||
@@ -455,14 +442,8 @@ public class InlineCodegen extends CallGenerator {
|
||||
|
||||
CallableMemberDescriptor descriptor = getLabelOwnerDescriptor(codegen.getContext());
|
||||
Set<String> labels = getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor);
|
||||
LabelOwner labelOwner = new LabelOwner() {
|
||||
@Override
|
||||
public boolean isMyLabel(@NotNull String name) {
|
||||
return labels.contains(name);
|
||||
}
|
||||
};
|
||||
|
||||
List<MethodInliner.PointForExternalFinallyBlocks> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
|
||||
List<MethodInliner.PointForExternalFinallyBlocks> infos = MethodInliner.processReturns(adapter, labels::contains, true, null);
|
||||
generateAndInsertFinallyBlocks(
|
||||
adapter, infos, ((StackValue.Local) remapper.remap(parameters.getArgsSizeOnStack() + 1).value).index
|
||||
);
|
||||
@@ -759,19 +740,16 @@ public class InlineCodegen extends CallGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (int i = infos.length - 1; i >= 0; i--) {
|
||||
ParameterInfo info = infos[i];
|
||||
if (!info.isSkippedOrRemapped()) {
|
||||
Type type = info.type;
|
||||
StackValue.Local local = StackValue.local(index[i], type);
|
||||
local.store(StackValue.onStack(type), codegen.v);
|
||||
if (info instanceof CapturedParamInfo) {
|
||||
info.setRemapValue(local);
|
||||
((CapturedParamInfo) info).setSynthetic(true);
|
||||
}
|
||||
Runnable runnable = () -> {
|
||||
for (int i = infos.length - 1; i >= 0; i--) {
|
||||
ParameterInfo info = infos[i];
|
||||
if (!info.isSkippedOrRemapped()) {
|
||||
Type type = info.type;
|
||||
StackValue.Local local = StackValue.local(index[i], type);
|
||||
local.store(StackValue.onStack(type), codegen.v);
|
||||
if (info instanceof CapturedParamInfo) {
|
||||
info.setRemapValue(local);
|
||||
((CapturedParamInfo) info).setSynthetic(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,17 +21,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
public interface LabelOwner {
|
||||
boolean isMyLabel(@NotNull String name);
|
||||
|
||||
LabelOwner SKIP_ALL = new LabelOwner() {
|
||||
@Override
|
||||
public boolean isMyLabel(@NotNull String name) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
LabelOwner SKIP_ALL = name -> false;
|
||||
|
||||
LabelOwner NOT_APPLICABLE = new LabelOwner() {
|
||||
@Override
|
||||
public boolean isMyLabel(@NotNull String name) {
|
||||
throw new RuntimeException("This operation not applicable for current context");
|
||||
}
|
||||
LabelOwner NOT_APPLICABLE = name -> {
|
||||
throw new RuntimeException("This operation not applicable for current context");
|
||||
};
|
||||
}
|
||||
|
||||
+1
-7
@@ -46,7 +46,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.inline;
|
||||
|
||||
import com.intellij.openapi.util.Factory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
@@ -430,12 +429,7 @@ public class MaxStackFrameSizeAndLocalsCalculator extends MaxLocalsCalculator {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
private LabelWrapper getLabelWrapper(Label label) {
|
||||
return ContainerUtil.getOrCreate(labelWrappersMap, label, new Factory<LabelWrapper>() {
|
||||
@Override
|
||||
public LabelWrapper create() {
|
||||
return new LabelWrapper(label);
|
||||
}
|
||||
});
|
||||
return ContainerUtil.<Label, LabelWrapper>getOrCreate(labelWrappersMap, label, () -> new LabelWrapper(label));
|
||||
}
|
||||
|
||||
private void increaseStackSize(int variation) {
|
||||
|
||||
+7
-16
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.codegen.optimization.boxing;
|
||||
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function1;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.StrictBasicValue;
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.UtilKt;
|
||||
@@ -100,12 +99,7 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
|
||||
|
||||
List<BasicValue> variableValues = getValuesStoredOrLoadedToVariable(localVariableNode, node, frames);
|
||||
|
||||
Collection<BasicValue> boxed = CollectionsKt.filter(variableValues, new Function1<BasicValue, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(BasicValue value) {
|
||||
return value instanceof BoxedBasicValue;
|
||||
}
|
||||
});
|
||||
Collection<BasicValue> boxed = CollectionsKt.filter(variableValues, value -> value instanceof BoxedBasicValue);
|
||||
|
||||
if (boxed.isEmpty()) continue;
|
||||
|
||||
@@ -127,16 +121,13 @@ public class RedundantBoxingMethodTransformer extends MethodTransformer {
|
||||
}
|
||||
|
||||
private static boolean isUnsafeToRemoveBoxingForConnectedValues(List<BasicValue> usedValues, Type unboxedType) {
|
||||
return CollectionsKt.any(usedValues, new Function1<BasicValue, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(BasicValue input) {
|
||||
if (input == StrictBasicValue.UNINITIALIZED_VALUE) return false;
|
||||
if (!(input instanceof BoxedBasicValue)) return true;
|
||||
return CollectionsKt.any(usedValues, input -> {
|
||||
if (input == StrictBasicValue.UNINITIALIZED_VALUE) return false;
|
||||
if (!(input instanceof BoxedBasicValue)) return true;
|
||||
|
||||
BoxedValueDescriptor descriptor = ((BoxedBasicValue) input).getDescriptor();
|
||||
return !descriptor.isSafeToRemove() ||
|
||||
!(descriptor.getUnboxedType().equals(unboxedType));
|
||||
}
|
||||
BoxedValueDescriptor descriptor = ((BoxedBasicValue) input).getDescriptor();
|
||||
return !descriptor.isSafeToRemove() ||
|
||||
!(descriptor.getUnboxedType().equals(unboxedType));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import kotlin.Pair;
|
||||
import kotlin.Unit;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import kotlin.jvm.functions.Function2;
|
||||
import kotlin.jvm.functions.Function3;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment;
|
||||
@@ -469,13 +468,11 @@ public class KotlinTypeMapper {
|
||||
) {
|
||||
return TypeSignatureMappingKt.mapType(
|
||||
kotlinType, AsmTypeFactory.INSTANCE, mode, typeMappingConfiguration, signatureVisitor,
|
||||
new Function3<KotlinType, Type, TypeMappingMode, Unit>() {
|
||||
@Override
|
||||
public Unit invoke(KotlinType kotlinType, Type type, TypeMappingMode mode) {
|
||||
writeGenericType(kotlinType, type, signatureVisitor, mode);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
});
|
||||
(ktType, asmType, typeMappingMode) -> {
|
||||
writeGenericType(ktType, asmType, signatureVisitor, typeMappingMode);
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,10 +23,7 @@ import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface Progress {
|
||||
Progress DEAF = new Progress() {
|
||||
@Override
|
||||
public void reportOutput(@NotNull Collection<File> sourceFiles, @Nullable File outputFile) {
|
||||
}
|
||||
Progress DEAF = (sourceFiles, outputFile) -> {
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,14 +158,8 @@ public class SwitchCodegenUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkAllItemsAreConstantsSatisfying(expression, bindingContext, shouldInlineConstVals, new Function1<ConstantValue<?>, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(
|
||||
@NotNull ConstantValue<?> constant
|
||||
) {
|
||||
return constant instanceof IntegerValueConstant;
|
||||
}
|
||||
});
|
||||
return checkAllItemsAreConstantsSatisfying(expression, bindingContext, shouldInlineConstVals,
|
||||
constant -> constant instanceof IntegerValueConstant);
|
||||
}
|
||||
|
||||
private static boolean isStringConstantsSwitch(
|
||||
@@ -179,13 +173,7 @@ public class SwitchCodegenUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
return checkAllItemsAreConstantsSatisfying(expression, bindingContext, shouldInlineConstVals, new Function1<ConstantValue<?>, Boolean>() {
|
||||
@Override
|
||||
public Boolean invoke(
|
||||
@NotNull ConstantValue<?> constant
|
||||
) {
|
||||
return constant instanceof StringValue || constant instanceof NullValue;
|
||||
}
|
||||
});
|
||||
return checkAllItemsAreConstantsSatisfying(expression, bindingContext, shouldInlineConstVals,
|
||||
constant -> constant instanceof StringValue || constant instanceof NullValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user