does anybody know why I cant override LinkedHashMa...
# announcements
g
does anybody know why I cant override LinkedHashMaps
removeEldestEntry
in java-covariant way with
Any
as the argument type? eg:
Copy code
val thingy : LinkedHashMap<AnnoyingKeyType, ValueType> = object: LinkedHashMap<AnnoyingKeyType, ValueType>{
  override fun removeEldestEntry(eldest: MutableMap.MutableEntry<AnnoyingKeyType, ValueType>?) = ...
}
is the default signature, and it is legal to override it with:
Copy code
val thingy : LinkedHashMap<AnnoyingKeyType, ValueType> = object: LinkedHashMap<AnnoyingKeyType, ValueType>{
  override fun removeEldestEntry(eldest: Map.Entry<AnnoyingKeyType, ValueType>?) = ...
}
but it is not legal to override it with
Copy code
val thingy : LinkedHashMap<AnnoyingKeyType, ValueType> = object: LinkedHashMap<AnnoyingKeyType, ValueType>{
  override fun removeEldestEntry(eldest: Any?) = ...
}
why?