mirror of
https://github.com/apple/swift.git
synced 2026-10-20 19:13:47 +02:00
Implicitly unwrapped optionals are rejected as witnesses for optional protocol
requirements. The diagnostics just indicated a generic type mismatch, though.
Additionally, the type of a C declaration that is imported as an IUO is printed
as `Type?` instead of `Type!` in the diagnostic, making the diagnostic look
non-sensical:
```
repro.swift:7:1: error: type 'MyStruct' does not conform to protocol 'MyProtocol'
2 |
3 | protocol MyProtocol {
4 | var pointer: UnsafePointer<UInt64>? { get }
| `- note: protocol requires property 'pointer' with type 'UnsafePointer<UInt64>?'
5 | }
6 |
7 | extension MyStruct: MyProtocol {}
| |- error: type 'MyStruct' does not conform to protocol 'MyProtocol'
| `- note: add stubs for conformance
8 |
/tmp/reproducer/./CStruct.h:4:21: note: candidate has non-matching type 'UnsafePointer<UInt64>?'
2 |
3 | struct MyStruct {
4 | const uint64_t *pointer;
| `- note: candidate has non-matching type 'UnsafePointer<UInt64>?'
5 | };
6 |
```
Diagnose IUO mismatches explicitly and add a fix-it to change the optionality
of the witness to match.
Resolves rdar://186694574.