Skip to content

Commit 2c7f5e4

Browse files
author
Benjamin Driscoll
committed
Allow more error message regressions for opaque types
1 parent 20e1dea commit 2c7f5e4

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

test/Constraints/result_builder_diags.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,12 @@ wrapperifyInfer(true) { x in // expected-error{{unable to infer type of a closur
629629
struct DoesNotConform {}
630630

631631
struct MyView {
632-
// FIXME [OPAQUE SUPPORT]: this is a big regression in error message clarity
632+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
633633
@TupleBuilder var value: some P { // expected-note{{where 'τ_0_0' = 'DoesNotConform'}}
634634
DoesNotConform()
635635
} // expected-error{{getter '_' requires that 'DoesNotConform' conform to 'P'}}
636636

637-
// FIXME [OPAQUE SUPPORT]: this is a big regression in error message clarity
637+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
638638
@TupleBuilder func test() -> some P { // expected-note{{where 'τ_0_0' = 'DoesNotConform'}}
639639
DoesNotConform()
640640
} // expected-error{{instance method 'test()' requires that 'DoesNotConform' conform to 'P'}}
@@ -665,7 +665,7 @@ struct MyView {
665665
}
666666
}
667667

668-
// FIXME [OPAQUE SUPPORT]: this is a big regression in error message clarity
668+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
669669
@TupleBuilder var invalidConversion: Int {
670670
""
671671
} // expected-error {{cannot convert return expression of type 'String' to return type 'Int'}}

test/type/opaque.swift

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ func recursion(x: Int) -> some P {
223223

224224
func noReturnStmts() -> some P {} // expected-error {{function declares an opaque return type, but has no return statements in its body from which to infer an underlying type}} {{educational-notes=opaque-type-inference}}
225225

226-
func returnUninhabited() -> some P { // expected-note {{opaque return type declared here}}
227-
fatalError() // expected-error{{return type of global function 'returnUninhabited()' requires that 'Never' conform to 'P'}}
226+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
227+
func returnUninhabited() -> some P { // expected-note {{where 'τ_0_0' = 'Never'}}
228+
fatalError() // expected-error{{global function 'returnUninhabited()' requires that 'Never' conform to 'P'}}
228229
}
229230

230231
func mismatchedReturnTypes(_ x: Bool, _ y: Int, _ z: String) -> some P { // expected-error{{do not have matching underlying types}} {{educational-notes=opaque-type-inference}}
@@ -359,34 +360,40 @@ struct RedeclarationTest {
359360

360361
func diagnose_requirement_failures() {
361362
struct S {
362-
var foo: some P { return S() } // expected-note {{declared here}}
363-
// expected-error@-1 {{return type of property 'foo' requires that 'S' conform to 'P'}}
363+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
364+
var foo: some P { return S() } // expected-note {{where 'τ_0_0' = 'S'}}
365+
// expected-error@-1 {{getter '_' requires that 'S' conform to 'P'}}
364366

365-
subscript(_: Int) -> some P { // expected-note {{declared here}}
367+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
368+
subscript(_: Int) -> some P { // expected-note {{where 'τ_0_0' = 'S'}}
366369
return S()
367-
// expected-error@-1 {{return type of subscript 'subscript(_:)' requires that 'S' conform to 'P'}}
370+
// expected-error@-1 {{getter '_' requires that 'S' conform to 'P'}}
368371
}
369372

370-
func bar() -> some P { // expected-note {{declared here}}
373+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
374+
func bar() -> some P { // expected-note {{where 'τ_0_0' = 'S'}}
371375
return S()
372-
// expected-error@-1 {{return type of instance method 'bar()' requires that 'S' conform to 'P'}}
376+
// expected-error@-1 {{instance method 'bar()' requires that 'S' conform to 'P'}}
373377
}
374378

375-
static func baz(x: String) -> some P { // expected-note {{declared here}}
379+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
380+
static func baz(x: String) -> some P { // expected-note {{where 'τ_0_0' = 'S'}}
376381
return S()
377-
// expected-error@-1 {{return type of static method 'baz(x:)' requires that 'S' conform to 'P'}}
382+
// expected-error@-1 {{static method 'baz(x:)' requires that 'S' conform to 'P'}}
378383
}
379384
}
380385

381-
func fn() -> some P { // expected-note {{declared here}}
386+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
387+
func fn() -> some P { // expected-note {{where 'τ_0_0' = 'S'}}
382388
return S()
383-
// expected-error@-1 {{return type of local function 'fn()' requires that 'S' conform to 'P'}}
389+
// expected-error@-1 {{local function 'fn()' requires that 'S' conform to 'P'}}
384390
}
385391
}
386392

387-
func global_function_with_requirement_failure() -> some P { // expected-note {{declared here}}
393+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
394+
func global_function_with_requirement_failure() -> some P { // expected-note {{where 'τ_0_0' = 'Double'}}
388395
return 42 as Double
389-
// expected-error@-1 {{return type of global function 'global_function_with_requirement_failure()' requires that 'Double' conform to 'P'}}
396+
// expected-error@-1 {{global function 'global_function_with_requirement_failure()' requires that 'Double' conform to 'P'}}
390397
}
391398

392399
func recursive_func_is_invalid_opaque() {
@@ -430,7 +437,8 @@ protocol P_51641323 {
430437

431438
func rdar_51641323() {
432439
struct Foo: P_51641323 {
433-
var foo: some P_51641323 { // expected-note {{required by opaque return type of property 'foo'}}
440+
// FIXME [OPAQUE SUPPORT]: regression in error message clarity
441+
var foo: some P_51641323 { // expected-note {{required by getter '_' where 'τ_0_0' = '() -> ()'}}
434442
{} // expected-error {{type '() -> ()' cannot conform to 'P_51641323'}} expected-note {{only concrete types such as structs, enums and classes can conform to protocols}}
435443
}
436444
}

0 commit comments

Comments
 (0)