Why won't this compile? ``` open class Queue<E...
# getting-started
b
Why won't this compile?
Copy code
open class Queue<Element>(protected var backingList: MutableList<Element> = mutableListOf()) {
    fun listValue():List<Element> = List(*(backingList.toTypedArray().copyOf()))
}
Error:
Copy code
Error:(44, 56) Kotlin: Cannot use 'Element' as reified type parameter. Use a class instead.
e
@benleggiero See definition of toTypedArray. Element must be reified https://kotlinlang.org/docs/reference/inline-functions.html
b
@elizarov but
reified
is only applicable to local generic types for inline functions, and I don't see any way to make that happen
e
true. There does not seem to be a way to use it here. In this particular case,
backingList.toList()
would do what you are trying to do.
b
Thanks!