From a22721fbd81f3001d55460ff1607939ce681948a Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Wed, 21 Sep 2016 21:21:06 +0300 Subject: [PATCH] Kapt: Add test on Map and MutableMap (cherry picked from commit 59cdbcb) --- .../testData/processors/MapMutableMap.kt | 12 ++++++++++++ .../test/processor/AbstractProcessorTest.kt | 6 +++++- .../processing/test/processor/ProcessorTests.kt | 12 ++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 plugins/annotation-processing/testData/processors/MapMutableMap.kt diff --git a/plugins/annotation-processing/testData/processors/MapMutableMap.kt b/plugins/annotation-processing/testData/processors/MapMutableMap.kt new file mode 100644 index 00000000000..28bf97ac033 --- /dev/null +++ b/plugins/annotation-processing/testData/processors/MapMutableMap.kt @@ -0,0 +1,12 @@ +annotation class Anno + +interface Intf + +@Anno +class Test { + fun a(map: Map) {} + fun b(map: MutableMap) {} + + fun c(map: Map) {} + fun d(map: MutableMap) {} +} \ No newline at end of file diff --git a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/AbstractProcessorTest.kt b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/AbstractProcessorTest.kt index 7d854c417de..7e92ede36cf 100755 --- a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/AbstractProcessorTest.kt +++ b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/AbstractProcessorTest.kt @@ -142,7 +142,11 @@ abstract class AbstractProcessorTest : AbstractBytecodeTextTest() { fail("Annotation processor " + (if (shouldRun) "was not started" else "was started")) } } - + + protected fun TypeElement.findMethods(name: String): List { + return enclosedElements.filterIsInstance().filter { it.simpleName.toString() == name } + } + protected fun TypeElement.findMethod(name: String, vararg parameterTypes: String): JeMethodExecutableElement { return enclosedElements.first { if (it !is JeMethodExecutableElement diff --git a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/ProcessorTests.kt b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/ProcessorTests.kt index f2d3c64a59a..a8800c86fd8 100644 --- a/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/ProcessorTests.kt +++ b/plugins/plugins-tests/tests/org/jetbrains/kotlin/annotation/processing/test/processor/ProcessorTests.kt @@ -333,4 +333,16 @@ class ProcessorTests : AbstractProcessorTest() { testDisposable("getBindingContext") } } + + fun testMapMutableMap() = test("MapMutableMap", "*") { set, roundEnv, env -> + val test = env.findClass("Test") + fun test(name: String, expected: String) { + assertEquals(expected, test.findMethods(name).single().parameters.single().asType().toString()) + } + + test("a", "java.util.Map") + test("b", "java.util.Map") + test("c", "java.util.Map") + test("d", "java.util.Map") + } } \ No newline at end of file