Pere Casafont
05/25/2018, 11:21 AMimplement
keyword to be used instead of override
when what you're "overriding" are actually interface or abstract methods?Pere Casafont
05/25/2018, 11:23 AMspand
05/25/2018, 11:39 AMPere Casafont
05/25/2018, 12:11 PMRussell Davis
05/26/2018, 2:53 AMimplement
) you'd get a compiler error (maybe a subclass started implementing the same thing, and now you'd want to revisit your implementation)benleggiero
05/26/2018, 4:05 AMoverride
always felt… misleading, at best, when implementing an interface.karelpeeters
05/26/2018, 12:46 PMbenleggiero
05/26/2018, 12:47 PMgildor
05/27/2018, 7:25 AMPere Casafont
05/27/2018, 4:38 PMPere Casafont
05/27/2018, 4:40 PMgildor
05/27/2018, 4:42 PMimplement
with override
without any profit except different word?
It's like separation of extends/implements in Java but much worse.Pere Casafont
05/27/2018, 5:27 PM?
to a very used field, you have to revisit all its usages, that strictness is in kotlin's signature imhoPere Casafont
05/27/2018, 5:29 PMbenleggiero
05/27/2018, 6:17 PMimplement
. Otherwise, if there was a previous implementation you want to override, the keyword should be override
. This seems straightforward to me.
This achieves a similar strength as the override
keyword, as now you know if an API changes and a method in an abstract class that used to have no implementation suddenly does, your code won't compile because you have not acknowledged this. Then you can decide if you want to use the "official" implementation by removing yours, or stick with your implementation by changing implement
to override
gildor
05/28/2018, 1:00 AMlike when you add aI see very big difference. I’m not just “add a `?`“, I changed type of property or signature of the method, so of course you should handle this case. But in case of override/implement I don’t see any prevented bugs or any other profit from splitting those identical keywords. Could you show me an example where it could prevent bugs or somehow help to a developer. For me it’s just looks like an unnecessary point that reduces source compatibility without any profitto a very used field?
gildor
05/28/2018, 1:03 AMOtherwise, if there was a previous implementation you want to override, the keyword should beIs not so straightforward for default methods. Anyway, this looks like a change that complete breaks compatibility of all Kotlin sources. This seems straightforward to me.override
benleggiero
05/28/2018, 4:26 AMgildor
05/28/2018, 4:41 AMbenleggiero
05/28/2018, 5:57 AMgildor
05/28/2018, 7:13 AMgildor
05/28/2018, 7:17 AMbenleggiero
05/28/2018, 7:43 AMPere Casafont
05/30/2018, 9:13 AMOverride is not allowed when implementing an interface method
gildor
05/30/2018, 11:31 PMThe method does override or implement a method declared in a supertype.So, as you can see Java decided to use the same annotation for both cases
Pere Casafont
05/30/2018, 11:32 PM