If an interface is annotated with `@Immutable` , i...
# compose
y
If an interface is annotated with
@Immutable
, is it still required to add the annotation to every class implementing this interface? (would make sense that it is). Any behavior difference between interface/superclass ? (Does it depend on the type declared in the composable signature, or the actual type at runtime?)
c
No, if the supertype is stable, then the type is considered stable as well.
­čĹŹ 1
e
I think it depends on the type at compiled time. So if you're using the concrete type and it wasn't annotated it wouldn't be considered stable (if the stability inference didn't work). I believe that's because the concrete class can be implemented in an unstable manner regardless of what the interface declares.
y
That's what I thought too, it would make more sense (at least to use the declared type in the signature, rather than looking for any Immutable parent)
c
No, it is not the case. If a type has any supertypes annotated as stable, it will be treated as stable as well. I actually tested this, but you can see it in the compiler code.
y
Thanks for the extra info and the link ­čÖĆ
e
I'm going based on https://kotlinlang.slack.com/archives/CJLTWPH7S/p1614158592395900?thread_ts=1614158592.395900&cid=CJLTWPH7S Although I guess that was almost a year ago so maybe something changed since then?
hasStableMarkedDescendant
is an odd name. It makes me think it'll look at all of a classes subtypes to see if any are marked as stable, but it actually looks at all the super types. Seems like
isStableMarkedDescendant
would be more appropriate unless I'm missing something.
c
I agree, that name is misleading.