Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ce68379 authored by Cole Faust's avatar Cole Faust
Browse files

Add -Xjvm-defaults=all to kotlin compilations

This causes kotlinc to output default methods
instead of DefaultsImpl inner classes. It's required
for code that depends on other libraries using
@JvmDefault. It will be the default in a future
version of kotlin.

Bug: 236431222
Test: treehugger
Change-Id: I67a7cb3b816b41a441af7ec78cc64bc358c6889d
parent d96eebf3
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -1072,6 +1072,13 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
		kotlincFlags := j.properties.Kotlincflags
		kotlincFlags := j.properties.Kotlincflags
		CheckKotlincFlags(ctx, kotlincFlags)
		CheckKotlincFlags(ctx, kotlincFlags)


		// This is needed for code that depends on libraries that use @JvmDefault
		// -Xjvm-default=all will be the default in a future version of kotlin
		// according to https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/
		if flags.javaVersion >= JAVA_VERSION_8 {
			kotlincFlags = append(kotlincFlags, "-Xjvm-default=all")
		}

		// Workaround for KT-46512
		// Workaround for KT-46512
		kotlincFlags = append(kotlincFlags, "-Xsam-conversions=class")
		kotlincFlags = append(kotlincFlags, "-Xsam-conversions=class")