Kapt: Add test on Map<Key, Intf> and MutableMap<Key, Intf>
(cherry picked from commit 59cdbcb)
This commit is contained in:
committed by
Yan Zhulanow
parent
30ed279426
commit
a22721fbd8
+5
-1
@@ -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<JeMethodExecutableElement> {
|
||||
return enclosedElements.filterIsInstance<JeMethodExecutableElement>().filter { it.simpleName.toString() == name }
|
||||
}
|
||||
|
||||
protected fun TypeElement.findMethod(name: String, vararg parameterTypes: String): JeMethodExecutableElement {
|
||||
return enclosedElements.first {
|
||||
if (it !is JeMethodExecutableElement
|
||||
|
||||
+12
@@ -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<java.lang.Integer,? extends Intf>")
|
||||
test("b", "java.util.Map<java.lang.Integer,Intf>")
|
||||
test("c", "java.util.Map<java.lang.Integer,Test>")
|
||||
test("d", "java.util.Map<java.lang.Integer,Test>")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user