Skip to content

Conversation

rjmccall
Copy link
Contributor

@rjmccall rjmccall commented Mar 16, 2023

Before I get too much deeper into variadic reabstraction, I wanted to take the opportunity to rework the APIs I've been using for doing these walks over abstraction patterns with expansions, because I'm about to use them a lot more. This centralizes the basic logic for doing parallel walking over expanded tuples and function parameter lists and makes the resulting code in different subsystems at least a little bit clearer. It's definitely more successful at improving the tuple code than it is for calls, though: self really makes things complicated, and the argument code tends to gather argument types from a lot of disparate places rather than passing in substituted types.

This also includes fixes to mapPackTypeIntoElementContext and mapContextualPackTypeIntoElementContext.

opened generic environments

Finding these is very hot for these environments, so doing it once
is a pretty nice win in both speed and code complexity.

I'm not actually using this yet.
First, we need this to work on both lowered and unlowered types,
so Type::subst is problematic: it'll assert if it sees a type
like SILFunctionType.  In this case, the substitution is simple
enough that that's never a problem, but Type::subst doesn't know
that, and the assertion is generally a good one.

Second, we need this to not recurse into nested pack expansions.

Third, we need this to not mess around with any existing element
archetypes we might see in the type, so mapping in and out of
context is not really okay.

Fortunately, because we're mapping between structures (pack and
element archetypes) that are guaranteed to have the same
constraints, this transformation is really easy and we can just
do it with transformRec.
As I've been iterating on this work, I've been gradually mulling these
over, and I think this is the way to go for now.  These should make it
a lot less cumbersome to write these kinds of traversals correctly.

The intent is to the sunset the existing expanded-components stuff
after I do a similar pass for function parameters.
@rjmccall
Copy link
Contributor Author

@swift-ci Please smoke test

@rjmccall rjmccall merged commit 531dd3a into swiftlang:main Mar 16, 2023
@rjmccall rjmccall deleted the silgen-variadic-abstraction-changes branch March 16, 2023 16:31
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.

1 participant