Conversation
|
I added : to splittables because in the e2e integration test for closure where there is (callback: |
PR HealthBreaking changes ✔️
This check can be disabled by tagging the PR with Changelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with API leaks ✔️The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.
This check can be disabled by tagging the PR with |
| TokenList fragments, | ||
| ) => _parseTypeExpression(context, symbolgraph, fragments); | ||
|
|
||
| (ReferredType, TokenList) _parseTypeExpression( |
There was a problem hiding this comment.
What's the point of separating parseType and _parseTypeExpression?
| return parselet(context, symbolgraph, token, fragments.slice(1)); | ||
| } | ||
|
|
||
| (ReferredType, TokenList) _parseTypeExpressionUntilArrow( |
There was a problem hiding this comment.
This seems hacky. Ideally types should be self delimiting. That is, I'd expect parseType to already stop when it's done parsing the type. What happens if you just try to use parseType?
| ) { | ||
| if (fragments.isEmpty) return (null, fragments); | ||
|
|
||
| final (isAsync, isThrowing, afterEffects) = _parseClosureModifiers(fragments); |
There was a problem hiding this comment.
This whole chunk violates the parslet design. Why do you need it?
| shouldWrapPrimitives: originalFunction.throws, | ||
| ); | ||
|
|
||
| final (wrapperResult, type) = switch (( |
There was a problem hiding this comment.
Shouldn't all this logic live in maybeWrapValue?
| ); | ||
|
|
||
| final (unwrappedParamValue, unwrappedType) = maybeUnwrapValue( | ||
| final (unwrappedParamValue, unwrappedType) = switch (( |
There was a problem hiding this comment.
Shouldn't all this logic live in maybeUnwrapValue?
| @@ -0,0 +1,21 @@ | |||
| import Foundation | |||
|
|
|||
| public func applyGlobal(callback: (Int) -> Int, value: Int) -> Int { | |||
There was a problem hiding this comment.
This needs way more test cases. You're only testing (Int) -> Int. Also add tests for:
- Zero args
- Multiple args
- Tuple returns
- Void returns
- Non-trivial arg and return types (ie types that themselves need to be transformed)
- nested closures (ie closures that take closures as args, and return closures)
- escaping
- sendable
- async
- throwing
- inout params
- labeled params,
(_ abc: String) -> Int
If any of those are going to be a lot of work to support, still write the test, but comment it out with a TODO. I'll file a bug for any such missing features, and we'll get to it later.
Fixes: #1669
Changes made:
7.Added visitClosureType to AST
9.Added closure effect parsing (for async, throws) using _parseClosureModifiers
Tests added:
2.attributed closures parsing
3.nested,optional closures, empty parameter closures parsing
4.checks closure flag preservation
5.method level closure param and return support
added e2e test
PR Checklist
dart tool/ci.dart --alllocally and resolved all issues identified. This ensures the PR is formatted, has no lint errors, and ran all code generators. This applies to the packages part of the toplevelpubspec.yamlworkspace.CHANGELOG.mdfor the relevant packages. (Not needed for small changes such as doc typos).