Skip to content

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Jun 3, 2016

What's in this pull request?

Lookup can occasionally produce a call to a superclass constructor here that is not in our immediate superclass and we would trust it was completely valid. Instead, following the idea @slavapestov had, we reject the notion of creating such a constructor entirely unless its decl can prove it is actually in our superclass.

Thanks to @jrose-apple for the logic behind this patch and for sticking with me during our discussions about this.

Resolved bug number: (SR-1571)


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
All supported platforms @swift-ci Please smoke test and merge
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
All supported platforms @swift-ci Please test and merge
OS X platform @swift-ci Please test OS X platform
OS X platform @swift-ci Please benchmark
Linux platform @swift-ci Please test Linux platform

Lint Testing

Language Comment
Python @swift-ci Please Python lint

Note: Only members of the Apple organization can trigger swift-ci.

// or an extension. We can use the type declared in that context to check
// if it's our immediate superclass and give up if we didn't.
//
// FIXME: Remove this when lookup of initializers becomes restricted to our
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good but it would be even better to address the FIXME too -- do you want to file a bug for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even better, I can provide a patch. @jrose-apple discussed the idea of plumbing NL_VisitSupertypes through as a proper part of NameLookupOptions and using it to affect lookupConstructors.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, thanks!

Although I think in this case, the problem is that piece of code we saw in NameLookup which checks if the found name was a protocol requirement, and looks up the witness -- I think this needs a special case where if the witness is a constructor, we skip it (since we would have found it otherwise I think)?

Copy link
Contributor Author

@CodaFi CodaFi Jun 3, 2016

Choose a reason for hiding this comment

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

But I'd like to do that in a different pull request. When I tried something like this before I have bad memories of breaking more tests than just this one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright, sounds good!

When you do the cleanup, I think it will suffice to verify that the existing tests pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this needs a special case where if the witness is a constructor, we skip it (since we would have found it otherwise I think)?

The witness is the initializer in A and we're back to square one. Or, if I special-case this, I can't see where the super call actually goes, so I'm stuck on top of breaking any initializers in extensions that return Self et al. like RawRepresentable.

Copy link
Contributor

Choose a reason for hiding this comment

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

By 'witness' I mean the implementation of the protocol requirement in the special code path, not the lookup result in general.

Let's discuss this in person tomorrow.

Copy link
Contributor

@jrose-apple jrose-apple Jun 3, 2016

Choose a reason for hiding this comment

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

My particular concern is whether we expect to find convenience initializers from extensions of protocols adopted by immediate or non-immediate superclasses.

Copy link
Contributor

Choose a reason for hiding this comment

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

We also talked about whether it ever makes sense to find initializers that aren't immediately on a type or its immediate protocols, but that's potentially a much more disruptive change.

@slavapestov
Copy link
Contributor

@swift-ci Please test

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Linux failure looks unrelated.

@jrose-apple
Copy link
Contributor

Let's get it clean anyway.

@swift-ci Please test Linux platform

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Still failing. Looks like it's @bitjammer's?

@slavapestov
Copy link
Contributor

I pushed a fix for that just now

@slavapestov
Copy link
Contributor

@swift-ci Please test and merge

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Still failing in the same test file.

@bitjammer
Copy link
Contributor

It looks like the Test and Merge job doesn't have the fix. Might need to run it again.

@jrose-apple
Copy link
Contributor

@swift-ci Please test and merge

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Same place, same failure unfortunately.

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

@jrose-apple If it helps, I can rebase onto the new changes and see if that helps.

@CodaFi CodaFi force-pushed the invalid-init-picks branch from 9012ecc to 9636752 Compare June 3, 2016 23:05
@harlanhaskins
Copy link
Contributor

@swift-ci please test

@CodaFi CodaFi force-pushed the invalid-init-picks branch from 9636752 to 9012ecc Compare June 3, 2016 23:07
@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

I have a feeling this and the problems we've been having with #2854 are github bugs. Seems like it's seeing the rebase pushes as similar enough to the old changes that it squashes them together and reports the old CI results instead of the new ones.

@CodaFi
Copy link
Contributor Author

CodaFi commented Jun 3, 2016

Here is the real linux build for this pull request.

@jrose-apple
Copy link
Contributor

All right, everything's passing on master, and this test really shouldn't change anything. I'm going to merge it.

@jrose-apple jrose-apple merged commit 8f3031d into swiftlang:master Jun 4, 2016
@jrose-apple
Copy link
Contributor

In the future, please provide a bit more information in your commit message, so that people don't have to go look up the bug to see what's being fixed. (In this case I copy/pasted your description as the commit message.)

Thanks, Robert!

@CodaFi CodaFi deleted the invalid-init-picks branch June 4, 2016 07:54
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.

5 participants