Skip to content

Commit 75e0959

Browse files
committed
Add option to enable multiplatform support. Resolves #303
1 parent ca4309e commit 75e0959

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

core/src/main/kotlin/com/tschuchort/compiletesting/AbstractKotlinCompilation.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,15 @@ abstract class AbstractKotlinCompilation<A : CommonCompilerArguments> internal c
9191
/** Use the new experimental K2 compiler */
9292
var useK2: Boolean by default { false }
9393

94+
/** Enable experimental multiplatform support */
95+
var multiplatform: Boolean = false
96+
97+
/** Do not check presence of 'actual' modifier in multi-platform projects */
98+
var noCheckActual: Boolean = false
99+
100+
/** Enable usages of API that requires opt-in with an opt-in requirement marker with the given fully qualified name */
101+
var optIn: List<String>? = null
102+
94103
/** Additional string arguments to the Kotlin compiler */
95104
var kotlincArguments: List<String> = emptyList()
96105

@@ -130,6 +139,9 @@ abstract class AbstractKotlinCompilation<A : CommonCompilerArguments> internal c
130139
args.reportOutputFiles = reportOutputFiles
131140
args.reportPerf = reportPerformance
132141
args.useK2 = useK2
142+
args.multiPlatform = multiplatform
143+
args.noCheckActual = noCheckActual
144+
args.optIn = optIn?.toTypedArray()
133145

134146
if (languageVersion != null)
135147
args.languageVersion = this.languageVersion

core/src/test/kotlin/com/tschuchort/compiletesting/KotlinCompilationTests.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,5 +917,18 @@ class KotlinCompilationTests {
917917
assertClassLoadable(result, "KSource")
918918
}
919919

920+
@Test
921+
fun `can compile code with multi-platform expect modifier`() {
922+
val result = defaultCompilerConfig().apply {
923+
sources = listOf(
924+
SourceFile.kotlin("kSource1.kt", "expect interface MppInterface"),
925+
SourceFile.kotlin("kSource2.kt", "actual interface MppInterface")
926+
)
927+
multiplatform = true
928+
}.compile()
929+
930+
assertThat(result.exitCode).isEqualTo(ExitCode.OK)
931+
}
932+
920933
class InheritedClass {}
921934
}

0 commit comments

Comments
 (0)