diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt index b813f6e1636..1a802fc8672 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/AbstractKotlinKapt3Test.kt @@ -60,7 +60,7 @@ import java.io.PrintStream import java.util.* import com.sun.tools.javac.util.List as JavacList -abstract class AbstractKotlinKapt3Test : CodegenTestCase() { +abstract class AbstractKotlinKapt3Test : KotlinKapt3TestBase() { companion object { const val FILE_SEPARATOR = "\n\n////////////////////\n\n" val ERR_BYTE_STREAM = ByteArrayOutputStream() @@ -69,13 +69,6 @@ abstract class AbstractKotlinKapt3Test : CodegenTestCase() { val messageCollector = PrintingMessageCollector(ERR_PRINT_STREAM, MessageRenderer.PLAIN_FULL_PATHS, false) } - val kaptFlags = mutableListOf() - - override fun setUp() { - super.setUp() - kaptFlags.clear() - } - override fun tearDown() { ERR_BYTE_STREAM.reset() super.tearDown() @@ -205,8 +198,6 @@ abstract class AbstractKotlinKapt3Test : CodegenTestCase() { } } - protected fun File.isOptionSet(name: String) = this.useLines { lines -> lines.any { it.trim() == "// $name" } } - protected fun File.getRawOptionValues(name: String) = this.useLines { lines -> lines.filter { it.startsWith("// $name") }.toList() } @@ -248,18 +239,6 @@ open class AbstractClassFileToSourceStubConverterTest : AbstractKotlinKapt3Test( fun testSuppressWarning() {} override fun doTest(filePath: String) { - val wholeFile = File(filePath) - - kaptFlags.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS) - - if (wholeFile.isOptionSet("CORRECT_ERROR_TYPES")) { - kaptFlags.add(KaptFlag.CORRECT_ERROR_TYPES) - } - - if (wholeFile.isOptionSet("STRICT_MODE")) { - kaptFlags.add(KaptFlag.STRICT) - } - super.doTest(filePath) doTestWithJdk9(AbstractClassFileToSourceStubConverterTest::class.java, filePath) doTestWithJdk11(AbstractClassFileToSourceStubConverterTest::class.java, filePath) diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3TestBase.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3TestBase.kt new file mode 100644 index 00000000000..c2efa4e912f --- /dev/null +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3TestBase.kt @@ -0,0 +1,39 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.kapt3.test + +import org.jetbrains.kotlin.base.kapt3.KaptFlag +import org.jetbrains.kotlin.codegen.CodegenTestCase +import java.io.File + +abstract class KotlinKapt3TestBase : CodegenTestCase() { + val kaptFlags = mutableListOf() + + override fun setUp() { + super.setUp() + kaptFlags.clear() + } + + protected fun File.isOptionSet(name: String) = this.useLines { lines -> lines.any { it.trim() == "// $name" } } + + override fun doTest(filePath: String) { + val wholeFile = File(filePath) + + kaptFlags.add(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS) + + fun handleFlag(flag: KaptFlag) { + if (wholeFile.isOptionSet(flag.name)) { + kaptFlags.add(flag) + } + } + + handleFlag(KaptFlag.CORRECT_ERROR_TYPES) + handleFlag(KaptFlag.STRICT) + handleFlag(KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES) + + super.doTest(filePath) + } +} \ No newline at end of file diff --git a/plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt b/plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt index 7acc5dacc56..3106eb438a2 100644 --- a/plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt +++ b/plugins/kapt3/kapt3-compiler/testData/converter/kt24272.kt @@ -1,4 +1,4 @@ -// STRICT_MODE +// STRICT class Foo(private val string: String) { val bar = Bar("bar")