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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3795,10 +3795,7 @@ static void recordConformanceDependency(DeclContext *DC,
Conformance->getDeclContext()->getParentModule())
return;

// FIXME: 'deinit' is being used as a dummy identifier here. Really we
// 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.

DC->isCascadingContextForLookup(InExpression));
}

Expand Down
3 changes: 2 additions & 1 deletion test/Incremental/single-file/AnyObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Foundation
// expected-private-conformance {{Swift.CustomDebugStringConvertible}}
// expected-private-conformance {{Swift.CVarArg}}
// expected-private-conformance {{Swift.CustomStringConvertible}}
// expected-cascading-superclass {{main.LookupFactory}}
@objc private class LookupFactory: NSObject {
// expected-provides {{AssignmentPrecedence}}
// expected-provides {{IntegerLiteralType}}
Expand All @@ -29,7 +30,7 @@ import Foundation

// expected-cascading-member {{__C.NSObject.init}}
// expected-cascading-member {{main.LookupFactory.init}}
// expected-cascading-member {{main.LookupFactory.deinit}}
// expected-private-member {{main.LookupFactory.deinit}}
// expected-cascading-member {{main.LookupFactory.someMember}}
// expected-cascading-member {{main.LookupFactory.someMethod}}
}
Expand Down
5 changes: 2 additions & 3 deletions test/Incremental/single-file/Conformances.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private protocol PrivateProtocol { } // expected-provides {{PrivateProtocol}}
public struct PublicConformance { } // expected-provides {{PublicConformance}}
// expected-cascading-member {{main.PublicConformance.init}}

// expected-cascading-member {{main.PublicConformance.deinit}}
// expected-cascading-conformance {{main.PublicConformance}}
extension PublicConformance: PublicProtocol { }
extension PublicConformance: InternalProtocol { }
extension PublicConformance: FilePrivateProtocol { }
Expand All @@ -20,8 +20,7 @@ extension PublicConformance: PrivateProtocol { }
private struct PrivateConformance { } // expected-provides {{PrivateConformance}}
// expected-cascading-member {{main.PrivateConformance.init}}

// FIXME: This could be a private dependency...
// expected-cascading-member {{main.PrivateConformance.deinit}}
// expected-cascading-conformance {{main.PrivateConformance}}
extension PrivateConformance: PublicProtocol { } // expected-cascading-conformance {{main.PublicProtocol}}
extension PrivateConformance: InternalProtocol { } // expected-cascading-conformance {{main.InternalProtocol}}
extension PrivateConformance: FilePrivateProtocol { } // expected-cascading-conformance {{main.FilePrivateProtocol}}
Expand Down
7 changes: 3 additions & 4 deletions test/NameBinding/reference-dependencies-fine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -464,21 +464,20 @@ struct Sentinel2 {}


// CHECK-MEMBER-DAG: member interface 4main10IntWrapperV Int false
// CHECK-MEMBER-DAG: member interface 4main10IntWrapperV deinit false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface SL '' false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface 4main18ClassFromOtherFileC '' false
// CHECK-MEMBER-DAG: member interface Si max false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface s25ExpressibleByFloatLiteralP '' false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface s33ExpressibleByUnicodeScalarLiteralP '' false
// CHECK-MEMBER-DAG: member interface Sx Stride false
// CHECK-MEMBER-DAG: member interface Sa reduce false
// CHECK-MEMBER-DAG: member interface 4main17OtherFileIntArrayV deinit false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface 4main17OtherFileIntArrayV '' false
// CHECK-MEMBER-DAG: member interface 4main18OtherFileOuterTypeV InnerType false
// CHECK-MEMBER-DAG: member interface 4main18OtherFileOuterTypeV05InnerE0V init false
// CHECK-MEMBER-DAG: member interface 4main18OtherFileOuterTypeV05InnerE0V sharedConstant false
// CHECK-MEMBER-DAG: member interface 4main26OtherFileSecretTypeWrapperV0dE0V constant false
// CHECK-MEMBER-DAG: member interface 4main25OtherFileProtoImplementorV deinit false
// CHECK-MEMBER-DAG: member interface 4main26OtherFileProtoImplementor2V deinit false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface 4main25OtherFileProtoImplementorV '' false
// CHECK-POTENTIALMEMBER-DAG: potentialMember interface 4main26OtherFileProtoImplementor2V '' false
// CHECK-MEMBER-DAG: member interface s15EmptyCollectionV8IteratorV init false
// CHECK-MEMBER-DAG: member interface 4main13OtherFileEnumO Value false
// CHECK-MEMBER-DAG: member interface 4main20OtherFileEnumWrapperV Enum false
Expand Down
2 changes: 1 addition & 1 deletion test/NameBinding/reference-dependencies-members-fine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protocol SomeProto {}
// PROVIDES-NOMINAL-DAG: nominal implementation 4main10OtherClassC '' true
// PROVIDES-NOMINAL-2-DAG: nominal interface 4main10OtherClassC '' true
// PROVIDES-MEMBER-DAG: potentialMember interface 4main10OtherClassC '' true
// DEPENDS-MEMBER-DAG: member interface 4main10OtherClassC deinit false
// DEPENDS-MEMBER-DAG: potentialMember interface 4main10OtherClassC '' true
extension OtherClass : SomeProto {}

// PROVIDES-NOMINAL-DAG: nominal implementation 4main11OtherStructV '' true
Expand Down
2 changes: 1 addition & 1 deletion test/NameBinding/reference-dependencies-members.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protocol SomeProto {}
// DEPENDS-NOMINAL-DAG: 10OtherClassC"
// DEPENDS-NOMINAL-DAG: 9SomeProtoP"
// DEPENDS-MEMBER-DAG: - ["{{.+}}9SomeProtoP", ""]
// DEPENDS-MEMBER-DAG: - ["{{.+}}10OtherClassC", "deinit"]
// DEPENDS-MEMBER-DAG: - ["{{.+}}10OtherClassC", ""]
extension OtherClass : SomeProto {}

// PROVIDES-NOMINAL-NEGATIVE-NOT: 11OtherStructV"{{$}}
Expand Down