Skip to content

[Sema] Highlight angle brackets <…> in diagnostics #781

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 4 commits into from
Jan 12, 2016

Conversation

JaSpa
Copy link
Contributor

@JaSpa JaSpa commented Dec 26, 2015

Move the checks for invalid generic arguments into applyGenericTypeReprArgs so we can pass the GenericIdentTypeRepr into it to access the angle bracket range while resolveDictionaryType can still use applyUnboundGenericArguments without an GenericIdentTypeRepr.

Edit: check-swift passed

Provide fixit hints for ungeneric but
specialized types (e.g. Int<Float>).
Solves FIXME
Highlight the angle brackets on under- and overspecialized types.
(E.g. Array<Int, Float> and Dictionary<Int>)
Solves FIXME
MutableArrayRef<TypeLoc> genericArgs,
bool isGenericSignature,
GenericTypeResolver *resolver);
Type applyUnboundGenericArguments(UnboundGenericType *unbound,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it ok to pass an UnboundGenericType or should it be wrapped inside a Type value?

With the previous commit the emitted diagnostics couldn't be easily
emitted through the public API.
This commit solves this problem by providing two different versions
of `applyGenericArguments`, one emitting diagnostics, the other
expecting valid parameters.
@JaSpa
Copy link
Contributor Author

JaSpa commented Jan 6, 2016

@DougGregor would you mind taking a look?

bool isGenericSignature,
GenericTypeResolver *resolver);

/// Apply generic arguments to the given type.
///
/// This functions requires a valid unbound generic type with the correct
Copy link
Contributor

Choose a reason for hiding this comment

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

function

@JaSpa JaSpa force-pushed the highlight-generic-args branch from b0e075d to 7822c92 Compare January 7, 2016 12:49
@DougGregor
Copy link
Member

I'd usually grumble about trailing whitespace changes, but it's fine; we should clean those up anyway. Thanks!

@DougGregor
Copy link
Member

Oh, I suspect this means that Sema could properly distinguish between "X<>" and "X" now, perhaps with some minor parser tweaks.

DougGregor added a commit that referenced this pull request Jan 12, 2016
[Sema] Highlight angle brackets <…> in diagnostics
@DougGregor DougGregor merged commit 1915b06 into swiftlang:master Jan 12, 2016
@JaSpa JaSpa deleted the highlight-generic-args branch January 12, 2016 23:12
@JaSpa JaSpa mentioned this pull request Jan 14, 2016
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