Weird case with generic on Android

  public <D extends com.j256.ormlite.dao.Dao<T,?>, T>  D getDao(java.lang.Class<T> clazz) throws java.sql.SQLException { /* compiled code */ }

Above is the parent method. Calling above method using the following Kotlin code doesn’t compile

``


  var bookmarkDao : Dao<Bookmark, out Int?>? = null

  fun getBookmarkDao() : Dao<Bookmark, out Int?> {
  if (bookmarkDao == null){
           bookmarkDao = getDao<Dao<Bookmark, out Int?>?, Bookmark>(javaClass<Bookmark>())
  }
  return bookmarkDao!!
  }

Above code generates the following error

Type argument is not within its bounds: should be subtype of ‘com.j256.ormlite.dao.Dao<T, out jet.Any?>?’

However if I override getDao

``


  public override fun <D: Dao<T, out Any?>?, T> getDao(clazz: Class<T>?): D {
  return super<OrmLiteSqliteOpenHelper>.getDao(clazz)!!
  }

  var bookmarkDao : Dao<Bookmark, out Int?>? = null

  fun getBookmarkDao() : Dao<Bookmark, out Int?> {
  if (bookmarkDao == null){
           bookmarkDao = getDao<Dao<Bookmark, out Int?>?, Bookmark>(javaClass<Bookmark>())
  }
  return bookmarkDao!!
  }

Above code compiles but it will not deploy to Android

pkg: /data/local/tmp/com.silverkeytech.android_rivers Failure [INSTALL_FAILED_DEXOPT]

12-13 22:34:19.901: DEBUG/installd(811): DexInv: --- BEGIN '/data/app/com.silverkeytech.android_rivers-1.apk' --- 12-13 22:34:21.774: ERROR/dalvikvm(1473): Out-of-order method_idx: 0x2bff then 0x2bff 12-13 22:34:21.774: ERROR/dalvikvm(1473): Trouble with item 897 @ offset 0x13e51c 12-13 22:34:21.774: ERROR/dalvikvm(1473): Swap of section type 2006 failed 12-13 22:34:21.774: ERROR/dalvikvm(1473): ERROR: Byte swap + verify failed 12-13 22:34:21.803: ERROR/dalvikvm(1473): Optimization failed 12-13 22:34:21.803: WARN/installd(811): DexInv: --- END '/data/app/com.silverkeytech.android_rivers-1.apk' --- status=0xff00, process failed 12-13 22:34:21.803: ERROR/installd(811): dexopt failed on '/data/dalvik-cache/data@app@com.silverkeytech.android_rivers-1.apk@classes.dex' res = 65280

Actually this code alone will break the deployment to Android

``


  var bookmarkDao : Dao<Bookmark, out Int?>? = null

  fun getBookmarkDao() : Dao<Bookmark, out Int?>? {
  return bookmarkDao
  }

12-13 22:43:57.219: ERROR/dalvikvm(1623): Out-of-order method_idx: 0x2bff then 0x2bff 12-13 22:43:57.219: ERROR/dalvikvm(1623): Trouble with item 897 @ offset 0x13e498 12-13 22:43:57.219: ERROR/dalvikvm(1623): Swap of section type 2006 failed 12-13 22:43:57.219: ERROR/dalvikvm(1623): ERROR: Byte swap + verify failed 12-13 22:43:57.230: ERROR/dalvikvm(1623): Optimization failed 12-13 22:43:57.230: WARN/installd(811): DexInv: --- END '/data/app/com.silverkeytech.android_rivers-1.apk' --- status=0xff00, process failed 12-13 22:43:57.230: ERROR/installd(811): dexopt failed on '/data/dalvik-cache/data@app@com.silverkeytech.android_rivers-1.apk@classes.dex' res = 65280

This looks like a bug. Could you please report it to your bug tracker (http://youtrack.jetbrains.com)?

http://youtrack.jetbrains.com/issue/KT-3170