What type is less specific than 'Any'?


#1

I’m fixing some code after upgrading to M13, and I got this error below. I see I can fix it by putting the “: Any” bound on RowType.

But I’m wondering, what type does it think it is without that bound? I didn’t think there was anything more general than Any

Error:(76, 23) Kotlin: Type argument is not within its bounds: should be subtype of ‘kotlin.Any’  

inline fun ResultSet.getRows<reified RowType>(): ArrayList<RowType> {
  // val c = javaClass<RowType>()
  val c = RowType::class.java  // error here
  return getRows©
}

#2

Probably "Any?"


#3
RowType should be subtype of kotlin.Any so in the method signature:
<reified RowType : Any>

#4

mikehearn wrote:

Probably “Any?”


Makes sense. If that’s it, it seems like I should still be able to access ::class inside the function.


#5

I refer you to kotlin slack http://kotlinslackin.herokuapp.com/ On channel #reflect it is well explained by Jayson Minard.