mirror of
https://github.com/Guardsquare/proguard.git
synced 2026-03-13 09:50:34 +08:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21d73170e5 |
@@ -131,16 +131,19 @@ implements KotlinMetadataVisitor,
|
||||
kotlinPropertyMetadata.flags.hasAnnotations = false;
|
||||
}
|
||||
|
||||
if (kotlinPropertyMetadata.referencedGetterMethod != null)
|
||||
if (kotlinPropertyMetadata.getterMetadata != null &&
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod != null)
|
||||
{
|
||||
kotlinPropertyMetadata.referencedGetterMethod.accept(clazz, annotationCounter.reset());
|
||||
kotlinPropertyMetadata.getterFlags.hasAnnotations = annotationCounter.getCount() > 0;
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod.accept(clazz, annotationCounter.reset());
|
||||
kotlinPropertyMetadata.getterMetadata.hasAnnotations = annotationCounter.getCount() > 0;
|
||||
}
|
||||
|
||||
if (kotlinPropertyMetadata.flags.isVar && kotlinPropertyMetadata.referencedSetterMethod != null)
|
||||
if (kotlinPropertyMetadata.flags.isVar &&
|
||||
kotlinPropertyMetadata.setterMetadata != null &&
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod != null)
|
||||
{
|
||||
kotlinPropertyMetadata.referencedSetterMethod.accept(clazz, annotationCounter.reset());
|
||||
kotlinPropertyMetadata.setterFlags.hasAnnotations = annotationCounter.getCount() > 0;
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod.accept(clazz, annotationCounter.reset());
|
||||
kotlinPropertyMetadata.setterMetadata.hasAnnotations = annotationCounter.getCount() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,9 +281,10 @@ implements KotlinMetadataVisitor,
|
||||
kotlinPropertyMetadata,
|
||||
this);
|
||||
|
||||
if (kotlinValueParameterMetadata.flags.hasAnnotations)
|
||||
if (kotlinValueParameterMetadata.flags.hasAnnotations &&
|
||||
kotlinPropertyMetadata.setterMetadata != null)
|
||||
{
|
||||
kotlinPropertyMetadata.referencedSetterMethod.accept(clazz, annotationCounter.reset());
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod.accept(clazz, annotationCounter.reset());
|
||||
kotlinValueParameterMetadata.flags.hasAnnotations =
|
||||
annotationCounter.getParameterAnnotationCount(kotlinValueParameterMetadata.index) > 0;
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ public class Marker implements Pass
|
||||
KotlinDeclarationContainerMetadata kotlinDeclarationContainerMetadata,
|
||||
KotlinPropertyMetadata kotlinPropertyMetadata) {
|
||||
List<Processable> processables = Stream.of(kotlinPropertyMetadata.referencedBackingField,
|
||||
kotlinPropertyMetadata.referencedGetterMethod,
|
||||
kotlinPropertyMetadata.referencedSetterMethod)
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod,
|
||||
kotlinPropertyMetadata.setterMetadata != null ? kotlinPropertyMetadata.setterMetadata.referencedMethod : null)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
int flags = 0;
|
||||
|
||||
@@ -64,11 +64,13 @@ implements KotlinMetadataVisitor,
|
||||
if ((kotlinPropertyMetadata.referencedBackingField != null &&
|
||||
(kotlinPropertyMetadata.referencedBackingField.getProcessingFlags() & ProcessingFlags.DONT_OBFUSCATE) != 0) ||
|
||||
|
||||
(kotlinPropertyMetadata.referencedGetterMethod != null &&
|
||||
(kotlinPropertyMetadata.referencedGetterMethod.getProcessingFlags() & ProcessingFlags.DONT_OBFUSCATE) != 0) ||
|
||||
(kotlinPropertyMetadata.getterMetadata != null &&
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod != null &&
|
||||
(kotlinPropertyMetadata.getterMetadata.referencedMethod.getProcessingFlags() & ProcessingFlags.DONT_OBFUSCATE) != 0) ||
|
||||
|
||||
(kotlinPropertyMetadata.referencedSetterMethod != null &&
|
||||
(kotlinPropertyMetadata.referencedSetterMethod.getProcessingFlags() & ProcessingFlags.DONT_OBFUSCATE) != 0))
|
||||
(kotlinPropertyMetadata.setterMetadata != null &&
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod != null &&
|
||||
(kotlinPropertyMetadata.setterMetadata.referencedMethod.getProcessingFlags() & ProcessingFlags.DONT_OBFUSCATE) != 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -114,14 +114,14 @@ implements KotlinMetadataVisitor,
|
||||
KotlinPropertyMetadata kotlinPropertyMetadata)
|
||||
{
|
||||
keepParameterInfo = false;
|
||||
if (kotlinPropertyMetadata.referencedSetterMethod != null)
|
||||
if (kotlinPropertyMetadata.setterMetadata != null && kotlinPropertyMetadata.setterMetadata.referencedMethod != null)
|
||||
{
|
||||
kotlinPropertyMetadata.referencedSetterMethod.accept(clazz, this);
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod.accept(clazz, this);
|
||||
}
|
||||
|
||||
if (keepParameterInfo)
|
||||
{
|
||||
kotlinPropertyMetadata.setterParametersAccept(clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.setterParameterAccept(clazz, kotlinDeclarationContainerMetadata, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +108,8 @@ public class KotlinContextReceiverUsageMarker implements
|
||||
public void visitAnyProperty(Clazz clazz, KotlinDeclarationContainerMetadata kotlinDeclarationContainerMetadata, KotlinPropertyMetadata kotlinPropertyMetadata)
|
||||
{
|
||||
markContextReceiverParameters(kotlinPropertyMetadata.contextReceivers,
|
||||
kotlinPropertyMetadata.referencedGetterMethod,
|
||||
kotlinPropertyMetadata.referencedSetterMethod);
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod,
|
||||
kotlinPropertyMetadata.setterMetadata != null ? kotlinPropertyMetadata.setterMetadata.referencedMethod : null);
|
||||
}
|
||||
|
||||
private void markContextReceiverParameters(List<KotlinTypeMetadata> contextReceivers, Method...methods)
|
||||
|
||||
@@ -1869,11 +1869,13 @@ implements ClassVisitor,
|
||||
kotlinPropertyMetadata.referencedBackingField != null &&
|
||||
isUsed(kotlinPropertyMetadata.referencedBackingField);
|
||||
boolean getterUsed =
|
||||
kotlinPropertyMetadata.referencedGetterMethod != null &&
|
||||
isUsed(kotlinPropertyMetadata.referencedGetterMethod);
|
||||
kotlinPropertyMetadata.getterMetadata != null &&
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod != null &&
|
||||
isUsed(kotlinPropertyMetadata.getterMetadata.referencedMethod);
|
||||
boolean setterUsed =
|
||||
kotlinPropertyMetadata.referencedSetterMethod != null &&
|
||||
isUsed(kotlinPropertyMetadata.referencedSetterMethod);
|
||||
kotlinPropertyMetadata.setterMetadata != null &&
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod != null &&
|
||||
isUsed(kotlinPropertyMetadata.setterMetadata.referencedMethod);
|
||||
|
||||
if (backingFieldUsed || getterUsed || setterUsed)
|
||||
{
|
||||
@@ -1914,7 +1916,7 @@ implements ClassVisitor,
|
||||
kotlinPropertyMetadata.receiverTypeAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.contextReceiverTypesAccept(clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.typeParametersAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.setterParametersAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.setterParameterAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.typeAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.versionRequirementAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import proguard.classfile.kotlin.KotlinClassKindMetadata;
|
||||
import proguard.classfile.kotlin.KotlinConstants;
|
||||
import proguard.classfile.kotlin.KotlinConstructorMetadata;
|
||||
import proguard.classfile.kotlin.KotlinDeclarationContainerMetadata;
|
||||
import proguard.classfile.kotlin.KotlinEnumEntryMetadata;
|
||||
import proguard.classfile.kotlin.KotlinFileFacadeKindMetadata;
|
||||
import proguard.classfile.kotlin.KotlinFunctionMetadata;
|
||||
import proguard.classfile.kotlin.KotlinMetadata;
|
||||
@@ -38,6 +39,7 @@ import proguard.classfile.kotlin.KotlinTypeMetadata;
|
||||
import proguard.classfile.kotlin.KotlinTypeParameterMetadata;
|
||||
import proguard.classfile.kotlin.KotlinValueParameterMetadata;
|
||||
import proguard.classfile.kotlin.KotlinVersionRequirementMetadata;
|
||||
import proguard.classfile.kotlin.flags.KotlinPropertyAccessorMetadata;
|
||||
import proguard.classfile.kotlin.visitor.AllTypeVisitor;
|
||||
import proguard.classfile.kotlin.visitor.KotlinConstructorVisitor;
|
||||
import proguard.classfile.kotlin.visitor.KotlinFunctionVisitor;
|
||||
@@ -110,8 +112,7 @@ implements KotlinMetadataVisitor,
|
||||
|
||||
shrinkMetadataArray(kotlinClassKindMetadata.constructors);
|
||||
|
||||
shrinkArray(kotlinClassKindMetadata.enumEntryNames,
|
||||
kotlinClassKindMetadata.referencedEnumEntries);
|
||||
shrinkEnumEntries(kotlinClassKindMetadata.enumEntries);
|
||||
|
||||
shrinkArray(kotlinClassKindMetadata.nestedClassNames,
|
||||
kotlinClassKindMetadata.referencedNestedClasses);
|
||||
@@ -167,7 +168,7 @@ implements KotlinMetadataVisitor,
|
||||
{
|
||||
kotlinPropertyMetadata.versionRequirementAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.typeAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.setterParametersAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.setterParameterAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.receiverTypeAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.contextReceiverTypesAccept(clazz, kotlinDeclarationContainerMetadata, this);
|
||||
kotlinPropertyMetadata.typeParametersAccept( clazz, kotlinDeclarationContainerMetadata, this);
|
||||
@@ -179,21 +180,18 @@ implements KotlinMetadataVisitor,
|
||||
kotlinPropertyMetadata.referencedBackingField = null;
|
||||
}
|
||||
|
||||
if (shouldShrinkMetadata(kotlinPropertyMetadata.getterSignature,
|
||||
kotlinPropertyMetadata.referencedGetterMethod))
|
||||
if (shouldShrinkMetadata(kotlinPropertyMetadata.getterMetadata))
|
||||
{
|
||||
kotlinPropertyMetadata.getterSignature = null;
|
||||
kotlinPropertyMetadata.referencedGetterMethod = null;
|
||||
kotlinPropertyMetadata.getterMetadata.signature = null;
|
||||
kotlinPropertyMetadata.getterMetadata.referencedMethod = null;
|
||||
}
|
||||
|
||||
if (shouldShrinkMetadata(kotlinPropertyMetadata.setterSignature,
|
||||
kotlinPropertyMetadata.referencedSetterMethod))
|
||||
if (shouldShrinkMetadata(kotlinPropertyMetadata.setterMetadata))
|
||||
{
|
||||
kotlinPropertyMetadata.setterSignature = null;
|
||||
kotlinPropertyMetadata.referencedSetterMethod = null;
|
||||
kotlinPropertyMetadata.flags.isVar = false;
|
||||
kotlinPropertyMetadata.setterParameter = null;
|
||||
kotlinPropertyMetadata.setterParameters.clear();
|
||||
kotlinPropertyMetadata.setterMetadata.signature = null;
|
||||
kotlinPropertyMetadata.setterMetadata.referencedMethod = null;
|
||||
kotlinPropertyMetadata.flags.isVar = false;
|
||||
kotlinPropertyMetadata.setterParameter = null;
|
||||
}
|
||||
|
||||
kotlinPropertyMetadata.versionRequirementAccept(clazz,
|
||||
@@ -206,7 +204,7 @@ implements KotlinMetadataVisitor,
|
||||
kotlinPropertyMetadata.syntheticMethodForAnnotations = null;
|
||||
kotlinPropertyMetadata.referencedSyntheticMethodForAnnotations = null;
|
||||
kotlinPropertyMetadata.referencedSyntheticMethodClass = null;
|
||||
kotlinPropertyMetadata.flags.hasAnnotations = false;
|
||||
kotlinPropertyMetadata.annotations.clear();
|
||||
}
|
||||
|
||||
if (kotlinPropertyMetadata.syntheticMethodForDelegate != null &&
|
||||
@@ -220,8 +218,10 @@ implements KotlinMetadataVisitor,
|
||||
// Fix inconsistencies that were introduced as
|
||||
// a result of shrinking
|
||||
if (kotlinPropertyMetadata.referencedBackingField != null &&
|
||||
kotlinPropertyMetadata.getterSignature == null &&
|
||||
kotlinPropertyMetadata.setterSignature == null &&
|
||||
(kotlinPropertyMetadata.setterMetadata == null ||
|
||||
kotlinPropertyMetadata.setterMetadata.signature == null) &&
|
||||
(kotlinPropertyMetadata.getterMetadata == null ||
|
||||
kotlinPropertyMetadata.getterMetadata.signature == null) &&
|
||||
(kotlinPropertyMetadata.referencedBackingField.getAccessFlags() & AccessConstants.PRIVATE) != 0 &&
|
||||
!kotlinPropertyMetadata.flags.visibility.isPrivate)
|
||||
{
|
||||
@@ -398,6 +398,10 @@ implements KotlinMetadataVisitor,
|
||||
return metadataElement != null &&
|
||||
!usageMarker.isUsed(jvmElement);
|
||||
}
|
||||
private boolean shouldShrinkMetadata(KotlinPropertyAccessorMetadata kotlinPropertyAccessorMetadata) {
|
||||
return kotlinPropertyAccessorMetadata != null && !usageMarker.isUsed(kotlinPropertyAccessorMetadata.referencedMethod);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@@ -412,10 +416,13 @@ implements KotlinMetadataVisitor,
|
||||
shrinkArray(usageMarker, elements, referencedJavaElements);
|
||||
}
|
||||
|
||||
private void shrinkEnumEntries(List<KotlinEnumEntryMetadata> enumEntries) {
|
||||
enumEntries.removeIf(usageMarker::isUsed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shrinks elements and their corresponding referenced element, based on
|
||||
* markings on the referenced element.
|
||||
*
|
||||
* List is modified - must be a modifiable list!
|
||||
*/
|
||||
static void shrinkArray(SimpleUsageMarker usageMarker,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
proguardVersion = 7.8.2
|
||||
proguardVersion = 7.9.0
|
||||
|
||||
# The version of ProGuardCORE that sub-projects are built with
|
||||
proguardCoreVersion = 9.2.0
|
||||
proguardCoreVersion = 9.3.0
|
||||
gsonVersion = 2.11.0
|
||||
kotlinVersion = 2.2.0
|
||||
target = 1.8
|
||||
|
||||
Reference in New Issue
Block a user