Skip to content

Commit

Permalink
Update for Kotlin 1.6 support (upgrade to ProGuardCORE 8.0.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjameshamilton committed Jan 6, 2022
1 parent cbaa07d commit 97b3de4
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jar {
}

dependencies {
implementation 'com.guardsquare:proguard-core:8.0.4'
implementation 'com.guardsquare:proguard-core:8.0.5'

// dex2jar dependencies.
implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import proguard.classfile.kotlin.visitor.KotlinAnnotationArgumentVisitor;
import proguard.classfile.kotlin.visitor.KotlinAnnotationVisitor;

import java.util.Collections;

import static proguard.classfile.kotlin.KotlinAnnotationArgument.*;

/**
Expand Down Expand Up @@ -115,6 +117,38 @@ public void visitAnyLiteralArgument(Clazz cla
}


@Override
public void visitUByteArgument(Clazz clazz, KotlinAnnotatable annotatable, KotlinAnnotation annotation, KotlinAnnotationArgument argument, UByteValue value)
{
visitAnyArgument(clazz, annotatable, annotation, argument, value);
printer.print(String.valueOf(Byte.toUnsignedInt(value.value)));
}


@Override
public void visitUShortArgument(Clazz clazz, KotlinAnnotatable annotatable, KotlinAnnotation annotation, KotlinAnnotationArgument argument, UShortValue value)
{
visitAnyArgument(clazz, annotatable, annotation, argument, value);
printer.print(String.valueOf(Short.toUnsignedInt(value.value)));
}


@Override
public void visitUIntArgument(Clazz clazz, KotlinAnnotatable annotatable, KotlinAnnotation annotation, KotlinAnnotationArgument argument, UIntValue value)
{
visitAnyArgument(clazz, annotatable, annotation, argument, value);
printer.print(Integer.toUnsignedString(value.value));
}


@Override
public void visitULongArgument(Clazz clazz, KotlinAnnotatable annotatable, KotlinAnnotation annotation, KotlinAnnotationArgument argument, ULongValue value)
{
visitAnyArgument(clazz, annotatable, annotation, argument, value);
printer.print(Long.toUnsignedString(value.value));
}


@Override
public void visitArrayArgument(Clazz clazz,
KotlinAnnotatable annotatable,
Expand Down Expand Up @@ -149,7 +183,13 @@ public void visitClassArgument(Clazz clazz,
KotlinAnnotationArgument.ClassValue value)
{
visitAnyArgument(clazz, annotatable, annotation, argument, value);
printer.print(printer.getContext().className(value.className, "."));
String className = printer.getContext().className(value.className, ".");
printer.print(
String.join("", Collections.nCopies(value.arrayDimensionsCount, "Array<")) +
className +
String.join("", Collections.nCopies(value.arrayDimensionsCount, ">")) +
"::class"
);
}


Expand Down
11 changes: 10 additions & 1 deletion src/main/java/proguard/kotlin/printer/KotlinSourcePrinter.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ else if (classCounter.getCount() > 0)
MyKotlinSourceMetadataPrinter.this));
}

if (kotlinClassKindMetadata.flags.isValue)
{
println("// Underlying property name: " + kotlinClassKindMetadata.underlyingPropertyName, true);
pushStringBuilder();
kotlinClassKindMetadata.inlineClassUnderlyingPropertyTypeAccept(clazz, MyKotlinSourceMetadataPrinter.this);
String underlyingPropertyType = popStringBuilder();
println("// Underlying property type: " + underlyingPropertyType, true);
}

visitKotlinDeclarationContainerMetadata(clazz, kotlinClassKindMetadata);

// Companion is also a nested class but print it here first, so it's not mixed in with the nested classes.
Expand Down Expand Up @@ -1119,7 +1128,7 @@ private String classFlags(KotlinClassFlags flags)
(flags.isAnnotationClass ? "annotation class " : "") +
(flags.isInner ? "inner " : "") + // Also isUsualClass = true.
(flags.isData ? "data " : "") + // Also isUsualClass = true.
(flags.isInline ? "inline " : "") + // Also isUsualClass = true.
(flags.isValue ? "value " : (flags.isInline ? "inline " : "")) + // Also isUsualClass = true.
(flags.isUsualClass ? "class " : "") +
(flags.isFun ? "fun " : "") +
(flags.isInterface ? "interface " : "") +
Expand Down

0 comments on commit 97b3de4

Please sign in to comment.