https://kotlinlang.org logo
t

tateisu

12/18/2020, 2:11 AM
Hi, please some one fix this
Copy code
prop.returnType.isSubtypeOf(ArrayList<String>::class.createType())
this expression raise compile error "Only classes are allowed on the left hand side of a class literal"
d

diesieben07

12/18/2020, 2:37 PM
If you don't want to use
typeOf
you can use this:
Copy code
val arrayListStringType = ArrayList::class.createType(
    arguments = listOf(
        KTypeProjection(KVariance.INVARIANT, String::class.createType())
    )
)
prop.returnType.isSubtypeOf(arrayListStringType)
t

tateisu

12/18/2020, 8:20 PM
thanks!
4 Views