Skip to content

Conversation

@rjmccall
Copy link
Contributor

Much like #25221, this is just checking in a preliminary version of the feature to make subsequent development easier.

@rjmccall
Copy link
Contributor Author

@swift-ci Please smoke test.

rintaro and others added 29 commits June 12, 2019 11:32
for 'VarDecl' or if we don't know the kind of the decl.
Property delegate allows arbitrary type name (with `@propertyDelegate`
attr).
Includes code anticipating property delegates in part because it's
been largely stolen from Doug's PR for that.
Turn the generic CustomAttrTypeRequest into a helper function and
introduce a FunctionBuilderTypeRequest that starts from a ParamDecl.
This has better caching characteristics and also means we only need to
do a single cache lookup in order to resolve the type in the normal path.
It also means we don't need as much parameterization in the cache.

In addition, check that the parameter has function type in the request,
not just when late-checking the attribute, and add a check that it isn't
an autoclosure.
Provide a place where we can capture more information about the parameters
from a declaration being called.
When calling a function whose parameter specifies a function builder
with a multi-statement closure argument, transform the closure into
a single expression via the function builder. Should the result
type checker, replace the closure body with the single expression.
If a function builder contains a buildIf function, then "if" statements
will be supported by passing an optional of the "then" branch.
"if" statements with an "else" statement are unsupported at present.
Use the opened type from the callee declaration to open up references to
generic function builders that contain type parameters. This allows general
use of generic function builders.
Make sure we don't suggest any builtin attributes, but only custom type
names.

rdar://problem/50074177
Since we short-circuit in the function builder application when we
hit something we cannot translate, relying on that visitor to
detect 'return' statements (which disable the application) is bogus.
Use a separate, earlier visitor to find 'return' statements consistently.

Fixes rdar://problem/50266341.
A substantial amount of this patch goes towards trying to get at least
minimal diagnostics working, since of course I messed up the rule a few
times when implementing this.

rdar://50149837
…olving.

When we perform constraint generation while solving, capture the
type mappings we generate as part of the solver scope and solutions,
rolling them back and replaying them as necessary. Otherwise, we’ll
end up with uses of stale type variables, expression/parameter/type-loc
types set twice, etc.

Fixes rdar://problem/50390449 and rdar://problem/50150314.
rjmccall and others added 8 commits June 12, 2019 11:33
Merging partial solutions can end up assigning the same type to a
particular typed node (expression, parameter, etc.), which can lead to
unbalanced set/clear when exploring the solution space (and later on,
crashes). Don't re-insert such information.

This is the same approach taken for type variable bindings, but it's
all pretty unfortunate: partial solutions should only record
information relative to their part of the constraint system, which
would save time and memory during solving. Howver, that's too big a
change for right now.

Fixes rdar://problem/50853028.
The implicit TypeExprs for function builders were getting inconsistently set
types, which would sometimes be the metatype and sometimes not be the
metatype, leading to a crash in the new test code.
@rjmccall rjmccall force-pushed the function-builders-5.1 branch from 79bef8d to 2675608 Compare June 12, 2019 18:33
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 79bef8d7eab90532ee40188da4e4b38f73c5762e

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 79bef8d7eab90532ee40188da4e4b38f73c5762e

@rjmccall rjmccall force-pushed the function-builders-5.1 branch from df669ef to a96e93a Compare June 12, 2019 20:44
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - df669ef7e3d1b2e5fb07d3e81db028eb5ee970f3

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - df669ef7e3d1b2e5fb07d3e81db028eb5ee970f3

@rjmccall rjmccall force-pushed the function-builders-5.1 branch from a96e93a to bcda358 Compare June 12, 2019 21:33
@rjmccall rjmccall force-pushed the function-builders-5.1 branch from bcda358 to 9c8be4c Compare June 12, 2019 21:34
@rjmccall
Copy link
Contributor Author

@swift-ci Please test.

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - a96e93af4f2cb09ca322294c1f8612a7ba8fe352

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - a96e93af4f2cb09ca322294c1f8612a7ba8fe352

@rjmccall
Copy link
Contributor Author

@swift-ci Please test OS X.

@DougGregor DougGregor merged commit f7331dd into swiftlang:swift-5.1-branch Jun 13, 2019
@rjmccall rjmccall deleted the function-builders-5.1 branch June 13, 2019 00:40
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.

4 participants