[Gradle] Test that nullability is correctly inferred in metadata compilation
^KT-56380
This commit is contained in:
committed by
Space Team
parent
2137d26ce8
commit
081e006006
+8
@@ -1183,6 +1183,14 @@ open class HierarchicalMppIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@GradleTest
|
||||
@DisplayName("KT-56380: correct nullability inference in metadata compilations")
|
||||
fun `test correct nullability inference in metadata compilation`(gradleVersion: GradleVersion) {
|
||||
project("kt-56380_correct_nullability_inference", gradleVersion) {
|
||||
build(":b:compileCommonMainKotlinMetadata")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun TestProject.testDependencyTransformations(
|
||||
subproject: String? = null,
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
linuxX64()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package a
|
||||
|
||||
class A(
|
||||
val data: Any?
|
||||
)
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("multiplatform")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm()
|
||||
linuxX64()
|
||||
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api(project(":a"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(KotlinCompile::class.java).configureEach {
|
||||
kotlinOptions {
|
||||
allWarningsAsErrors = true
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package b
|
||||
|
||||
import a.A
|
||||
|
||||
fun foo(response: A) {
|
||||
if (response.data != null) {
|
||||
doSomethingWithNonNullable(response.data!!)
|
||||
}
|
||||
}
|
||||
|
||||
fun doSomethingWithNonNullable(data: Any) {
|
||||
print(data)
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
plugins {
|
||||
kotlin("multiplatform") apply false
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kotlin.mpp.enableCompatibilityMetadataVariant=true
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
include(":a")
|
||||
include(":b")
|
||||
Reference in New Issue
Block a user