"projections are not allowed for immediate arguments of a supertype" 科特林 Android 工作室
"projections are not allowed for immediate arguments of a supertype" Kotlin Android Studio
我将 Java 转换为 Kotlin 时出现此错误:
Java
public class HeaderTab extends ExpandableGroup {
private String header;
public HeaderTab(String title, List items) {
super(title, items);
}
}
科特林
class HeaderTab(title: String, items: List<*>) : ExpandableGroup<*>(title, items) {
private val header: String? = null
}
Android Studio 是这样说的:
projections are not allowed for immediate arguments of a supertype
这里需要修改什么?
使用 Any
进行快速修复,或引入类型参数以确保您不会破坏库的类型安全。
class HeaderTab(title: String, items: List<*>) : ExpandableGroup<Any>(title, items) {
或
class HeaderTab<E>(title: String, items: List<E>) : ExpandableGroup<E>(title, items) {
问题是 kotlin 需要 class 类型被完全指定,所以你可以指定一个特定的类型作为类型参数或传递一个新的类型参数。
我将 Java 转换为 Kotlin 时出现此错误:
Java
public class HeaderTab extends ExpandableGroup {
private String header;
public HeaderTab(String title, List items) {
super(title, items);
}
}
科特林
class HeaderTab(title: String, items: List<*>) : ExpandableGroup<*>(title, items) {
private val header: String? = null
}
Android Studio 是这样说的:
projections are not allowed for immediate arguments of a supertype
这里需要修改什么?
使用 Any
进行快速修复,或引入类型参数以确保您不会破坏库的类型安全。
class HeaderTab(title: String, items: List<*>) : ExpandableGroup<Any>(title, items) {
或
class HeaderTab<E>(title: String, items: List<E>) : ExpandableGroup<E>(title, items) {
问题是 kotlin 需要 class 类型被完全指定,所以你可以指定一个特定的类型作为类型参数或传递一个新的类型参数。