首页 > 解决方案 > Dagger2 @Binds methods' parameter type must be assignable to the return type with interface and implementation

问题描述

标签: androidkotlindagger-2

解决方案


我怀疑这可能是“缺少”@JvmSuppressWildcards 的情况,其中 kotlin? extends StringList类型中添加了一些,这使得 dagger 编译器失败(错误消息应该包含更多提示)。

我想您需要将函数类型更改为Function<List<@JvmSuppressWildcards String>, String>使用它的位置。

这是一个已知的烦恼,您可以在此处阅读更多详细信息: https ://medium.com/@naturalwarren/dagger-kotlin-3b03c8dd6e9b

我怀疑这MutableList不存在这个问题,因为您可以使用它“读取”和“写入”字符串。


推荐阅读