Skip to content

[Constraint solver] Shore up "common return type" optimization. #9494

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

Merged
merged 3 commits into from
May 11, 2017

Conversation

DougGregor
Copy link
Member

The "common return type" optimization that occurs at
constraint-generation time was overly complicated and wrong in a
couple of places. Fix up these issues:

  • Don't cache information about this optimization in the decls
    themselves; it ignores visibility as well as invalidation that
    occurs in script mode and playgrounds. Just do the the work again
  • Don't map type into context; we can bail out when there are type
    parameters present
  • Skip the "self" parameters of operators in types (since this only
    ever occurs for operators).

Longer term, this optimization should move into the solver itself. But
for now, at least it's cleaner/more correct.

The "common return type" optimization that occurs at
constraint-generation time was overly complicated and wrong in a
couple of places. Fix up these issues:

* Don't cache information about this optimization in the decls
  themselves; it ignores visibility as well as invalidation that
  occurs in script mode and playgrounds. Just do the the work again
* Don't map type into context; we can bail out when there are type
  parameters present
* Skip the "self" parameters of operators in types (since this only
  ever occurs for operators).

Longer term, this optimization should move into the solver itself. But
for now, at least it's cleaner/more correct.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor DougGregor force-pushed the common-return-type-cleanup branch from a0403ee to d98ae72 Compare May 11, 2017 14:53
@DougGregor
Copy link
Member Author

It's gonna fail. Sigh

@DougGregor
Copy link
Member Author

@swift-ci please smoke test

@DougGregor
Copy link
Member Author

Second commit fixed some crashers.

…cker.

When errors occur in the processing of expressions, we can end up with
invalid ASTs where the application of an operator declared within a
type is missing its "self" argument. Tolerate such ASTs in the
error-handling checker.
The "skip generic operators" heuristic within the constraint solver is
fairly awful, because it is known to miss reasonable solutions. Make
is slightly more narrow by only skipping generic operators when the
concrete operator we found was symmetric.
@DougGregor DougGregor force-pushed the common-return-type-cleanup branch from d98ae72 to badffdc Compare May 11, 2017 15:57
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit cd61cf6 into swiftlang:master May 11, 2017
@DougGregor DougGregor deleted the common-return-type-cleanup branch May 11, 2017 16:58
@DougGregor
Copy link
Member Author

@rudkx and @xedin might be interested in this

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