You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Diagnostics] Desugar syntax sugared types if they have unresolved types
If a syntax sugared type like Array had an unresolved type, it used to print as `[_]` in diagnostics, which could be confusing.
Instead, desugar these unresolved types before printing, so Array, for example, prints as `Array<_>`.
Currently this only applies to Array, Dictionary, and Optional.
Copy file name to clipboardExpand all lines: test/Constraints/diagnostics.swift
+22-1Lines changed: 22 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -424,7 +424,7 @@ enum Color {
424
424
}
425
425
426
426
// FIXME: This used to be better: "'map' produces '[T]', not the expected contextual result type '(Int, Color)'"
427
-
let _:(Int,Color)=[1,2].map({($0,.Unknown(""))}) // expected-error {{expression type '((Int) throws -> _) throws -> [_]' is ambiguous without more context}}
427
+
let _:(Int,Color)=[1,2].map({($0,.Unknown(""))}) // expected-error {{expression type '((Int) throws -> _) throws -> Array<_>' is ambiguous without more context}}
428
428
429
429
let _:[(Int,Color)]=[1,2].map({($0,.Unknown(""))})// expected-error {{missing argument label 'description:' in call}}
430
430
@@ -1233,3 +1233,24 @@ let baz: (Swift.Error) = Error() //expected-error {{value of type 'diagnostics.E
1233
1233
letbaz2:Swift.Error=(Error()) //expected-error {{value of type 'diagnostics.Error' does not conform to specified type 'Swift.Error'}}
1234
1234
letbaz3:(Swift.Error)=(Error()) //expected-error {{value of type 'diagnostics.Error' does not conform to specified type 'Swift.Error'}}
1235
1235
letbaz4:((Swift.Error))=(Error()) //expected-error {{value of type 'diagnostics.Error' does not conform to specified type 'Swift.Error'}}
1236
+
1237
+
// SyntaxSugarTypes with unresolved types
1238
+
func takesGenericArray<T>(_ x:[T]){}
1239
+
takesGenericArray(1) // expected-error {{cannot convert value of type 'Int' to expected argument type 'Array<_>'}}
1240
+
func takesNestedGenericArray<T>(_ x:[[T]]){}
1241
+
takesNestedGenericArray(1) // expected-error {{cannot convert value of type 'Int' to expected argument type 'Array<Array<_>>'}}
1242
+
func takesSetOfGenericArrays<T>(_ x:Set<[T]>){}
1243
+
takesSetOfGenericArrays(1) // expected-error {{cannot convert value of type 'Int' to expected argument type 'Set<Array<_>>'}}
0 commit comments