Implications of SE-0335 when implementing dependency injection

The benefit of adding the any keyword is clarifying in your code that you do not have the full API surface promised by the protocol constraint. There also may be places where you can change the any to some instead, e.g. in function parameters. There's more information on when to use some vs any here:

SE-0335 will have more code changes for specific programming patterns, including some forms of dependency injection and the delegate pattern, compared to emergent programming patterns that preserve more static type information. It's okay to disagree that this language change is ultimately "worth it", because every programmer has different opinions and constraints. At the end of the day, if you want to write any everywhere it was previously inferred, the code change will amount to applying all fix-its from the compiler.

3 Likes