Skip to content

Sundry Sema fixes #4042

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
Aug 5, 2016
Merged

Sundry Sema fixes #4042

merged 4 commits into from
Aug 5, 2016

Conversation

slavapestov
Copy link
Contributor

No description provided.

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@jrose-apple
Copy link
Contributor

I'm not convinced the second change is an improvement. It's sometimes better than no result, but other times we end up with even stranger diagnostics. I'd hold off on it for now.

@slavapestov
Copy link
Contributor Author

Sorry which change? The "invalid pattern" diagnostic change isn't quite done -- I do want to clean up that spew of crap in the existing test before I check it in.

@jrose-apple
Copy link
Contributor

The name-lookup-filtering change. I think it needs a little more consideration to decide if it really makes sense, given the changes in diagnostics.

@slavapestov
Copy link
Contributor Author

@jrose-apple I think the diagnostics get better -- instead of "cannot find 'foo'" it says "cannot call type member on instance". Also, having a special case just for methods (and not properties, etc) seemed a little odd.

…stance/static context

We do this in a more general way higher up in the constraint
solver. Filtering out methods in name lookup only hurts
diagnostics.

In fact I don't think this behavior was intentional at all,
since the code in question was originally written in 2013
before a lot of the more recent member lookup and diagnostic
code was added.

This does break source compatibility though, but in a minor
way. See the change to the CoreGraphics overlay. Again,
though, I think this was an accident and not intentional.
Suggest a fix-it for unqualified references to all static members
from instance context, not just enum elements.

Also, fix a small problem with the fix-it for replacing protocol
names with 'Self' inside extension bodies -- we didn't handle nested
functions properly.
The problem here is that we would just emit 'invalid pattern'
instead of digging deeper, which meant that the fix-it for
qualified enum element access wasn't getting inserted for
more complex patterns, such as 'case X(let x)'.

Unfortunately, in the matching_patterns.swift test, we emit
too many diagnostics that are not really useful to figuring
out the problem, and the old 'invalid pattern' made more
sense. I'll work on some CSDiag tweaks to address this --
I think it makes more sense to dig there than just emit a
general 'invalid pattern' diagnostic anyway.

Fixes <rdar://problem/27684266>.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test and merge

@@ -96,7 +96,8 @@ private enum Bar<T> {

mutating func value() -> T {
switch self {
case E(let x): // expected-error{{invalid pattern}}
// FIXME: Should diagnose here that '.' needs to be inserted, but E has an ErrorType at this point
case E(let x):
Copy link
Contributor

Choose a reason for hiding this comment

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

We do have to emit some error here, or SILGen will crash.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, but if it only happens on error cases then we're fine. I see.

@jrose-apple
Copy link
Contributor

Slava convinced me in person that the changes for static members are net good, and certainly more consistent.

@swift-ci swift-ci merged commit 2af662b into swiftlang:master Aug 5, 2016
@slavapestov slavapestov deleted the sundry-sema-fixes branch August 19, 2016 05:21
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