kanyun-inc / Kace

Kace: Kotlin Android Compatible Extensions, a framework for assisting in the seamless migration from kotlin-android-extensions
Apache License 2.0
263 stars 12 forks source link

支持Kotlin 1.9.0吗? #46

Closed SwordWang0228 closed 1 year ago

bennyhuo commented 1 year ago

试试1.9.0-1.1.0-SNAPSHOT。因为还没有验证过,所以没发正式版

bennyhuo commented 1 year ago

如果SNAPSHOT没有发现问题,可以联系我发正式版

FioneraGH commented 1 year ago

测试1.9.0-1.1.0没问题

bennyhuo commented 1 year ago

好的。1.9.0现在合了主干最新功能,可以试试1.9.0-1.2.0-SNAPSHOT哈,这个支持了有泛型参数的View类型。没问题的话我明天就可以发正式包。

FioneraGH commented 1 year ago

https://s01.oss.sonatype.org/content/repositories/snapshots/com/kanyun/kace/kace-gradle-plugin/ 没有1.9.0-1.2.0,也没有1.9.10-1.2.0

bennyhuo commented 1 year ago

抱歉,可能是之前发失败了,我重新发一下

bennyhuo commented 1 year ago

https://s01.oss.sonatype.org/content/repositories/snapshots/com/kanyun/kace/kace-gradle-plugin/1.9.0-1.2.0-SNAPSHOT/

.有了

FioneraGH commented 1 year ago

/build/generated/source/kace/debug/kotlinx/android/synthetic/main/fragment_publish_mv/view/FragmentPublishMv.kt:104:69 Argument type mismatch: actual type is java/lang/Class but java/lang/Class<ft<T & Any, T?>>! was expected

FioneraGH commented 1 year ago

1.2.0有类型不匹配

FioneraGH commented 1 year ago

private inline val AndroidExtensionsBase.tv_video_visibility get() = findViewByIdCached(this, R.id.tv_video_visibility)

/**

bennyhuo commented 1 year ago

需要clean重新编译哈,看上去生成的代码是之前的。1.2和1.1的不兼容

FioneraGH commented 1 year ago

clean 后还是不行哎

build/generated/source/kace/debug/kotlinx/android/synthetic/main/activity_publish_info_edit/ActivityPublishInfoEdit.kt:191:32 Argument type mismatch: actual type is com/kanyun/kace/AndroidExtensionsBase but com/kanyun/kace/AndroidExtensionsBase! was expected

build/generated/source/kace/debug/kotlinx/android/synthetic/main/activity_publish_info_edit/ActivityPublishInfoEdit.kt:191:38 Argument type mismatch: actual type is kotlin/Int but kotlin/Int was expected

build/generated/source/kace/debug/kotlinx/android/synthetic/main/activity_publish_info_edit/ActivityPublishInfoEdit.kt:191:61 Argument type mismatch: actual type is java/lang/Class but java/lang/Class<ft<T & Any, T?>>! was expected

生成代码: private inline val AndroidExtensionsBase.recycler_wrapper get() = findViewByIdCached(this, R.id.recycler_wrapper, packagename.util.widget.pullloadmorerecyclerview.LoadMoreWrapperRecyclerView::class.java)

这个view是自定义view 会有关系吗

kace-runtime: public interface AndroidExtensionsBase {

/**
 * It is necessary to write this in Java, because we want a platform type here as the return type.
 */
<T extends View> T findViewByIdCached(AndroidExtensionsBase owner, int id, Class<T> viewClass);

}

bennyhuo commented 1 year ago

如果你使用 K2 编译,可能跟 K2 的 bug 有关。如果:

  1. LoadMoreWrapperRecyclerView 是一个 Java 类
  2. 它所在的包下面只有 Java 类
  3. 它的父级包至少有一层没有任何代码文件(即只有子包)

满足这几个条件,那么估计就是命中了 K2 的 bug。

报错信息后面应该还有类似的:

Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: [val <T> KClass<T>.java: Class<T>]

解决办法:

使用 K1 编译 或者 在这个类所在的没有源码文件的父包当中创建一个空的 Java 类让 K2 能够正常解析这个类名。

bennyhuo commented 1 year ago

K2 的这个问题预计在 1.9.20 修复,参考:https://youtrack.jetbrains.com/issue/KT-57353https://youtrack.jetbrains.com/issue/KT-57845

FioneraGH commented 1 year ago

这个类确实是这样,1.1.0时没有viewClass倒没事,我试一下你说的workaround

FioneraGH commented 1 year ago

的确是K2这个问题,没问题了

bennyhuo commented 1 year ago

好,我待会儿发个 1.9.0-1.2.0 正式版。

bennyhuo commented 1 year ago

1.9.0-1.2.0 已发布,谢谢支持。