You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, sometimes you realize that you need index access to the elements of your collection and want to change the return type from Collection to RandomAccess.
However, RandomAccess is a marker interface, not a subtype of Collection, so this is an incorrect example.
Also, the section name "Don't make return types narrower" leads reader to an implicit assumption that "making return types wider" is somehow a good thing. It clearly needs a clarification that narrowing, unlike widening, is mostly source-compatible, so it is tempting to do, yet should not be done.
The text was updated successfully, but these errors were encountered:
From https://kotlinlang.org/docs/jvm-api-guidelines-backward-compatibility.html#don-t-make-return-types-narrower
However,
RandomAccess
is a marker interface, not a subtype ofCollection
, so this is an incorrect example.Also, the section name "Don't make return types narrower" leads reader to an implicit assumption that "making return types wider" is somehow a good thing. It clearly needs a clarification that narrowing, unlike widening, is mostly source-compatible, so it is tempting to do, yet should not be done.
The text was updated successfully, but these errors were encountered: