Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持Kotlin 1.9.0吗? #46

Closed
SwordWang0228 opened this issue Aug 23, 2023 · 18 comments
Closed

支持Kotlin 1.9.0吗? #46

SwordWang0228 opened this issue Aug 23, 2023 · 18 comments

Comments

@SwordWang0228
Copy link

No description provided.

@bennyhuo
Copy link
Member

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

@bennyhuo
Copy link
Member

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

@FioneraGH
Copy link

测试1.9.0-1.1.0没问题

@bennyhuo
Copy link
Member

bennyhuo commented Sep 5, 2023

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

@bennyhuo bennyhuo reopened this Sep 5, 2023
@FioneraGH
Copy link

@bennyhuo
Copy link
Member

bennyhuo commented Sep 5, 2023

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

@FioneraGH
Copy link

/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
Copy link

1.2.0有类型不匹配

@FioneraGH
Copy link

private inline val AndroidExtensionsBase.tv_video_visibility
get() = findViewByIdCached<android.widget.TextView>(this, R.id.tv_video_visibility)

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

@bennyhuo
Copy link
Member

bennyhuo commented Sep 6, 2023

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

@FioneraGH
Copy link

FioneraGH commented Sep 7, 2023

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
Copy link
Member

bennyhuo commented Sep 7, 2023

如果你使用 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
Copy link
Member

bennyhuo commented Sep 7, 2023

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

@FioneraGH
Copy link

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

@FioneraGH
Copy link

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

@bennyhuo
Copy link
Member

bennyhuo commented Sep 7, 2023

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

@bennyhuo
Copy link
Member

bennyhuo commented Sep 7, 2023

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

@bennyhuo bennyhuo closed this as completed Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants