Skip to content

Commit d248545

Browse files
authored
Add ByteArray and List workarounds. (#623)
* Add ByteArray and List workarounds. * Fix spell.
1 parent e5a52e3 commit d248545

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

processor/src/main/kotlin/permissions/dispatcher/processor/util/Extensions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ fun TypeName.correctJavaTypeToKotlinType(): TypeName {
128128
"java.lang.Double" -> ClassName("kotlin", "Double")
129129
"java.lang.Object" -> ClassName("kotlin", "Any")
130130
"java.lang.String" -> ClassName("kotlin", "String")
131+
// https://github.com/permissions-dispatcher/PermissionsDispatcher/issues/599
132+
// https://github.com/permissions-dispatcher/PermissionsDispatcher/issues/619
133+
"kotlin.ByteArray", "kotlin.collections.List" -> this
131134
else -> this
132135
}
133136
}

processor/src/test/java/permissions/dispatcher/processor/util/ExtensionsTest.kt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@ import org.mockito.Mockito.mock
1010

1111
class ExtensionsTest {
1212
@Test
13-
fun `java Byte is converted into kotlin Byte`() {
13+
fun `java Byte being converted into kotlin Byte`() {
1414
val typeName = mock(TypeName::class.java)
1515
`when`(typeName.toString()).thenReturn("java.lang.Byte")
1616
val expected = typeName.correctJavaTypeToKotlinType().toString()
1717
assertEquals(expected, "kotlin.Byte")
1818
}
1919

2020
@Test
21-
fun `java Double is converted into kotlin Double`() {
21+
fun `java Double being converted into kotlin Double`() {
2222
val typeName = mock(TypeName::class.java)
2323
`when`(typeName.toString()).thenReturn("java.lang.Double")
2424
val expected = typeName.correctJavaTypeToKotlinType().toString()
2525
assertEquals(expected, "kotlin.Double")
2626
}
2727

2828
@Test
29-
fun `java Object is converted into kotlin Any`() {
29+
fun `java Object being converted into kotlin Any`() {
3030
val typeName = mock(TypeName::class.java)
3131
`when`(typeName.toString()).thenReturn("java.lang.Object")
3232
val expected = typeName.correctJavaTypeToKotlinType().toString()
3333
assertEquals(expected, "kotlin.Any")
3434
}
3535

3636
@Test
37-
fun `java String is converted into kotlin String`() {
37+
fun `java String being converted into kotlin String`() {
3838
val typeName = mock(TypeName::class.java)
3939
`when`(typeName.toString()).thenReturn("java.lang.String")
4040
val expected = typeName.correctJavaTypeToKotlinType().toString()
4141
assertEquals(expected, "kotlin.String")
4242
}
4343

4444
@Test
45-
fun `java String in List is converted into kotlin String`() {
45+
fun `java String in parameter being converted into kotlin String`() {
4646
val parameterizedTypeName = mock(ParameterizedTypeName::class.java)
4747
val typeName = mock(TypeName::class.java)
4848
`when`(typeName.toString()).thenReturn("java.lang.String")
@@ -53,4 +53,20 @@ class ExtensionsTest {
5353
expected.typeArguments.first().toString()
5454
assertEquals( expected.typeArguments.first().toString(), "kotlin.String")
5555
}
56+
57+
@Test
58+
fun `kotlin ByteArray retains its type`() {
59+
val typeName = mock(TypeName::class.java)
60+
`when`(typeName.toString()).thenReturn("kotlin.ByteArray")
61+
val expected = typeName.correctJavaTypeToKotlinType().toString()
62+
assertEquals(expected, "kotlin.ByteArray")
63+
}
64+
65+
@Test
66+
fun `kotlin List retains its type`() {
67+
val typeName = mock(TypeName::class.java)
68+
`when`(typeName.toString()).thenReturn("kotlin.collections.List")
69+
val expected = typeName.correctJavaTypeToKotlinType().toString()
70+
assertEquals(expected, "kotlin.collections.List")
71+
}
5672
}

0 commit comments

Comments
 (0)