例如在Java中我可以这样写:交叉引用参数
public abstract class Element<S extends Snapshot> { ... }
public abstract class Snapshot<E extends Element> { ... }
,然后某处,扩展这一类:
public class SnapshotImpl extends Snapshot<ElementImpl> { ... }
public class ElementImpl extends Element<SnapshotImpl> { ... }
但是,当我试图实现科特林同一类层次结构:
abstract class Element<S : Snapshot>
abstract class Snapshot<E : Element>
我得到了下面的编译错误:
Error:(6, 28) Kotlin: One type argument expected for class Snapshot<E> defined in model Error:(6, 25) Kotlin: One type argument expected for class Element<S> defined in model
是否有任何方法可以在Kotlin中重现相同类型的参数限制?