[SR-12296] Return protocols / opaque types as return / computed variables #54726
Labels
compiler
The Swift compiler in itself
improvement
opaque types
Feature → types: opaque types
type checker
Area → compiler: Semantic analysis
Attachment: Download
Additional Detail from JIRA
md5: 4a2b82dc25f04c24f0e53bd7aa7ea45a
Issue Description:
Currently we can create protocols and opaque types and return objects using those types from computed variables and functions without a problem. Returning these types individually will provide API's and SDK's, as well as the default library new ways to expand.
Example:
Currently this errors with "Return type of global function 'returnA()' requires that 'B.Protocol' conform to 'A'". Allowing this would allow new advancements in generic programming, progression in rewriting the Swift language, and advances in the creation of new technology outside the Apple platform. An example would be Layout Constraints.
The line of code above is a good example of where this change can be applied. Layout Constraints are fragmented at best. Rewriting them using this change would give a unified change and allow less strict "do not use" code for developers and more continuity.
See attached playground for the example above.
The text was updated successfully, but these errors were encountered: