Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for subscript properties #76

Merged
merged 1 commit into from
Apr 27, 2023
Merged

Conversation

kdubb
Copy link
Contributor

@kdubb kdubb commented Apr 27, 2023

  • Adds new FunctionSignatureSpec shared between properties and functions
  • subscript properties are built using a new subscriptBuilder(FunctionSignatureSpec) factory

Fixes #69

* Adds new `FunctionSignatureSpec` shared between properties and functions
* subscript properties are built using a new `subscriptBuilder(FunctionSignatureSpec)` factory
@kdubb
Copy link
Contributor Author

kdubb commented Apr 27, 2023

@lickel This implements subscript properties in all their Swift glory. Use have to use a FunctionSignatureSpec builder that allows you to create whatever crazy signature you need 😀

E.g.

PropertySpec
  .subscriptBuilder(
    FunctionSignatureSpec.builder()
      .addTypeVariable(typeVariable("P").withBounds(TypeVariableName.Bound(typeName("Swift.StringProtocol"))))
      .addParameter(
        "index",
        typeName("Swift.KeyPath")
          .parameterizedBy(typeName(".BackingData"), typeVariable("P"))
      )
      .returns(typeVariable("P"))
      .build()
  )
  .getter(...)
  .setter(...)
  .build()

@kdubb kdubb merged commit 5f360d4 into develop Apr 27, 2023
@kdubb kdubb deleted the feature/subscript-props branch April 27, 2023 00:49
@lickel
Copy link
Collaborator

lickel commented Apr 27, 2023

that's awesome, thanks!

@lickel lickel mentioned this pull request May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Subscript builders
2 participants