Use kotlin version 1.3.72
Change-Id: Ib06238a5685f36905e0bcdcdcb30ffcfcb6766ef
diff --git a/build.gradle b/build.gradle
index 5de1a41..90ad4ab 100644
--- a/build.gradle
+++ b/build.gradle
@@ -43,7 +43,7 @@
gsonVersion = '2.7'
junitVersion = '4.13-beta-2'
mockitoVersion = '2.10.0'
- kotlinVersion = '1.3.41'
+ kotlinVersion = '1.3.72'
kotlinExtMetadataJVMVersion = '0.1.0'
smaliVersion = '2.2b4'
errorproneVersion = '2.3.2'
diff --git a/buildSrc/src/main/java/kotlin/Kotlinc.java b/buildSrc/src/main/java/kotlin/Kotlinc.java
index 9c29870..efb39aa 100644
--- a/buildSrc/src/main/java/kotlin/Kotlinc.java
+++ b/buildSrc/src/main/java/kotlin/Kotlinc.java
@@ -30,7 +30,7 @@
private static final Path kotlincExecPath =
Paths.get(
- "third_party", "kotlin", "kotlin-compiler-1.3.11", "kotlinc", "bin", kotlincExecName);
+ "third_party", "kotlin", "kotlin-compiler-1.3.72", "kotlinc", "bin", kotlincExecName);
enum KotlinTargetVersion {
JAVA_6("1.6"),
diff --git a/src/test/java/com/android/tools/r8/KotlinCompilerTool.java b/src/test/java/com/android/tools/r8/KotlinCompilerTool.java
index 0094983..ca9abd4 100644
--- a/src/test/java/com/android/tools/r8/KotlinCompilerTool.java
+++ b/src/test/java/com/android/tools/r8/KotlinCompilerTool.java
@@ -46,7 +46,7 @@
Paths.get(
ToolHelper.THIRD_PARTY_DIR,
"kotlin",
- "kotlin-compiler-1.3.11",
+ "kotlin-compiler-1.3.72",
"kotlinc",
"lib",
"kotlin-compiler.jar"));
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 74c0649..f19c7ce 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -135,16 +135,16 @@
"third_party/rhino-android-1.1.1/rhino-android-1.1.1.jar";
public static final String RHINO_JAR = "third_party/rhino-1.7.10/rhino-1.7.10.jar";
static final String KT_PRELOADER =
- "third_party/kotlin/kotlin-compiler-1.3.11/kotlinc/lib/kotlin-preloader.jar";
+ "third_party/kotlin/kotlin-compiler-1.3.72/kotlinc/lib/kotlin-preloader.jar";
public static final String KT_COMPILER =
- "third_party/kotlin/kotlin-compiler-1.3.11/kotlinc/lib/kotlin-compiler.jar";
+ "third_party/kotlin/kotlin-compiler-1.3.72/kotlinc/lib/kotlin-compiler.jar";
public static final String K2JVMCompiler = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler";
public static final String KT_STDLIB =
- "third_party/kotlin/kotlin-compiler-1.3.11/kotlinc/lib/kotlin-stdlib.jar";
+ "third_party/kotlin/kotlin-compiler-1.3.72/kotlinc/lib/kotlin-stdlib.jar";
public static final String KT_REFLECT =
- "third_party/kotlin/kotlin-compiler-1.3.11/kotlinc/lib/kotlin-reflect.jar";
+ "third_party/kotlin/kotlin-compiler-1.3.72/kotlinc/lib/kotlin-reflect.jar";
public static final String KT_SCRIPT_RT =
- "third_party/kotlin/kotlin-compiler-1.3.11/kotlinc/lib/kotlin-script-runtime.jar";
+ "third_party/kotlin/kotlin-compiler-1.3.72/kotlinc/lib/kotlin-script-runtime.jar";
private static final String ANDROID_JAR_PATTERN = "third_party/android_jar/lib-v%d/android.jar";
private static final AndroidApiLevel DEFAULT_MIN_SDK = AndroidApiLevel.I;
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java b/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java
index 8d209b0..894e7d5 100644
--- a/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java
+++ b/src/test/java/com/android/tools/r8/debug/KotlinInlineTest.java
@@ -147,7 +147,7 @@
private static String mangleLambdaNameFromInlineScope(String functionName, int lambdaId) {
assert lambdaId > 0;
- return "$i$a$" + lambdaId + "$" + functionName;
+ return "$i$a$" + functionName + "$" + lambdaId;
}
private static String mangleLvNameFromInlineScope(String lvName, int inlineDepth) {
@@ -167,59 +167,74 @@
DEBUGGEE_CLASS,
breakpoint(DEBUGGEE_CLASS, inliningMethodName),
run(),
- inspect(s -> {
- assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(16, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(inliningMethodName, s.getMethodName());
+ assertEquals(16, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- // We must have stepped into the code of the inlined method but the actual current method
- // did not change.
- assertEquals(inliningMethodName, s.getMethodName());
- // TODO(shertz) get the original line if JSR45 is supported by the targeted ART runtime.
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ // We must have stepped into the code of the inlined method but the actual current
+ // method
+ // did not change.
+ assertEquals(inliningMethodName, s.getMethodName());
+ // TODO(shertz) get the original line if JSR45 is supported by the targeted ART
+ // runtime.
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(17, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(inliningMethodName, s.getMethodName());
+ assertEquals(17, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(18, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("inA", Value.createInt(1));
- // This is a "hidden" lv added by Kotlin (which is neither initialized nor used).
- s.checkLocal(mangleFunctionNameFromInlineScope("inlinedA"));
- s.checkLocal(mangleLambdaNameFromInlineScope("inlinedA", 1));
- }),
+ inspect(
+ s -> {
+ assertEquals(inliningMethodName, s.getMethodName());
+ assertEquals(18, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("inA", Value.createInt(1));
+ // This is a "hidden" lv added by Kotlin (which is neither initialized nor used).
+ s.checkLocal(mangleFunctionNameFromInlineScope("inlinedA"));
+ s.checkLocal(
+ mangleLambdaNameFromInlineScope(
+ "-inlinedA-KotlinInline$invokeInlinedFunctions", 1));
+ }),
stepInto(),
- inspect(s -> {
- // We must have stepped into the code of the second inlined method but the actual current
- // method did not change.
- assertEquals(inliningMethodName, s.getMethodName());
- // TODO(shertz) get the original line if JSR45 is supported by the targeted ART runtime.
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ // We must have stepped into the code of the second inlined method but the actual
+ // current
+ // method did not change.
+ assertEquals(inliningMethodName, s.getMethodName());
+ // TODO(shertz) get the original line if JSR45 is supported by the targeted ART
+ // runtime.
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(19, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(inliningMethodName, s.getMethodName());
+ assertEquals(19, s.getLineNumber());
+ s.checkLocal("this");
+ }),
stepInto(),
- inspect(s -> {
- assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(20, s.getLineNumber());
- s.checkLocal("this");
- s.checkLocal("inB", Value.createInt(2));
- // This is a "hidden" lv added by Kotlin (which is neither initialized nor used).
- s.checkLocal(mangleFunctionNameFromInlineScope("inlinedB"));
- s.checkLocal(mangleLambdaNameFromInlineScope("inlinedB", 1));
- }),
+ inspect(
+ s -> {
+ assertEquals(inliningMethodName, s.getMethodName());
+ assertEquals(20, s.getLineNumber());
+ s.checkLocal("this");
+ s.checkLocal("inB", Value.createInt(2));
+ // This is a "hidden" lv added by Kotlin (which is neither initialized nor used).
+ s.checkLocal(mangleFunctionNameFromInlineScope("inlinedB"));
+ s.checkLocal(
+ mangleLambdaNameFromInlineScope(
+ "-inlinedB-KotlinInline$invokeInlinedFunctions$1", 1));
+ }),
run());
}
@@ -239,7 +254,7 @@
// Local variables that represent the scope (start,end) of lambda's code that has been inlined.
final String inlinee2_lambda1_inlineScope = mangleLambdaNameFromInlineScope("inlinee2", 1);
- final String inlinee2_lambda2_inlineScope = mangleLambdaNameFromInlineScope("inlinee2", 2);
+ final String inlinee2_lambda2_inlineScope = "$i$a$-inlinee2-KotlinInline$inlinee1$1$iv";
final String c_mangledLvName = mangleLvNameFromInlineScope("c", 1);
final String left_mangledLvName = mangleLvNameFromInlineScope("left", 1);
final String right_mangledLvName = mangleLvNameFromInlineScope("right", 1);
@@ -250,11 +265,12 @@
DEBUGGEE_CLASS,
breakpoint(DEBUGGEE_CLASS, inliningMethodName),
run(),
- inspect(s -> {
- assertEquals(inliningMethodName, s.getMethodName());
- assertEquals(52, s.getLineNumber());
- s.checkLocal("this");
- }),
+ inspect(
+ s -> {
+ assertEquals(inliningMethodName, s.getMethodName());
+ assertEquals(52, s.getLineNumber());
+ s.checkLocal("this");
+ }),
checkLocal("this"),
checkNoLocals("l1", "l2"),
stepOver(),
@@ -268,10 +284,11 @@
// We jumped into 1st inlinee but the current method is the same
checkMethod(DEBUGGEE_CLASS, inliningMethodName),
checkLocal(inlinee1_inlineScope),
- inspect(state -> {
- assertEquals(SOURCE_FILE, state.getSourceFile());
- assertTrue(state.getLineNumber() > maxLineNumber);
- }),
+ inspect(
+ state -> {
+ assertEquals(SOURCE_FILE, state.getSourceFile());
+ assertTrue(state.getLineNumber() > maxLineNumber);
+ }),
checkNoLocal(c_mangledLvName),
stepInto(),
checkLocal(c_mangledLvName),
@@ -279,10 +296,11 @@
// We jumped into 2nd inlinee which is nested in the 1st inlinee
checkLocal(inlinee2_inlineScope),
checkLocal(inlinee1_inlineScope),
- inspect(state -> {
- assertEquals(SOURCE_FILE, state.getSourceFile());
- assertTrue(state.getLineNumber() > maxLineNumber);
- }),
+ inspect(
+ state -> {
+ assertEquals(SOURCE_FILE, state.getSourceFile());
+ assertTrue(state.getLineNumber() > maxLineNumber);
+ }),
// We must see the local variable "p" with a 2-level inline depth.
checkLocal(p_mangledLvName),
checkNoLocals(left_mangledLvName, right_mangledLvName),
@@ -293,10 +311,10 @@
// Enter the inlined lambda
stepInto(),
checkLocal(p_mangledLvName),
- checkLocal(inlinee2_lambda1_inlineScope),
+ checkLocal(inlinee2_lambda2_inlineScope),
checkNoLocals(left_mangledLvName, right_mangledLvName),
stepInto(),
- checkLocal(inlinee2_lambda1_inlineScope),
+ checkLocal(inlinee2_lambda2_inlineScope),
checkLocal(left_mangledLvName),
checkNoLocal(right_mangledLvName),
stepInto(),
@@ -307,14 +325,14 @@
checkLine(SOURCE_FILE, 34),
stepOut(),
// We're back to the inline section, at the end of the lambda
- inspect(state -> {
- assertEquals(SOURCE_FILE, state.getSourceFile());
- assertTrue(state.getLineNumber() > maxLineNumber);
- }),
+ inspect(
+ state -> {
+ assertEquals(SOURCE_FILE, state.getSourceFile());
+ assertTrue(state.getLineNumber() > maxLineNumber);
+ }),
checkLocal(inlinee1_inlineScope),
checkLocal(inlinee2_inlineScope),
- checkLocal(inlinee2_lambda1_inlineScope),
- checkNoLocal(inlinee2_lambda2_inlineScope),
+ checkLocal(inlinee2_lambda2_inlineScope),
stepInto(),
// We're in inlinee2, after the call to the inlined lambda.
checkLocal(inlinee1_inlineScope),
@@ -349,7 +367,7 @@
checkLocal(inlinee1_inlineScope),
checkLocal(inlinee2_inlineScope),
checkNoLocal(inlinee2_lambda1_inlineScope),
- checkLocal(inlinee2_lambda2_inlineScope),
+ checkNoLocal(inlinee2_lambda2_inlineScope),
// Enter the call to "foo"
stepInto(),
checkMethod(DEBUGGEE_CLASS, "foo"),
diff --git a/src/test/java/com/android/tools/r8/kotlin/ProcessKotlinStdlibTest.java b/src/test/java/com/android/tools/r8/kotlin/ProcessKotlinStdlibTest.java
index e3107bb..195b536 100644
--- a/src/test/java/com/android/tools/r8/kotlin/ProcessKotlinStdlibTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/ProcessKotlinStdlibTest.java
@@ -47,9 +47,7 @@
.addKeepAttributes(ProguardKeepAttributes.INNER_CLASSES)
.addKeepAttributes(ProguardKeepAttributes.ENCLOSING_METHOD)
.apply(consumer)
- .allowDiagnosticInfoMessages(expectInvalidDebugInfo)
- .compile()
- .assertAllInfoMessagesMatch(expectedInfoMessagesFromKotlinStdLib());
+ .compile();
}
@Test
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInTypeArgumentsTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInTypeArgumentsTest.java
index 2e3dd21..bed423f 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInTypeArgumentsTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInTypeArgumentsTest.java
@@ -16,6 +16,7 @@
import com.android.tools.r8.TestParameters;
import com.android.tools.r8.ToolHelper;
import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
+import com.android.tools.r8.ToolHelper.ProcessResult;
import com.android.tools.r8.shaking.ProguardKeepAttributes;
import com.android.tools.r8.utils.StringUtils;
import com.android.tools.r8.utils.codeinspector.ClassSubject;
@@ -148,21 +149,19 @@
.inspect(this::inspect)
.writeToZip();
- Path mainJar =
+ // TODO(b/152306391): Reified type-parameters are not flagged correctly.
+ ProcessResult mainResult =
kotlinc(parameters.getRuntime().asCf(), KOTLINC, targetVersion)
.addClasspathFiles(libJar)
.addSourceFiles(getKotlinFileInTest(PKG_PREFIX + "/typeargument_app", "main"))
- .compile();
-
- // TODO(b/152306391): Reified type-parameters are not flagged correctly.
- testForJvm()
- .addRunClasspathFiles(ToolHelper.getKotlinStdlibJar(), libJar)
- .addClasspath(mainJar)
- .run(parameters.getRuntime(), PKG + ".typeargument_app.MainKt")
- .assertFailureWithErrorThatMatches(
- containsString(
- "This function has a reified type parameter and thus can only be inlined at"
- + " compilation time, not called directly"));
+ .setOutputPath(temp.newFolder().toPath())
+ .compileRaw();
+ assertEquals(1, mainResult.exitCode);
+ assertThat(
+ mainResult.stderr,
+ containsString(
+ "org.jetbrains.kotlin.codegen.CompilationException: "
+ + "Back-end (JVM) Internal error: wrong bytecode generated"));
}
private void inspect(CodeInspector inspector) {
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewritePassThroughTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewritePassThroughTest.java
index e0ac745..4826e1a 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewritePassThroughTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewritePassThroughTest.java
@@ -51,10 +51,7 @@
.setMinApi(parameters.getApiLevel())
.addKeepAllClassesRule()
.addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
- .allowDiagnosticInfoMessages()
.compile()
- .assertAllInfoMessagesMatch(expectedInfoMessagesFromKotlinStdLib())
- .assertInfosCount(3)
.inspect(this::inspect);
}
@@ -74,7 +71,8 @@
KotlinClassHeader rewrittenHeader = rewrittenMetadata.getHeader();
assertEquals(originalHeader.getKind(), rewrittenHeader.getKind());
// TODO(b/154199572): Should we check for meta-data version?
- assertEquals(originalHeader.getPackageName(), rewrittenHeader.getPackageName());
+ // TODO(b/156290606): Check if we should assert the package names are equal.
+ // assertEquals(originalHeader.getPackageName(), rewrittenHeader.getPackageName());
// We cannot assert equality of the data since it may be ordered differently. Instead we use
// the KotlinMetadataWriter.
String expected = KotlinMetadataWriter.kotlinMetadataToString("", originalMetadata);
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataStripTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataStripTest.java
index 94edd94..aa0fcf8 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataStripTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataStripTest.java
@@ -53,13 +53,11 @@
.addKeepRules("-keep class kotlin.Metadata")
// TODO(b/151194540): if this option is settled down, this test is meaningless.
.addOptionsModification(o -> o.enableKotlinMetadataRewritingForRenamedClasses = false)
- .allowDiagnosticMessages()
+ .allowDiagnosticWarningMessages()
.setMinApi(parameters.getApiLevel())
.compile()
.assertAllWarningMessagesMatch(
equalTo("Resource 'META-INF/MANIFEST.MF' already exists."))
- .assertAllInfoMessagesMatch(expectedInfoMessagesFromKotlinStdLib())
- .assertNoErrorMessages()
.run(parameters.getRuntime(), mainClassName);
CodeInspector inspector = result.inspector();
ClassSubject clazz = inspector.clazz(mainClassName);
diff --git a/src/test/java/com/android/tools/r8/naming/EnumMinificationKotlinTest.java b/src/test/java/com/android/tools/r8/naming/EnumMinificationKotlinTest.java
index 7e15524..dce8ca3 100644
--- a/src/test/java/com/android/tools/r8/naming/EnumMinificationKotlinTest.java
+++ b/src/test/java/com/android/tools/r8/naming/EnumMinificationKotlinTest.java
@@ -69,5 +69,4 @@
assertEquals(0,
Streams.stream(clinit.iterateInstructions(InstructionSubject::isThrow)).count());
}
-
}