[Commonizer] Implement integration test for KT-52050

The test project will be compiled and proves that
'platform.posix.DIR' retains it's 'CPointed' supertype.

The test is expected to fail on platforms that do not support
macos (windows and linux), since the issue seems to be caused
by optimistic, single platform propagation.
This commit is contained in:
sebastian.sellmair
2022-04-20 13:42:45 +02:00
committed by Space
parent 4cf10686d6
commit 99d995a313
3 changed files with 51 additions and 0 deletions
@@ -153,6 +153,16 @@ class CommonizerHierarchicalIT : BaseGradleIT() {
}
}
@Test
fun `test KT-52050 - DIR retains CPointed supertype`() {
with(Project("commonize-kt-52050-DIR-supertype")) {
build(":compileCommonMainKotlinMetadata") {
assertNotContains("Unresolved reference")
assertSuccessful()
}
}
}
private object Os {
private val os = OperatingSystem.current()
val canCompileApple get() = os.isMacOsX
@@ -0,0 +1,24 @@
plugins {
kotlin("multiplatform")
}
repositories {
mavenLocal()
mavenCentral()
}
kotlin {
macosX64("macos")
linuxX64("linux")
mingwX64("windows")
val commonMain by sourceSets.getting
val macosMain by sourceSets.getting
val linuxMain by sourceSets.getting
val unixMain by sourceSets.creating
unixMain.dependsOn(commonMain)
linuxMain.dependsOn(unixMain)
macosMain.dependsOn(unixMain)
}
@@ -0,0 +1,17 @@
@file:Suppress("UNUSED_PARAMETER")
import kotlinx.cinterop.CPointed
import platform.posix.DIR
fun requireCPointed(value: CPointed): Unit = error("Not supported")
fun DIR(): DIR = error("Not supported")
fun main() {
/*
Linux and Windows Hosts failed to retain
CPointed supertype of `DIR` when commonizing.
This happened in the special case of 'single platform propagation', which
lost forward declarations from one step to the next.
*/
requireCPointed(DIR())
}