Skip to content

🍒 [5.7] DiagnosticEngine: Print any in 'aka' types #59155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/AST/DiagnosticEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ static void formatDiagnosticArgument(StringRef Modifier,
llvm::SmallString<256> AkaText;
llvm::raw_svector_ostream OutAka(AkaText);

OutAka << getAkaTypeForDisplay(type);
getAkaTypeForDisplay(type)->print(OutAka, printOptions);
Out << llvm::format(FormatOpts.AKAFormatString.c_str(),
typeName.c_str(), AkaText.c_str());
} else {
Expand Down
8 changes: 4 additions & 4 deletions test/ClangImporter/objc_parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -544,20 +544,20 @@ func testStrangeSelectors(obj: StrangeSelectors) {

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

_ = cell as NSObject
_ = cell as NSObjectProtocol
_ = cell as NSCopying
_ = cell as SomeCell

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

extension Printing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ func takesProtocol(_ x: Protocol) {}
takesProtocol(ObjCProto.self)
takesProtocol(ObjCProto2.self)
takesProtocol(NonObjCProto.self) // expected-error{{cannot convert value of type '(any NonObjCProto).Type' to expected argument type 'Protocol'}}
takesProtocol(TwoObjCProtos.self) // expected-error{{cannot convert value of type '(any TwoObjCProtos).Type' (aka '(ObjCProto & ObjCProto2).Protocol') to expected argument type 'Protocol'}}
takesProtocol(TwoObjCProtos.self) // expected-error{{cannot convert value of type '(any TwoObjCProtos).Type' (aka '(any ObjCProto & ObjCProto2).Type') to expected argument type 'Protocol'}}
4 changes: 2 additions & 2 deletions test/Constraints/casts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,8 @@ func protocol_composition(_ c: ProtocolP & ProtocolQ, _ c1: ProtocolP & Composit
_ = c1 as? ConcretePQ1 // OK
_ = c1 as? ConcretePPQ1 // Ok
_ = c1 as? NotConforms // Ok
_ = c1 as? StructNotComforms // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'StructNotComforms' always fails}}
_ = c1 as? NotConformsFinal // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'NotConformsFinal' always fails}}
_ = c1 as? StructNotComforms // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'any ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'StructNotComforms' always fails}}
_ = c1 as? NotConformsFinal // expected-warning {{cast from 'any ProtocolP & Composition' (aka 'any ProtocolP & ProtocolP1 & ProtocolQ1') to unrelated type 'NotConformsFinal' always fails}}
}

// SR-13899
Expand Down
2 changes: 1 addition & 1 deletion test/Constraints/metatypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let test4 : AnyClass = B.self
struct S {}

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

func acceptMeta<T>(_ meta: T.Type) { }
acceptMeta(A) // expected-error {{expected member name or constructor call after type name}}
Expand Down
2 changes: 1 addition & 1 deletion test/Sema/diag_metatype_cast_to_reference_no_objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
class C {}

func test(c: AnyClass) {
let _: AnyObject = c // expected-error {{value of type 'AnyClass' (aka 'AnyObject.Type') expected to be instance of class or class-constrained type}}
let _: AnyObject = c // expected-error {{value of type 'AnyClass' (aka 'any AnyObject.Type') expected to be instance of class or class-constrained type}}
let _: AnyObject = C.self // expected-error {{value of type 'C.Type' expected to be instance of class or class-constrained type}}
}
4 changes: 2 additions & 2 deletions test/decl/protocol/conforms/failure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protocol P11 {
associatedtype A: Equatable
// FIXME: Should not resolve witness for 'method', but Type::subst doesn't care
// about conditional requirements when querying type witnesses.
// expected-note@+1 {{protocol requires function 'method()' with type '() -> Conformer.A' (aka '() -> Array<P11>'); do you want to add a stub?}}
// expected-note@+1 {{protocol requires function 'method()' with type '() -> Conformer.A' (aka '() -> Array<any P11>'); do you want to add a stub?}}
func method() -> A
}
do {
Expand All @@ -223,7 +223,7 @@ do {
// expected-error@-2 {{type 'any P11' does not conform to protocol 'Equatable'}} // FIXME: Crappy diagnostics
// expected-error@-3 {{'P11' requires that 'any P11' conform to 'Equatable'}}
// expected-note@-4 {{requirement specified as 'any P11' : 'Equatable'}}
// expected-note@-5 {{requirement from conditional conformance of 'Conformer.A' (aka 'Array<P11>') to 'Equatable'}}
// expected-note@-5 {{requirement from conditional conformance of 'Conformer.A' (aka 'Array<any P11>') to 'Equatable'}}
typealias A = Array<any P11>
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/expr/postfix/call/construction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,5 @@ func constructExistentialValue(_ pm: P.Type) {
typealias P1_and_P2 = P & P2
func constructExistentialCompositionValue(_ pm: (P & P2).Type) {
_ = pm.init(int: 5)
_ = P1_and_P2(int: 5) // expected-error{{type 'any P1_and_P2' (aka 'P & P2') cannot be instantiated}}
_ = P1_and_P2(int: 5) // expected-error{{type 'any P1_and_P2' (aka 'any P & P2') cannot be instantiated}}
}