mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
- Don't attempt to insert fixes if there are restrictions present, they'd inform the failures. Inserting fixes too early doesn't help the solver because restriction matching logic would record the same fixes. - Adjust impact of the fixes. Optional conversions shouldn't impact the score in any way because they are not the source of the issue. - Look through one level of optional when failure is related to optional injection. The diagnostic is going to be about underlying type, so there is no reason to print optional on right-hand side.
45 lines
1.3 KiB
Swift
45 lines
1.3 KiB
Swift
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5
|
|
// REQUIRES: objc_interop
|
|
// REQUIRES: OS=macosx
|
|
|
|
import SwiftUI
|
|
|
|
enum ColorScheme: CaseIterable, Hashable, Equatable, Identifiable {
|
|
// expected-error@-1 {{type 'ColorScheme' does not conform to protocol 'Identifiable'}}
|
|
// expected-note@-2 {{add stubs for conformance}}
|
|
case `default`
|
|
case pink
|
|
|
|
var foreground: Color {
|
|
switch self {
|
|
case .default:
|
|
return .primary
|
|
case .pink:
|
|
return .pink
|
|
}
|
|
}
|
|
}
|
|
|
|
struct IconPicker : View {
|
|
var body: some View {
|
|
Text("hello")
|
|
}
|
|
}
|
|
|
|
struct CountdownEditor : View {
|
|
@State var symbol: String = "timer"
|
|
@State var selectedColor: ColorScheme = ColorScheme.pink
|
|
|
|
var body: some View {
|
|
NavigationLink(destination: IconPicker()) {
|
|
Text("Icon")
|
|
Spacer()
|
|
Image(systemName: symbol)
|
|
.foregroundColor(selectedColor.color)
|
|
// expected-error@-1 {{cannot convert value of type 'Binding<Subject>' to expected argument type 'Color'}}
|
|
// expected-error@-2 {{referencing subscript 'subscript(dynamicMember:)' requires wrapper 'Binding<ColorScheme>'}}
|
|
// expected-error@-3 {{value of type 'ColorScheme' has no dynamic member 'color' using key path from root type 'ColorScheme'}}
|
|
}
|
|
}
|
|
}
|