Files
swift-mirror/validation-test/Sema/SwiftUI/too_complex_source_location.swift
Kathy Gray fde49b8847 Diagnostics : Increase possibility for missed property diagnostic
Impact for an unknown property access was frequently higher than other options
on ambiguous selections, by 3 to 5 points, causing fix selections that were
farther away and frequently noted to be in accurate. This commit lowers the
impact to be in a similar range to other fixes and this causes property accesses
to be selected more proprotionaly.

In the existing test suite, this changed the diagnostic only in the case of
protocol composition, which was also discovered to be a flawed binding lookup.

Tests added for the property lookup, tests updated for protocol composition
(Including correcting a likely error in a test specification)
2025-12-11 16:08:22 +00:00

48 lines
1.4 KiB
Swift

// RUN: %target-typecheck-verify-swift -verify-ignore-unrelated -target %target-cpu-apple-macosx10.15 -swift-version 5
// REQUIRES: objc_interop
// REQUIRES: OS=macosx
// https://forums.swift.org/t/roadmap-for-improving-the-type-checker/82952/9
//
// The purpose of the test is to ensure the diagnostic points at the right statement in
// the function body, and not the function declaration itself.
//
// Ideally, we would produce a useful diagnostic here. Once we are able to do that, we
// will need to devise a new test which complains with 'reasonable time' to ensure the
// source location remains correct.
import SwiftUI
struct ContentView: View {
@State var selection = ""
@State var a: Int?
@State var b: Int?
@State var c: Int?
var body: some View {
ScrollView {
VStack {
VStack {
Picker(selection: $selection) {
ForEach(["a", "b", "c"], id: \.self) {
Text($0) // expected-error {{ reasonable time}}
.foregroundStyl(.red) // Typo is here
}
} label: {
}
.pickerStyle(.segmented)
}
.padding(.vertical)
}
.padding(.horizontal)
}
.onChange(of: a) { oldValue, newValue in
}
.onChange(of: b) { oldValue, newValue in
}
.onChange(of: c) { oldValue, newValue in
}
}
}