Skip to content

Register Conformances as Potential Member Constraints #30585

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 1 commit into from
Mar 23, 2020

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Mar 23, 2020

Unwind a hack whose stated purpose was to register a potential member
edge from an extension to the extended type. In reality, this only
registered a plain member dependency on 'deinit'. This edge is
insufficient in isolation to cause a rebuild of a dependent file in the
case where a type and its extension live in separate files. However, we
appear to have been saved by the redundancy in edge registration because the
lookup for the extended type will register a top-level or nominal
dependency (for an unqualified or qualified reference respectively). The
worry there is if a protocol conformance should flip a previously
private nominal dependency edge to a cascading edge. In such a case, the
old code would not have been able to make the cascading edge promotion,
and we would have potentially miscompiled by not rescheduling dependent
jobs.

Unwind a hack whose stated purpose was to register a potential member
edge from an extension to the extended type. In reality, this only
registered a plain member dependency on 'deinit'. This edge is
insufficient in isolation to cause a rebuild of a dependent file in the
case where a type and its extension live in separate files. However, we
appear to have been saved by the redundancy in edge registration because the
lookup for the extended type will register a top-level or nominal
dependency (for an unqualified or qualified reference respectively). The
worry there is if a protocol conformance edge *should* flip a previously
private nominal dependency edge to a cascading edge. In such a case, the
old code would not have been able to make the cascading edge promotion,
and we would have potentially miscompiled by not rescheduling dependent
jobs.
@CodaFi CodaFi requested a review from davidungar March 23, 2020 18:21
@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 23, 2020

@swift-ci test

@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 23, 2020

This whole debacle strongly suggests we should consider adding explicit dependency types for protocol conformances and extensions.

@CodaFi CodaFi requested a review from slavapestov March 23, 2020 20:26
Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

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

I'm not terribly qualified to review this PR; while git blame turns up my commit as responsible for recordConformanceDependency(), if you look closely you'll see I was just moving some existing code around when I introduced it.

Copy link
Contributor

@davidungar davidungar left a comment

Choose a reason for hiding this comment

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

Looks OK to me. There's one place where an added comment might be nice.

// don't care about /any/ of the type's members, only that it conforms to
// the protocol.
tracker->addUsedMember({Adoptee, DeclBaseName::createDestructor()},
tracker->addUsedMember({Adoptee, Identifier()},
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to see a comment here explaining why the potentialMember dep is needed.

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'll tag you as a reviewer for a follow-up.

@CodaFi
Copy link
Contributor Author

CodaFi commented Mar 23, 2020

⛵️

@CodaFi CodaFi merged commit 89b8163 into swiftlang:master Mar 23, 2020
@CodaFi CodaFi deleted the untapped-potential branch March 23, 2020 21:34
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