Roberto Fernandez
12/29/2017, 12:44 PMprotected Class getPrototypeClass(T content) {
With this code
override fun getPrototypeClass(content: AlfredElement): Class<*> {
return when (content) {
is Category -> AlfredCategoryRenderer::class.java
is Suggestion -> AlfredSuggestionElement::class.java
}
}
And AlfredCategoryRenderer is a class with this type
: Renderer<AlfredElement>()
So, how can i tell kotlin compiler something like i can do i java which is tell the method getPrototypeClass will return a class that is Something like extends AlfredElement?voddan
12/29/2017, 1:27 PMmarcinmoskala
12/29/2017, 1:58 PMsealed class AlfredElement
class Category : AlfredElement()
class Suggestion : AlfredElement()
abstract class Renderer
class AlfredSuggestionElement : Renderer()
class AlfredCategoryRenderer : Renderer()
fun getPrototypeClass(content: AlfredElement): Class<out Renderer> = when (content) {
is Category -> AlfredCategoryRenderer::class.java
is Suggestion -> AlfredSuggestionElement::class.java
}
marcinmoskala
12/29/2017, 1:59 PMgetPrototypeClass
returns Class of something that is subtype of Renderer