-
Notifications
You must be signed in to change notification settings - Fork 10.5k
@_implementationOnly: fix over-eager checking for vars in extensions #24629
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3678,7 +3678,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied( | |
conformanceBeingChecked->getLoc(), | ||
diag::conformance_from_implementation_only_module, | ||
rootConformance->getType(), | ||
rootConformance->getProtocol()->getName(), M->getName()); | ||
rootConformance->getProtocol()->getName(), 0, M->getName()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above. |
||
} else { | ||
ctx.Diags.diagnose( | ||
conformanceBeingChecked->getLoc(), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,27 +86,35 @@ public var (testBadTypeTuplePartlyInferred3, testBadTypeTuplePartlyInferred4): ( | |
public var testMultipleBindings1: Int? = nil, testMultipleBindings2: BadStruct? = nil // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} | ||
public var testMultipleBindings3: BadStruct? = nil, testMultipleBindings4: Int? = nil // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} | ||
|
||
extension BadStruct { // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} | ||
public func testExtensionOfBadType() {} // FIXME: Should complain here instead of at the extension decl. | ||
extension BadStruct { // expected-error {{cannot use struct 'BadStruct' in an extension with public or '@usableFromInline' members; 'BADLibrary' has been imported as implementation-only}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent. |
||
public func testExtensionOfBadType() {} | ||
public var testExtensionVarBad: Int { 0 } | ||
public subscript(bad _: Int) -> Int { 0 } | ||
} | ||
extension BadStruct { | ||
func testExtensionOfOkayType() {} | ||
var testExtensionVarOkay: Int { 0 } | ||
subscript(okay _: Int) -> Int { 0 } | ||
} | ||
|
||
extension Array where Element == BadStruct { // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} | ||
public func testExtensionWithBadRequirement() {} // FIXME: Should complain here instead of at the extension decl. | ||
extension Array where Element == BadStruct { // expected-error {{cannot use struct 'BadStruct' in an extension with public or '@usableFromInline' members; 'BADLibrary' has been imported as implementation-only}} | ||
public func testExtensionWithBadRequirement() {} | ||
public var testExtensionVarBad: Int { 0 } | ||
public subscript(bad _: Int) -> Int { 0 } | ||
} | ||
|
||
extension Array where Element == BadStruct { | ||
func testExtensionWithOkayRequirement() {} // okay | ||
var testExtensionVarOkay: Int { 0 } // okay | ||
subscript(okay _: Int) -> Int { 0 } // okay | ||
} | ||
|
||
extension Int: BadProto {} // expected-error {{cannot use protocol 'BadProto' here; 'BADLibrary' has been imported as implementation-only}} | ||
struct TestExtensionConformanceOkay {} | ||
extension TestExtensionConformanceOkay: BadProto {} // okay | ||
|
||
public protocol TestConstrainedExtensionProto {} | ||
extension Array: TestConstrainedExtensionProto where Element == BadStruct { // expected-error {{cannot use struct 'BadStruct' here; 'BADLibrary' has been imported as implementation-only}} | ||
extension Array: TestConstrainedExtensionProto where Element == BadStruct { // expected-error {{cannot use struct 'BadStruct' in an extension with conditional conformances; 'BADLibrary' has been imported as implementation-only}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this be allowed if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't actually allow that right now even though we probably should. |
||
} | ||
|
||
|
||
|
@@ -165,7 +173,7 @@ public class SubclassOfNormalClass: NormalClass {} | |
public func testInheritedConformance(_: NormalProtoAssocHolder<SubclassOfNormalClass>) {} // expected-error {{cannot use conformance of 'NormalClass' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} | ||
public func testSpecializedConformance(_: NormalProtoAssocHolder<GenericStruct<Int>>) {} // expected-error {{cannot use conformance of 'GenericStruct<T>' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} | ||
|
||
extension Array where Element == NormalProtoAssocHolder<NormalStruct> { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' here; 'BADLibrary' has been imported as implementation-only}} | ||
extension Array where Element == NormalProtoAssocHolder<NormalStruct> { // expected-error {{cannot use conformance of 'NormalStruct' to 'NormalProto' in an extension with public or '@usableFromInline' members; 'BADLibrary' has been imported as implementation-only}} | ||
public func testConstrainedExtensionUsingBadConformance() {} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be better to expose the
Reason
enum widely enough to use it here, but I can live with this if you can.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm not sure where it would live. Splitting it into two diagnostics might make more sense, but I think this is okay specifically because it's 0 and the first case and not any of the others.