-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Issue-60730: Addressing the situation where we were saying that (any … #61191
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
a2d1ef6
6222099
81c3b3c
41cbed8
d5463c8
54d99aa
c34e5c2
7697e87
66c2284
c053448
f4c2027
d4e2cb7
4e92152
f8c6cbc
9f9770e
0488fe0
6811590
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 |
---|---|---|
|
@@ -565,3 +565,27 @@ func testFunctionContainerMethodCall(container: FunctionContainer?) { | |
// expected-note@-3 {{coalesce}} | ||
// expected-note@-4 {{force-unwrap}} | ||
} | ||
|
||
// Test for https://github.com/apple/swift/issues/60730 | ||
// rdar://94037733 | ||
do { | ||
struct S: P {} | ||
func takesP(_: any P) {} | ||
func passOptional(value: (any P)?) { | ||
takesP(value) | ||
// expected-error@-1 {{value of optional type '(any P)?' must be unwrapped to a value of type 'any P'}} | ||
// expected-note@-2 {{coalesce using '??' to provide a default when the optional value contains 'nil'}} | ||
// expected-note@-3 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} | ||
} | ||
xedin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func passLayersOfOptional(value: (any P)??) { | ||
// FIXME(diagnostics): Consider recording multiple ForceUnwrap fixes based on number of optionals | ||
takesP(value) | ||
// expected-error@-1 {{value of optional type '(any P)??' must be unwrapped to a value of type '(any P)?}} | ||
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. Hm, this is not great... Could you please leave a 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. Where do I add the "FIXME"? As a comment above the takesP() call? 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. Yes, that's good enough. |
||
// expected-note@-2 {{coalesce using '??' to provide a default when the optional value contains 'nil'}} | ||
// expected-note@-3 {{force-unwrap using '!' to abort execution if the optional value contains 'nil'}} | ||
} | ||
func passNonConformingValue(value: (any BinaryInteger)?){ | ||
takesP(value) | ||
// expected-error@-1 {{argument type '(any BinaryInteger)?' does not conform to expected type 'P'}} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.