Skip to content

Small constraint solver cleanups #18970

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
Aug 25, 2018
Merged

Conversation

slavapestov
Copy link
Contributor

A few NFC parts of my work to move the constraint solver over to the new function type representation.

We don't get default arguments or varargs here anymore.
There can't actually be GenericFunctionTypes in the constraint system itself.
@slavapestov slavapestov requested a review from rudkx August 24, 2018 23:56
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

// FIXME: This should be revisited. If one of argTy or paramTy
// is a type variable, matchTypes() will add a constraint, and
// when the constraint is later solved, we will have lost the
// value of 'subflags'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we really need to fix this at some point...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be best to just try removing this sub flag altogether, instead of recovering it from the locator or whatever.

@@ -5200,51 +5172,6 @@ Expr *ExprRewriter::coerceTupleToTuple(Expr *expr, TupleType *fromTuple,
fromElt.getWithType(cs.getType(convertedElt));
}

// Convert all of the variadic arguments to the destination type.
ArraySliceType *arrayType = nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just for my own understanding what to double-check - this is dead-code now because parameters in the function type is represented as an array of Param objects and regular tuples can't have variadics, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was dead even before that. This code path is never taken for function arguments. It is only used when we convert a value of tuple type to another tuple type. Applying the solution to call arguments happens in coerceCallArguments() (which uses Params now, but even before that, it was separate because the rules for call arguments are different from tuple values).

What makes this confusing is that both call arguments and tuple conversions use a TupleShuffleExpr, which supports the union of the transformations needed in both cases. Once all this redundant code is gone it will be easier to split up TupleShuffleExpr into two separate Exprs with very little overlap between them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And yes, at the end of all of this, “variadic tuples” and tuples with inouts will no longer be a thing, but it will take us a while to get there. I’ve been mostly focusing on places where we build the old representation; there are more spots where we take it apart, by calling getInput().

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thank you!

@slavapestov slavapestov merged commit ecd25a7 into swiftlang:master Aug 25, 2018
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.

3 participants