Skip to content

Commit 7a6f9ce

Browse files
Merge pull request #59147 from AnthonyLatsis/print-any-in-aka
DiagnosticEngine: Print `any` in 'aka' types
2 parents 7075fb0 + b2e2bab commit 7a6f9ce

File tree

9 files changed

+14
-14
lines changed

9 files changed

+14
-14
lines changed

lib/AST/DiagnosticEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ static void formatDiagnosticArgument(StringRef Modifier,
737737
llvm::SmallString<256> AkaText;
738738
llvm::raw_svector_ostream OutAka(AkaText);
739739

740-
OutAka << getAkaTypeForDisplay(type);
740+
getAkaTypeForDisplay(type)->print(OutAka, printOptions);
741741
Out << llvm::format(FormatOpts.AKAFormatString.c_str(),
742742
typeName.c_str(), AkaText.c_str());
743743
} else {

test/ClangImporter/objc_parse.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -544,20 +544,20 @@ func testStrangeSelectors(obj: StrangeSelectors) {
544544

545545
func testProtocolQualified(_ obj: CopyableNSObject, cell: CopyableSomeCell,
546546
plainObj: NSObject, plainCell: SomeCell) {
547-
_ = obj as NSObject // expected-error {{'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') is not convertible to 'NSObject'}}
547+
_ = obj as NSObject // expected-error {{'CopyableNSObject' (aka 'any NSCopying & NSObjectProtocol') is not convertible to 'NSObject'}}
548548
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{11-13=as!}}
549549
_ = obj as NSObjectProtocol
550550
_ = obj as NSCopying
551-
_ = obj as SomeCell // expected-error {{'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') is not convertible to 'SomeCell'}}
551+
_ = obj as SomeCell // expected-error {{'CopyableNSObject' (aka 'any NSCopying & NSObjectProtocol') is not convertible to 'SomeCell'}}
552552
// expected-note@-1 {{did you mean to use 'as!' to force downcast?}} {{11-13=as!}}
553553

554554
_ = cell as NSObject
555555
_ = cell as NSObjectProtocol
556556
_ = cell as NSCopying
557557
_ = cell as SomeCell
558558

559-
_ = plainObj as CopyableNSObject // expected-error {{cannot convert value of type 'NSObject' to type 'CopyableNSObject' (aka 'NSCopying & NSObjectProtocol') in coercion}}
560-
_ = plainCell as CopyableSomeCell // expected-error {{cannot convert value of type 'SomeCell' to type 'CopyableSomeCell' (aka 'SomeCell & NSCopying') in coercion}}
559+
_ = plainObj as CopyableNSObject // expected-error {{cannot convert value of type 'NSObject' to type 'CopyableNSObject' (aka 'any NSCopying & NSObjectProtocol') in coercion}}
560+
_ = plainCell as CopyableSomeCell // expected-error {{cannot convert value of type 'SomeCell' to type 'CopyableSomeCell' (aka 'any SomeCell & NSCopying') in coercion}}
561561
}
562562

563563
extension Printing {

test/ClangImporter/protocol_metatype_object_conversion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ func takesProtocol(_ x: Protocol) {}
1414
takesProtocol(ObjCProto.self)
1515
takesProtocol(ObjCProto2.self)
1616
takesProtocol(NonObjCProto.self) // expected-error{{cannot convert value of type '(any NonObjCProto).Type' to expected argument type 'Protocol'}}
17-
takesProtocol(TwoObjCProtos.self) // expected-error{{cannot convert value of type '(any TwoObjCProtos).Type' (aka '(ObjCProto & ObjCProto2).Protocol') to expected argument type 'Protocol'}}
17+
takesProtocol(TwoObjCProtos.self) // expected-error{{cannot convert value of type '(any TwoObjCProtos).Type' (aka '(any ObjCProto & ObjCProto2).Type') to expected argument type 'Protocol'}}

test/Constraints/casts.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ func protocol_composition(_ c: ProtocolP & ProtocolQ, _ c1: ProtocolP & Composit
485485
_ = c1 as? ConcretePQ1 // OK
486486
_ = c1 as? ConcretePPQ1 // Ok
487487
_ = c1 as? NotConforms // Ok
488-
_ = c1 as? StructNotComforms // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'StructNotComforms' always fails}}
489-
_ = c1 as? NotConformsFinal // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'NotConformsFinal' always fails}}
488+
_ = c1 as? StructNotComforms // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'any ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'StructNotComforms' always fails}}
489+
_ = c1 as? NotConformsFinal // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'any ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'NotConformsFinal' always fails}}
490490
}
491491

492492
// SR-13899

test/Constraints/metatypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let test4 : AnyClass = B.self
1212
struct S {}
1313

1414
let test5 : S.Type = S.self
15-
let test6 : AnyClass = S.self // expected-error {{cannot convert value of type 'S.Type' to specified type 'AnyClass' (aka 'AnyObject.Type')}}
15+
let test6 : AnyClass = S.self // expected-error {{cannot convert value of type 'S.Type' to specified type 'AnyClass' (aka 'any AnyObject.Type')}}
1616

1717
func acceptMeta<T>(_ meta: T.Type) { }
1818
acceptMeta(A) // expected-error {{expected member name or constructor call after type name}}

test/Sema/diag_metatype_cast_to_reference_no_objc.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
class C {}
44

55
func test(c: AnyClass) {
6-
let _: AnyObject = c // expected-error {{value of type 'AnyClass' (aka 'AnyObject.Type') expected to be instance of class or class-constrained type}}
6+
let _: AnyObject = c // expected-error {{value of type 'AnyClass' (aka 'any AnyObject.Type') expected to be instance of class or class-constrained type}}
77
let _: AnyObject = C.self // expected-error {{value of type 'C.Type' expected to be instance of class or class-constrained type}}
88
}

test/decl/protocol/conforms/failure.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ protocol P11 {
214214
associatedtype A: Equatable
215215
// FIXME: Should not resolve witness for 'method', but Type::subst doesn't care
216216
// about conditional requirements when querying type witnesses.
217-
// expected-note@+1 {{protocol requires function 'method()' with type '() -> Conformer.A' (aka '() -> Array<P11>'); do you want to add a stub?}}
217+
// expected-note@+1 {{protocol requires function 'method()' with type '() -> Conformer.A' (aka '() -> Array<any P11>'); do you want to add a stub?}}
218218
func method() -> A
219219
}
220220
do {
@@ -223,7 +223,7 @@ do {
223223
// expected-error@-2 {{type 'any P11' does not conform to protocol 'Equatable'}} // FIXME: Crappy diagnostics
224224
// expected-error@-3 {{'P11' requires that 'any P11' conform to 'Equatable'}}
225225
// expected-note@-4 {{requirement specified as 'any P11' : 'Equatable'}}
226-
// expected-note@-5 {{requirement from conditional conformance of 'Conformer.A' (aka 'Array<P11>') to 'Equatable'}}
226+
// expected-note@-5 {{requirement from conditional conformance of 'Conformer.A' (aka 'Array<any P11>') to 'Equatable'}}
227227
typealias A = Array<any P11>
228228
}
229229
}

test/expr/postfix/call/construction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,5 @@ func constructExistentialValue(_ pm: P.Type) {
119119
typealias P1_and_P2 = P & P2
120120
func constructExistentialCompositionValue(_ pm: (P & P2).Type) {
121121
_ = pm.init(int: 5)
122-
_ = P1_and_P2(int: 5) // expected-error{{type 'any P1_and_P2' (aka 'P & P2') cannot be instantiated}}
122+
_ = P1_and_P2(int: 5) // expected-error{{type 'any P1_and_P2' (aka 'any P & P2') cannot be instantiated}}
123123
}

test/type/explicit_existential.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func testEnumAssociatedValue() {
334334

335335
// https://github.com/apple/swift/issues/58920
336336
typealias Iterator = any IteratorProtocol
337-
var example: any Iterator = 5 // expected-error{{redundant 'any' has no effect on existential type 'Iterator' (aka 'IteratorProtocol')}} {{14-18=}}
337+
var example: any Iterator = 5 // expected-error{{redundant 'any' has no effect on existential type 'Iterator' (aka 'any IteratorProtocol')}} {{14-18=}}
338338
// expected-error@-1{{value of type 'Int' does not conform to specified type 'IteratorProtocol'}}
339339
var example1: any (any IteratorProtocol) = 5 // expected-error{{redundant 'any' has no effect on existential type 'any IteratorProtocol'}} {{15-19=}}
340340
// expected-error@-1{{value of type 'Int' does not conform to specified type 'IteratorProtocol'}}

0 commit comments

Comments
 (0)