AoC PR: Automatic select t.0
/t.1
,... instead of t.values.0
, t.values.1
, ...
#2392
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This simplifies the code to access the elements of, e.g., a tuple where it is not possible to write
t.2
instead oft.values.2
.This syntax sugar comes with the following restrictions:
it is only applicable to types declared in library features
the result type of the feature must be an open type parameter
there must not be any function arguments in the call
there must be exactly one such feature visible
For this, I also had to fix type inference from actual args in case actuals get replaced.
This fixes a bug that was revealed by automatically calling features with open type parameters (eg., t.0 instead of t.values.0 in tuples): When the actual expression gets replaced by something else, the type inference still used the original expression resulting in potentially wrong types being inferred.
This patch no longer stores the actual argument that was found, but instead stores the call that was found. To determine the actual type, the actual is taken form the call resulting in the new actual in case it was replaced during resolveTypes or syntax sugar phases.
This also cleans up the somewhat clumsy check to prevent infinite recursion and uses a simple flag instead.