重写Kotlin中的Java @Nullable varargs方法,IDE抱怨它没有覆盖任何东西
我有一个Java方法接口,看起来像这样:
@NonNull Future<List<Item>> search(@NonNull String query, @Nullable EntityType... types);
当我像这样在Kotlin中实现它时(通过IntelliJ实现代):
override fun search(query: String, vararg roomType: EntityType?): Future<List<Item>>
IDE抱怨说它“无所作为”。 但是,如果Java类中不存在@Nullable注释,则不存在lint错误。
注释是将可变参数数组标记为可空,而不是数组中的值。 这似乎工作:
override fun search(query: String, roomType: Array<EntityType>?): Future<List<Item>>