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

Render generic type parameters in functions. #3670

Merged
merged 1 commit into from
Feb 22, 2024
Merged

Render generic type parameters in functions. #3670

merged 1 commit into from
Feb 22, 2024

Conversation

kallentu
Copy link
Member

Added generic type parameters to function parameters, fixing #3452.

For that issue's example, it'd show as the following now.

// Before: extractIterableTypeArgument(Iterable iterable, Object? extract()) → Object?
extractIterableTypeArgument(Iterable iterable, Object? extract<T>()) → Object?

@srawlins
Wondering if we should revisit the function format and make it Object? Function<T>() extract instead of Object? extract<T>()? This CL isn't for that, but it wouldn't be too hard to make that change.

  • Renamed some tests in parameter_test.dart because I was itching to do so.
  • The two new tests added are test_formalParameter_generic_method and test_formalParameter_generic_topLevelFunction.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

Copy link
Member

@srawlins srawlins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Nice test refactoring.

@srawlins
Copy link
Member

Wondering if we should revisit the function format and make it Object? Function<T>() extract instead of Object? extract<T>()?

I think I would be in favor of this. I can see supporting one of two designs:

  • Always display the new format.
  • Always display what is in the source code; if they wrote the old school format, support that. There are plenty of cases in the Dart SDK at least that use the old school format, like Future.then. I'm not sure if it's intentional, but if it is 🤷 maybe leave it that way in dartdoc too.

@kallentu
Copy link
Member Author

I'll look into it in my free-time, but if we could, I think maybe it'd be good to display what's in the source code.

I'll make an issue for this.

@kallentu kallentu merged commit 47fe3b6 into main Feb 22, 2024
11 checks passed
@kallentu kallentu deleted the complex-func branch February 22, 2024 18:50
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.

2 participants