Remove deprecated Flags accesses
Bug: b/341991457
Change-Id: Ifc9371ac6184ae01f98df8de7a7d343646261982
diff --git a/src/main/java/com/android/tools/r8/kotlin/KotlinDeclarationContainerInfo.java b/src/main/java/com/android/tools/r8/kotlin/KotlinDeclarationContainerInfo.java
index 21f5469..d1d9441 100644
--- a/src/main/java/com/android/tools/r8/kotlin/KotlinDeclarationContainerInfo.java
+++ b/src/main/java/com/android/tools/r8/kotlin/KotlinDeclarationContainerInfo.java
@@ -26,11 +26,12 @@
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
+import kotlin.metadata.Attributes;
import kotlin.metadata.KmDeclarationContainer;
import kotlin.metadata.KmFunction;
import kotlin.metadata.KmProperty;
+import kotlin.metadata.KmPropertyAccessorAttributes;
import kotlin.metadata.KmTypeAlias;
-import kotlin.metadata.internal.metadata.deserialization.Flags;
import kotlin.metadata.jvm.JvmExtensionsKt;
import kotlin.metadata.jvm.JvmMethodSignature;
@@ -85,7 +86,7 @@
}
continue;
}
- keepIfInline(kmFunction.getFlags(), method, signature, methodSignatureMap, keepByteCode);
+ keepIfInline(kmFunction, method, signature, methodSignatureMap, keepByteCode);
method.setKotlinMemberInfo(kotlinFunctionInfo);
originalAssignmentTracker.add(method.getReference());
}
@@ -110,7 +111,7 @@
methodSignatureMap.get(propertyProcessor.getterSignature().toString());
if (method != null) {
hasBacking = true;
- keepIfAccessorInline(kmProperty.getGetterFlags(), method, keepByteCode);
+ keepIfAccessorInline(kmProperty.getGetter(), method, keepByteCode);
method.setKotlinMemberInfo(
new KotlinPropertyInfoDelegate(kotlinPropertyInfo, PropertyType.GETTER));
originalAssignmentTracker.add(method.getReference());
@@ -121,7 +122,7 @@
methodSignatureMap.get(propertyProcessor.setterSignature().toString());
if (method != null) {
hasBacking = true;
- keepIfAccessorInline(kmProperty.getGetterFlags(), method, keepByteCode);
+ keepIfAccessorInline(kmProperty.getGetter(), method, keepByteCode);
method.setKotlinMemberInfo(
new KotlinPropertyInfoDelegate(kotlinPropertyInfo, PropertyType.SETTER));
originalAssignmentTracker.add(method.getReference());
@@ -150,12 +151,12 @@
}
private static void keepIfInline(
- int flags,
+ KmFunction kmFunction,
DexEncodedMethod method,
JvmMethodSignature signature,
Map<String, DexEncodedMethod> methodSignatureMap,
Consumer<DexEncodedMethod> keepByteCode) {
- if (Flags.IS_INLINE.get(flags)) {
+ if (Attributes.isInline(kmFunction)) {
// Check if we can find a default method. If there are more than 32 arguments another int
// index will be added to the default method.
for (int i = 1;
@@ -173,8 +174,10 @@
}
private static void keepIfAccessorInline(
- int flags, DexEncodedMethod method, Consumer<DexEncodedMethod> keepByteCode) {
- if (Flags.IS_INLINE_ACCESSOR.get(flags)) {
+ KmPropertyAccessorAttributes kmPropertyAccessorAttributes,
+ DexEncodedMethod method,
+ Consumer<DexEncodedMethod> keepByteCode) {
+ if (Attributes.isInline(kmPropertyAccessorAttributes)) {
keepByteCode.accept(method);
}
}
diff --git a/src/main/java/com/android/tools/r8/kotlin/KotlinValueParameterInfo.java b/src/main/java/com/android/tools/r8/kotlin/KotlinValueParameterInfo.java
index dca2632..a96b249 100644
--- a/src/main/java/com/android/tools/r8/kotlin/KotlinValueParameterInfo.java
+++ b/src/main/java/com/android/tools/r8/kotlin/KotlinValueParameterInfo.java
@@ -15,32 +15,29 @@
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.function.Consumer;
+import kotlin.metadata.Attributes;
import kotlin.metadata.KmType;
import kotlin.metadata.KmValueParameter;
-import kotlin.metadata.internal.metadata.deserialization.Flags;
// Provides access to Kotlin information about value parameter.
class KotlinValueParameterInfo implements EnqueuerMetadataTraceable {
private static final List<KotlinValueParameterInfo> EMPTY_VALUE_PARAMETERS = ImmutableList.of();
- // Original parameter name.
- final String name;
- // Original parameter flags, e.g., has default value.
- final int flags;
+ // Original parameter.
+ final KmValueParameter kmValueParameter;
// Original information about the type.
final KotlinTypeInfo type;
// Indicates whether the formal parameter is originally `vararg`.
final KotlinTypeInfo varargElementType;
private KotlinValueParameterInfo(
- int flags, String name, KotlinTypeInfo type, KotlinTypeInfo varargElementType) {
- this.name = name;
- this.flags = flags;
+ KmValueParameter kmValueParameter, KotlinTypeInfo type, KotlinTypeInfo varargElementType) {
+ this.kmValueParameter = kmValueParameter;
this.type = type;
this.varargElementType = varargElementType;
}
boolean isCrossInline() {
- return Flags.IS_CROSSINLINE.get(flags);
+ return Attributes.isCrossinline(kmValueParameter);
}
static KotlinValueParameterInfo create(
@@ -50,8 +47,7 @@
}
KmType kmType = kmValueParameter.getType();
return new KotlinValueParameterInfo(
- kmValueParameter.getFlags(),
- kmValueParameter.getName(),
+ kmValueParameter,
KotlinTypeInfo.create(kmType, factory, reporter),
KotlinTypeInfo.create(kmValueParameter.getVarargElementType(), factory, reporter));
}
@@ -69,13 +65,16 @@
}
boolean rewrite(Consumer<KmValueParameter> consumer, AppView<?> appView) {
- KmValueParameter kmValueParameter = consume(new KmValueParameter(flags, name), consumer);
- boolean rewritten = type.rewrite(kmValueParameter::setType, appView);
+ KmValueParameter rewrittenKmValueParameter =
+ consume(
+ new KmValueParameter(kmValueParameter.getFlags(), kmValueParameter.getName()),
+ consumer);
+ boolean rewritten = type.rewrite(rewrittenKmValueParameter::setType, appView);
rewritten |=
rewriteIfNotNull(
appView,
varargElementType,
- kmValueParameter::setVarargElementType,
+ rewrittenKmValueParameter::setVarargElementType,
KotlinTypeInfo::rewrite);
return rewritten;
}