blob: 2225e141614e06544ec6888978d5acf0f37539f9 [file] [log] [blame]
// Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.shaking;
import com.android.tools.r8.graph.DexProgramClass;
import com.android.tools.r8.graph.ProgramDefinition;
import com.android.tools.r8.shaking.KeepInfo.Builder;
/** Immutable keep requirements for a member. */
public abstract class KeepMemberInfo<B extends Builder<B, K>, K extends KeepInfo<B, K>>
extends KeepInfo<B, K> {
KeepMemberInfo(B builder) {
super(builder);
}
@Override
public boolean isRepackagingAllowed(
ProgramDefinition definition, GlobalKeepInfoConfiguration configuration) {
return configuration.isRepackagingEnabled()
&& (definition.getAccessFlags().isPublic()
|| !internalIsAccessModificationRequiredForRepackaging());
}
public boolean isKotlinMetadataRemovalAllowed(
DexProgramClass holder, GlobalKeepInfoConfiguration configuration) {
// Checking the holder for missing kotlin information relies on the holder being processed
// before members.
return holder.getKotlinInfo().isNoKotlinInformation() || !isPinned(configuration);
}
}