Add more tests about metadata rewriting:
return type, parameter type, and property.
Bug: 70169921
Change-Id: Ic6850e3d97a2a0ebb22a2d2215f770114e845320
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInExtensionTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInExtensionTest.java
index 3ba5ecd..1569404 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInExtensionTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInExtensionTest.java
@@ -18,6 +18,7 @@
import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
import com.android.tools.r8.ToolHelper.ProcessResult;
import com.android.tools.r8.graph.DexAnnotation;
+import com.android.tools.r8.shaking.ProguardKeepAttributes;
import com.android.tools.r8.utils.codeinspector.ClassSubject;
import java.nio.file.Path;
import java.util.Collection;
@@ -70,7 +71,7 @@
// Keep the BKt extension method which requires metadata
// to be called with Kotlin syntax from other kotlin code.
.addKeepRules("-keep class **.BKt { <methods>; }")
- .addKeepAttributes("*Annotation*")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.compile();
String pkg = getClass().getPackage().getName();
final String superClassName = pkg + ".extension_lib.Super";
@@ -117,7 +118,7 @@
// Keep the BKt extension method which requires metadata
// to be called with Kotlin syntax from other kotlin code.
.addKeepRules("-keep class **.BKt { <methods>; }")
- .addKeepAttributes("*Annotation*")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.compile();
String pkg = getClass().getPackage().getName();
final String superClassName = pkg + ".extension_lib.Super";
@@ -136,19 +137,19 @@
assertThat(metadata.toString(), not(containsString("Super")));
});
- Path r8ProcessedLibZip = temp.newFile("r8-lib.zip").toPath();
- compileResult.writeToZip(r8ProcessedLibZip);
+ Path libJar = temp.newFile("lib.jar").toPath();
+ compileResult.writeToZip(libJar);
String appFolder = PKG_PREFIX + "/extension_app";
Path output =
kotlinc(parameters.getRuntime().asCf())
- .addClasspathFiles(r8ProcessedLibZip)
+ .addClasspathFiles(libJar)
.addSourceFiles(getKotlinFileInTest(appFolder, "main"))
.setOutputPath(temp.newFolder().toPath())
.compile();
testForJvm()
- .addRunClasspathFiles(ToolHelper.getKotlinStdlibJar(), r8ProcessedLibZip)
+ .addRunClasspathFiles(ToolHelper.getKotlinStdlibJar(), libJar)
.addClasspath(output)
.run(parameters.getRuntime(), pkg + ".extension_app.MainKt")
.assertSuccessWithOutputLines("do stuff", "do stuff");
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInParametertypeTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInParametertypeTest.java
new file mode 100644
index 0000000..0155279
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInParametertypeTest.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2019, 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.kotlin.metadata;
+
+import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
+import static com.android.tools.r8.utils.codeinspector.Matchers.isRenamed;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.android.tools.r8.R8TestCompileResult;
+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.graph.DexAnnotation;
+import com.android.tools.r8.shaking.ProguardKeepAttributes;
+import com.android.tools.r8.utils.codeinspector.ClassSubject;
+import java.nio.file.Path;
+import java.util.Collection;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class MetadataRenameInParametertypeTest extends KotlinMetadataTestBase {
+
+ private final TestParameters parameters;
+
+ @Parameterized.Parameters(name = "{0} target: {1}")
+ public static Collection<Object[]> data() {
+ return buildParameters(
+ getTestParameters().withCfRuntimes().build(), KotlinTargetVersion.values());
+ }
+
+ public MetadataRenameInParametertypeTest(
+ TestParameters parameters, KotlinTargetVersion targetVersion) {
+ super(targetVersion);
+ this.parameters = parameters;
+ }
+
+ private static Path parameterLibJar;
+
+ @BeforeClass
+ public static void createLibJar() throws Exception {
+ String paramLibFolder = PKG_PREFIX + "/parametertype_lib";
+ parameterLibJar = getStaticTemp().newFile("param_lib.jar").toPath();
+ ProcessResult processResult =
+ ToolHelper.runKotlinc(
+ null,
+ parameterLibJar,
+ null,
+ getKotlinFileInTest(paramLibFolder, "lib")
+ );
+ assertEquals(0, processResult.exitCode);
+ }
+
+ @Test
+ public void testMetadataInParameter_renamed() throws Exception {
+ R8TestCompileResult compileResult =
+ testForR8(parameters.getBackend())
+ .addProgramFiles(parameterLibJar)
+ // Keep non-private members of Impl
+ .addKeepRules("-keep public class **.Impl { !private *; }")
+ // Keep Itf, but allow minification.
+ .addKeepRules("-keep,allowobfuscation class **.Itf")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
+ .compile();
+ String pkg = getClass().getPackage().getName();
+ final String itfClassName = pkg + ".parametertype_lib.Itf";
+ final String implClassName = pkg + ".parametertype_lib.Impl";
+ compileResult.inspect(inspector -> {
+ ClassSubject itf = inspector.clazz(itfClassName);
+ assertThat(itf, isPresent());
+ assertThat(itf, isRenamed());
+
+ ClassSubject impl = inspector.clazz(implClassName);
+ assertThat(impl, isPresent());
+ assertThat(impl, not(isRenamed()));
+ // API entry is kept, hence the presence of Metadata.
+ DexAnnotation metadata = retrieveMetadata(impl.getDexClass());
+ assertNotNull(metadata);
+ // TODO(b/70169921): should not refer to Itf
+ assertThat(metadata.toString(), containsString("Itf"));
+ });
+
+ Path libJar = temp.newFile("lib.jar").toPath();
+ compileResult.writeToZip(libJar);
+
+ String appFolder = PKG_PREFIX + "/parametertype_app";
+ ProcessResult processResult =
+ kotlinc(parameters.getRuntime().asCf())
+ .addClasspathFiles(libJar)
+ .addSourceFiles(getKotlinFileInTest(appFolder, "main"))
+ .setOutputPath(temp.newFolder().toPath())
+ // TODO(b/70169921): update to just .compile() once fixed.
+ .compileRaw();
+ // TODO(b/70169921): should be able to compile!
+ assertNotEquals(0, processResult.exitCode);
+ assertThat(
+ processResult.stderr,
+ containsString("cannot access class '" + pkg + ".parametertype_lib.Itf'"));
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInPropertyTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInPropertyTest.java
new file mode 100644
index 0000000..9883e66
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInPropertyTest.java
@@ -0,0 +1,106 @@
+// Copyright (c) 2019, 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.kotlin.metadata;
+
+import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
+import static com.android.tools.r8.utils.codeinspector.Matchers.isRenamed;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.android.tools.r8.R8TestCompileResult;
+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.graph.DexAnnotation;
+import com.android.tools.r8.shaking.ProguardKeepAttributes;
+import com.android.tools.r8.utils.codeinspector.ClassSubject;
+import java.nio.file.Path;
+import java.util.Collection;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class MetadataRenameInPropertyTest extends KotlinMetadataTestBase {
+
+ private final TestParameters parameters;
+
+ @Parameterized.Parameters(name = "{0} target: {1}")
+ public static Collection<Object[]> data() {
+ return buildParameters(
+ getTestParameters().withCfRuntimes().build(), KotlinTargetVersion.values());
+ }
+
+ public MetadataRenameInPropertyTest(
+ TestParameters parameters, KotlinTargetVersion targetVersion) {
+ super(targetVersion);
+ this.parameters = parameters;
+ }
+
+ private static Path propertyLibJar;
+
+ @BeforeClass
+ public static void createLibJar() throws Exception {
+ String propertyLibFolder = PKG_PREFIX + "/propertytype_lib";
+ propertyLibJar = getStaticTemp().newFile("property_lib.jar").toPath();
+ ProcessResult processResult =
+ ToolHelper.runKotlinc(
+ null,
+ propertyLibJar,
+ null,
+ getKotlinFileInTest(propertyLibFolder, "lib")
+ );
+ assertEquals(0, processResult.exitCode);
+ }
+
+ @Test
+ public void testMetadataInProperty_renamed() throws Exception {
+ R8TestCompileResult compileResult =
+ testForR8(parameters.getBackend())
+ .addProgramFiles(propertyLibJar)
+ // Keep non-private members of Impl
+ .addKeepRules("-keep public class **.Impl { !private *; }")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
+ .compile();
+ String pkg = getClass().getPackage().getName();
+ final String itfClassName = pkg + ".propertytype_lib.Itf";
+ final String implClassName = pkg + ".propertytype_lib.Impl";
+ compileResult.inspect(inspector -> {
+ ClassSubject itf = inspector.clazz(itfClassName);
+ assertThat(itf, isPresent());
+ assertThat(itf, isRenamed());
+
+ ClassSubject impl = inspector.clazz(implClassName);
+ assertThat(impl, isPresent());
+ assertThat(impl, not(isRenamed()));
+ // API entry is kept, hence the presence of Metadata.
+ DexAnnotation metadata = retrieveMetadata(impl.getDexClass());
+ assertNotNull(metadata);
+ // TODO(b/70169921): should not refer to Itf
+ assertThat(metadata.toString(), containsString("Itf"));
+ });
+
+ Path libJar = temp.newFile("lib.jar").toPath();
+ compileResult.writeToZip(libJar);
+
+ String appFolder = PKG_PREFIX + "/propertytype_app";
+ ProcessResult processResult =
+ kotlinc(parameters.getRuntime().asCf())
+ .addClasspathFiles(libJar)
+ .addSourceFiles(getKotlinFileInTest(appFolder, "main"))
+ .setOutputPath(temp.newFolder().toPath())
+ .compileRaw();
+ // TODO(b/70169921): should be able to compile!
+ assertNotEquals(0, processResult.exitCode);
+ assertThat(
+ processResult.stderr,
+ containsString("cannot access class '" + pkg + ".propertytype_lib.Itf'"));
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInReturntypeTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInReturntypeTest.java
new file mode 100644
index 0000000..cc493c6
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInReturntypeTest.java
@@ -0,0 +1,109 @@
+// Copyright (c) 2019, 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.kotlin.metadata;
+
+import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
+import static com.android.tools.r8.utils.codeinspector.Matchers.isRenamed;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.android.tools.r8.R8TestCompileResult;
+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.graph.DexAnnotation;
+import com.android.tools.r8.shaking.ProguardKeepAttributes;
+import com.android.tools.r8.utils.codeinspector.ClassSubject;
+import java.nio.file.Path;
+import java.util.Collection;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+@RunWith(Parameterized.class)
+public class MetadataRenameInReturntypeTest extends KotlinMetadataTestBase {
+ private final TestParameters parameters;
+
+ @Parameterized.Parameters(name = "{0} target: {1}")
+ public static Collection<Object[]> data() {
+ return buildParameters(
+ getTestParameters().withCfRuntimes().build(), KotlinTargetVersion.values());
+ }
+
+ public MetadataRenameInReturntypeTest(
+ TestParameters parameters, KotlinTargetVersion targetVersion) {
+ super(targetVersion);
+ this.parameters = parameters;
+ }
+
+ private static Path returntypeLibJar;
+
+ @BeforeClass
+ public static void createLibJar() throws Exception {
+ String returntypeLibFolder = PKG_PREFIX + "/returntype_lib";
+ returntypeLibJar = getStaticTemp().newFile("returntype_lib.jar").toPath();
+ ProcessResult processResult =
+ ToolHelper.runKotlinc(
+ null,
+ returntypeLibJar,
+ null,
+ getKotlinFileInTest(returntypeLibFolder, "lib")
+ );
+ assertEquals(0, processResult.exitCode);
+ }
+
+ @Test
+ public void testmetadataInReturnType_renamed() throws Exception {
+ R8TestCompileResult compileResult =
+ testForR8(parameters.getBackend())
+ .addProgramFiles(returntypeLibJar)
+ // Keep non-private members of Impl
+ .addKeepRules("-keep public class **.Impl { !private *; }")
+ // Keep Itf, but allow minification.
+ .addKeepRules("-keep,allowobfuscation class **.Itf")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
+ .compile();
+ String pkg = getClass().getPackage().getName();
+ final String itfClassName = pkg + ".returntype_lib.Itf";
+ final String implClassName = pkg + ".returntype_lib.Impl";
+ compileResult.inspect(inspector -> {
+ ClassSubject itf = inspector.clazz(itfClassName);
+ assertThat(itf, isPresent());
+ assertThat(itf, isRenamed());
+
+ ClassSubject impl = inspector.clazz(implClassName);
+ assertThat(impl, isPresent());
+ assertThat(impl, not(isRenamed()));
+ // API entry is kept, hence the presence of Metadata.
+ DexAnnotation metadata = retrieveMetadata(impl.getDexClass());
+ assertNotNull(metadata);
+ // TODO(b/70169921): should not refer to Itf
+ assertThat(metadata.toString(), containsString("Itf"));
+ });
+
+ Path libJar = temp.newFile("lib.jar").toPath();
+ compileResult.writeToZip(libJar);
+
+ String appFolder = PKG_PREFIX + "/returntype_app";
+ ProcessResult processResult =
+ kotlinc(parameters.getRuntime().asCf())
+ .addClasspathFiles(libJar)
+ .addSourceFiles(getKotlinFileInTest(appFolder, "main"))
+ .setOutputPath(temp.newFolder().toPath())
+ // TODO(b/70169921): update to just .compile() once fixed.
+ .compileRaw();
+ // TODO(b/70169921): should be able to compile!
+ assertNotEquals(0, processResult.exitCode);
+ assertThat(
+ processResult.stderr,
+ containsString("cannot access class '" + pkg + ".returntype_lib.Itf'"));
+ }
+}
+
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInSupertypeTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInSupertypeTest.java
index 7001909..f89ee5e 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInSupertypeTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRenameInSupertypeTest.java
@@ -17,6 +17,7 @@
import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
import com.android.tools.r8.ToolHelper.ProcessResult;
import com.android.tools.r8.graph.DexAnnotation;
+import com.android.tools.r8.shaking.ProguardKeepAttributes;
import com.android.tools.r8.utils.codeinspector.ClassSubject;
import java.nio.file.Path;
import java.util.Collection;
@@ -66,7 +67,7 @@
.addProgramFiles(supertypeLibJar)
// Keep non-private members except for ones in `internal` definitions.
.addKeepRules("-keep public class !**.internal.**, * { !private *; }")
- .addKeepAttributes("*Annotation*")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.compile();
String pkg = getClass().getPackage().getName();
final String itfClassName = pkg + ".supertype_lib.internal.Itf";
@@ -112,7 +113,7 @@
.addKeepRules("-keep public class !**.internal.**, * { !private *; }")
// Keep `internal` definitions, but allow minification.
.addKeepRules("-keep,allowobfuscation class **.internal.** { *; }")
- .addKeepAttributes("*Annotation*")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.compile();
String pkg = getClass().getPackage().getName();
final String itfClassName = pkg + ".supertype_lib.internal.Itf";
@@ -133,19 +134,19 @@
assertThat(metadata.toString(), containsString("a/a"));
});
- Path r8ProcessedLibZip = temp.newFile("r8-lib.zip").toPath();
- compileResult.writeToZip(r8ProcessedLibZip);
+ Path libJar = temp.newFile("lib.jar").toPath();
+ compileResult.writeToZip(libJar);
String appFolder = PKG_PREFIX + "/supertype_app";
Path output =
kotlinc(parameters.getRuntime().asCf())
- .addClasspathFiles(r8ProcessedLibZip)
+ .addClasspathFiles(libJar)
.addSourceFiles(getKotlinFileInTest(appFolder, "main"))
.setOutputPath(temp.newFolder().toPath())
.compile();
testForJvm()
- .addRunClasspathFiles(ToolHelper.getKotlinStdlibJar(), r8ProcessedLibZip)
+ .addRunClasspathFiles(ToolHelper.getKotlinStdlibJar(), libJar)
.addClasspath(output)
.run(parameters.getRuntime(), pkg + ".supertype_app.MainKt")
.assertSuccessWithOutputLines("Impl::foo", "Program::foo");
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 fa46140..00b5606 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
@@ -15,6 +15,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.shaking.ProguardKeepAttributes;
import com.android.tools.r8.utils.codeinspector.ClassSubject;
import com.android.tools.r8.utils.codeinspector.CodeInspector;
import java.util.Collection;
@@ -49,7 +50,7 @@
.addProgramFiles(getJavaJarFile(folder))
.addProgramFiles(ToolHelper.getKotlinReflectJar())
.addKeepMainRule(mainClassName)
- .addKeepAttributes("*Annotation*")
+ .addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.addKeepRules("-keep class kotlin.Metadata")
// TODO(b/145090972): Should never need to exit gracefully during testing.
.allowClassInlinerGracefulExit()
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/parametertype_app/main.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/parametertype_app/main.kt
new file mode 100644
index 0000000..17a6457
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/parametertype_app/main.kt
@@ -0,0 +1,18 @@
+// Copyright (c) 2019, 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.kotlin.metadata.parametertype_app
+
+import com.android.tools.r8.kotlin.metadata.parametertype_lib.Impl
+
+class ProgramClass : Impl() {
+ override fun bar() {
+ super.bar()
+ println("Program::bar")
+ }
+}
+
+fun main() {
+ val instance = ProgramClass()
+ instance.foo(instance)
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/parametertype_lib/lib.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/parametertype_lib/lib.kt
new file mode 100644
index 0000000..75c3d78
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/parametertype_lib/lib.kt
@@ -0,0 +1,19 @@
+// Copyright (c) 2019, 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.kotlin.metadata.parametertype_lib
+
+interface Itf {
+ fun foo(arg : Itf)
+ fun bar()
+}
+
+open class Impl : Itf {
+ override fun foo(arg : Itf) {
+ arg.bar()
+ }
+
+ override fun bar() {
+ println("Impl::bar")
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/propertytype_app/main.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/propertytype_app/main.kt
new file mode 100644
index 0000000..214300c
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/propertytype_app/main.kt
@@ -0,0 +1,14 @@
+// Copyright (c) 2019, 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.kotlin.metadata.propertytype_app
+
+import com.android.tools.r8.kotlin.metadata.propertytype_lib.Impl
+
+class ProgramClass : Impl(8) {
+}
+
+fun main() {
+ val instance : Impl = ProgramClass()
+ println(instance.prop1)
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/propertytype_lib/lib.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/propertytype_lib/lib.kt
new file mode 100644
index 0000000..40aa801
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/propertytype_lib/lib.kt
@@ -0,0 +1,18 @@
+// Copyright (c) 2019, 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.kotlin.metadata.propertytype_lib
+
+interface Itf {
+ val prop1: Itf
+}
+
+open class Impl(val id: Int) : Itf {
+
+ override val prop1: Itf
+ get() = this
+
+ override fun toString(): String {
+ return "Impl::$id"
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/returntype_app/main.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/returntype_app/main.kt
new file mode 100644
index 0000000..37d446e
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/returntype_app/main.kt
@@ -0,0 +1,20 @@
+// Copyright (c) 2019, 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.kotlin.metadata.returntype_app
+
+import com.android.tools.r8.kotlin.metadata.returntype_lib.Impl
+import com.android.tools.r8.kotlin.metadata.returntype_lib.Itf
+
+class ProgramClass : Impl() {
+ override fun foo(): Itf {
+ super.foo()
+ println("Program::foo")
+ return this
+ }
+}
+
+fun main() {
+ val instance = ProgramClass()
+ println(instance == instance.foo())
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/returntype_lib/lib.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/returntype_lib/lib.kt
new file mode 100644
index 0000000..c24e292
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/returntype_lib/lib.kt
@@ -0,0 +1,15 @@
+// Copyright (c) 2019, 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.kotlin.metadata.returntype_lib
+
+interface Itf {
+ fun foo() : Itf
+}
+
+open class Impl : Itf {
+ override fun foo() : Itf {
+ println("Impl::foo")
+ return this
+ }
+}
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/supertype_app/main.kt b/src/test/java/com/android/tools/r8/kotlin/metadata/supertype_app/main.kt
index 4192774..309b756 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/supertype_app/main.kt
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/supertype_app/main.kt
@@ -12,6 +12,6 @@
}
}
-fun main(args: Array<String>) {
+fun main() {
ProgramClass().foo()
}
\ No newline at end of file