Remove unused parameters, compiler keys and obsolete code

This commit is contained in:
Mikhael Bogdanov
2018-02-21 18:07:53 +01:00
parent fe45eb2a81
commit 63afd37cdd
10 changed files with 18 additions and 43 deletions
@@ -215,10 +215,6 @@ public class FunctionCodegen {
generateBridges(functionDescriptor);
}
if (CodegenUtilKt.hasJvmDefaultAnnotation(functionDescriptor) && contextKind != OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()) {
generateDelegateForDefaultImpl(functionDescriptor, origin.getElement());
}
boolean staticInCompanionObject = CodegenUtilKt.isJvmStaticInCompanionObject(functionDescriptor);
if (staticInCompanionObject) {
ImplementationBodyCodegen parentBodyCodegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
@@ -592,18 +588,6 @@ public class FunctionCodegen {
generateFacadeDelegateMethodBody(mv, signature.getAsmMethod(), (MultifileClassFacadeContext) context.getParentContext());
methodEnd = new Label();
}
else if (OwnerKind.DEFAULT_IMPLS == context.getContextKind() && CodegenUtilKt.hasJvmDefaultAnnotation(functionDescriptor)) {
int flags = AsmUtil.getMethodAsmFlags(functionDescriptor, OwnerKind.DEFAULT_IMPLS, context.getState());
assert (flags & Opcodes.ACC_ABSTRACT) == 0 : "Interface method with body should be non-abstract" + functionDescriptor;
Type type = typeMapper.mapOwner(functionDescriptor);
Method asmMethod = typeMapper.mapAsmMethod(functionDescriptor, OwnerKind.DEFAULT_IMPLS);
generateDelegateToStaticMethodBody(
true, mv,
new Method(asmMethod.getName() + JvmAbi.DEFAULT_IMPLS_DELEGATE_SUFFIX, asmMethod.getDescriptor()),
type.getInternalName()
);
methodEnd = new Label();
}
else {
FrameMap frameMap = createFrameMap(
parentCodegen.state, signature, functionDescriptor.getExtensionReceiverParameter(),
@@ -350,9 +350,7 @@ public class PropertyCodegen {
if (annotations.getAllAnnotations().isEmpty()) return;
DeclarationDescriptor contextDescriptor = context.getContextDescriptor();
if (!isInterface(contextDescriptor) ||
(FunctionCodegen.processInterfaceMethod(descriptor, kind, true) || //TODO delete
(kind == OwnerKind.DEFAULT_IMPLS && state.getGenerateDefaultImplsForJvm8()))) {
if (!isInterface(contextDescriptor) || FunctionCodegen.processInterfaceMethod(descriptor, kind, true)) {
memberCodegen.generateSyntheticAnnotationsMethod(
descriptor, getSyntheticMethodSignature(descriptor), annotations, AnnotationUseSiteTarget.PROPERTY
);
@@ -26,8 +26,9 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.KotlinToJvmSignatureMapper
class KotlinToJvmSignatureMapperImpl : KotlinToJvmSignatureMapper {
// We use empty BindingContext, because it is only used by KotlinTypeMapper for purposes irrelevant to the needs of this class
private val typeMapper = KotlinTypeMapper(BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
private val typeMapper = KotlinTypeMapper(
BindingContext.EMPTY, ClassBuilderMode.LIGHT_CLASSES,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
override fun mapToJvmMethodSignature(function: FunctionDescriptor) = typeMapper.mapAsmMethod(function)
}
@@ -62,7 +62,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
// Avoid errors when some classes are not loaded for some reason
private val typeMapper = KotlinTypeMapper(
bindingContext, ClassBuilderMode.LIGHT_CLASSES, IncompatibleClassTracker.DoNothing, moduleName, false, false
bindingContext, ClassBuilderMode.LIGHT_CLASSES, IncompatibleClassTracker.DoNothing, moduleName, false
)
private val reportDiagnosticsTasks = ArrayList<() -> Unit>()
@@ -177,8 +177,6 @@ class GenerationState private constructor(
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
val isJvm8Target: Boolean = target == JvmTarget.JVM_1_8
val isJvm8TargetWithDefaults: Boolean = isJvm8Target && configuration.getBoolean(JVMConfigurationKeys.JVM8_TARGET_WITH_DEFAULTS)
val generateDefaultImplsForJvm8: Boolean = configuration.getBoolean(JVMConfigurationKeys.INTERFACE_COMPATIBILITY)
val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module)
val classBuilderMode: ClassBuilderMode = builderFactory.classBuilderMode
@@ -189,7 +187,7 @@ class GenerationState private constructor(
val bindingContext: BindingContext = bindingTrace.bindingContext
val typeMapper: KotlinTypeMapper = KotlinTypeMapper(
this.bindingContext, classBuilderMode, IncompatibleClassTrackerImpl(extraJvmDiagnosticsTrace),
this.moduleName, isJvm8Target, isJvm8TargetWithDefaults
this.moduleName, isJvm8Target
)
val intrinsics: IntrinsicMethods = run {
val shouldUseConsistentEquals = languageVersionSettings.supportsFeature(LanguageFeature.ThrowNpeOnExplicitEqualsForBoxedNull) &&
@@ -142,8 +142,7 @@ public class KotlinTypeMapper {
@NotNull ClassBuilderMode classBuilderMode,
@NotNull IncompatibleClassTracker incompatibleClassTracker,
@NotNull String moduleName,
boolean isJvm8Target,
boolean isJvm8TargetWithDefaults
boolean isJvm8Target
) {
this.bindingContext = bindingContext;
this.classBuilderMode = classBuilderMode;
@@ -97,12 +97,6 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> PARAMETERS_METADATA =
CompilerConfigurationKey.create("Parameters metadata for java 1.8 reflection");
public static final CompilerConfigurationKey<Boolean> INTERFACE_COMPATIBILITY =
CompilerConfigurationKey.create("Generate additional 'DefaultImpls' class files for jvm 8 target for compatibility with 6 target interfaces");
public static final CompilerConfigurationKey<Boolean> JVM8_TARGET_WITH_DEFAULTS =
CompilerConfigurationKey.create("Generate default methods in interfaces");
public static final CompilerConfigurationKey<IncrementalCompilationComponents> INCREMENTAL_COMPILATION_COMPONENTS =
CompilerConfigurationKey.create("incremental cache provider");
@@ -180,12 +180,11 @@ class ParcelableDeclarationChecker : DeclarationChecker {
}
val typeMapper = KotlinTypeMapper(
bindingContext,
ClassBuilderMode.full(false),
IncompatibleClassTracker.DoNothing,
descriptor.module.name.asString(),
/* isJvm8Target */ false,
/* isJvm8TargetWithDefaults */ false)
bindingContext,
ClassBuilderMode.full(false),
IncompatibleClassTracker.DoNothing,
descriptor.module.name.asString(),
/* isJvm8Target */ false)
for (parameter in primaryConstructor?.valueParameters.orEmpty()) {
checkParcelableClassProperty(parameter, descriptor, diagnosticHolder, typeMapper)
@@ -29,7 +29,8 @@ class IdeaKotlinUastBindingContextProviderService : KotlinUastBindingContextProv
override fun getBindingContext(element: KtElement) = element.analyze(BodyResolveMode.PARTIAL)
override fun getTypeMapper(element: KtElement): KotlinTypeMapper? {
return KotlinTypeMapper(getBindingContext(element), ClassBuilderMode.LIGHT_CLASSES,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
return KotlinTypeMapper(
getBindingContext(element), ClassBuilderMode.LIGHT_CLASSES,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
}
}
@@ -39,8 +39,9 @@ class UastAnalysisHandlerExtension : AnalysisHandlerExtension {
if (typeMapper != null) return typeMapper
val bindingContext = context ?: return null
val typeMapper = KotlinTypeMapper(bindingContext, ClassBuilderMode.LIGHT_CLASSES,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false, false)
val typeMapper = KotlinTypeMapper(
bindingContext, ClassBuilderMode.LIGHT_CLASSES,
IncompatibleClassTracker.DoNothing, JvmAbi.DEFAULT_MODULE_NAME, false)
this.typeMapper = typeMapper
return typeMapper
}