KT-65404 KAPT should print a warning if stub generation is triggered for an interface with method bodies but without -Xjvm-default=all or -Xjvm-default=all-compatibility
Merge-request: KT-MR-14139 Merged-by: Pavel Mikhailovskii <Pavel.Mikhailovskii@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
d75463a7d5
commit
e363a1228d
+5
-4
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.kapt.cli.test
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.intellij.openapi.util.text.StringUtil.convertLineSeparators
|
||||
import org.jetbrains.kotlin.cli.common.arguments.readArgumentsFromArgFile
|
||||
import org.jetbrains.kotlin.test.services.JUnit5Assertions
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
@@ -53,10 +54,10 @@ abstract class AbstractKaptToolIntegrationTest {
|
||||
"javac" -> runJavac(section.args)
|
||||
"java" -> runJava(section.args)
|
||||
"output" -> {
|
||||
val output = File(tmpdir, "processOutput.txt").readText()
|
||||
val expected = section.content.trim()
|
||||
JUnit5Assertions.assertTrue(output.contains(expected)) {
|
||||
"Output\"$output\" doesn't contain the expected string \"$expected\""
|
||||
val output = convertLineSeparators(File(tmpdir, "processOutput.txt").readText().trim())
|
||||
val expected = convertLineSeparators(section.content.trim())
|
||||
JUnit5Assertions.assertEquals(expected, output) {
|
||||
"Output\"$output\" is different from the expected string \"$expected\""
|
||||
}
|
||||
}
|
||||
"after" -> {}
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
interface I1 {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
class C: I1, I2
|
||||
plugins/kapt3/kapt3-cli/testData/integration-kapt4/defaultMethodsAllCompatibilityNoWarning/build.txt
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
# mkdir
|
||||
output/stubs
|
||||
|
||||
# kapt
|
||||
-Xjvm-default=all-compatibility
|
||||
-language-version 2.0
|
||||
-Xuse-kapt4
|
||||
-Kapt-mode=stubs
|
||||
-Kapt-stubs=output/stubs
|
||||
-Kapt-classes=output/classes
|
||||
-Kapt-sources=output/sources
|
||||
-Kapt-classpath=output/ap
|
||||
-d output/classes
|
||||
-cp %KOTLIN_STDLIB%
|
||||
Test.kt
|
||||
|
||||
# output
|
||||
warning: k2 kapt is an experimental feature. Use with caution.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
interface I1 {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
class C: I1, I2
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# mkdir
|
||||
output/stubs
|
||||
|
||||
# kapt
|
||||
-Xjvm-default=all
|
||||
-language-version 2.0
|
||||
-Xuse-kapt4
|
||||
-Kapt-mode=stubs
|
||||
-Kapt-stubs=output/stubs
|
||||
-Kapt-classes=output/classes
|
||||
-Kapt-sources=output/sources
|
||||
-Kapt-classpath=output/ap
|
||||
-d output/classes
|
||||
-cp %KOTLIN_STDLIB%
|
||||
Test.kt
|
||||
|
||||
# output
|
||||
warning: k2 kapt is an experimental feature. Use with caution.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package test
|
||||
|
||||
interface I1 {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface I2 {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
class C: I1, I2
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
# mkdir
|
||||
output/stubs
|
||||
|
||||
# kapt
|
||||
-language-version 2.0
|
||||
-Xuse-kapt4
|
||||
-Kapt-mode=stubs
|
||||
-Kapt-stubs=output/stubs
|
||||
-Kapt-classes=output/classes
|
||||
-Kapt-sources=output/sources
|
||||
-Kapt-classpath=output/ap
|
||||
-d output/classes
|
||||
-cp %KOTLIN_STDLIB%
|
||||
Test.kt
|
||||
|
||||
# output
|
||||
warning: k2 kapt is an experimental feature. Use with caution.
|
||||
warning: [kapt] Support for interface methods with bodies in Kapt requires -Xjvm-default=all or -Xjvm-default=all-compatibility compiler option
|
||||
+18
@@ -42,6 +42,24 @@ public class Kapt4ToolIntegrationTestGenerated extends AbstractKapt4ToolIntegrat
|
||||
runTest("plugins/kapt3/kapt3-cli/testData/integration-kapt4/correctErrorTypesOn/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultMethodsAllCompatibilityNoWarning")
|
||||
public void testDefaultMethodsAllCompatibilityNoWarning() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-cli/testData/integration-kapt4/defaultMethodsAllCompatibilityNoWarning/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultMethodsAllNoWarning")
|
||||
public void testDefaultMethodsAllNoWarning() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-cli/testData/integration-kapt4/defaultMethodsAllNoWarning/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultMethodsWarning")
|
||||
public void testDefaultMethodsWarning() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-cli/testData/integration-kapt4/defaultMethodsWarning/");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultPackage")
|
||||
public void testDefaultPackage() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user