mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Some editors use diagnostics from SourceKit to replace build issues. This causes issues if the diagnostics from SourceKit are formatted differently than the build issues. Make sure they are rendered the same way, removing most uses of `DiagnosticsEditorMode`. To do so, always emit the `add stubs for conformance` note (which previously was only emitted in editor mode) and remove all `; add <something>` suffixes from notes that state which requirements are missing. rdar://129283608
53 lines
1.3 KiB
Swift
53 lines
1.3 KiB
Swift
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify -o - -primary-file %s -I %S/Inputs/custom-modules/
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import SubclassExistentialsExtra
|
|
|
|
class SwiftLaundryService : NSLaundry {
|
|
var g: (Garment & Coat)? = nil
|
|
|
|
func wash(_ g: Garment & Coat) {
|
|
self.g = g
|
|
}
|
|
|
|
func bleach(_ g: Garment & Coat & Cotton) {}
|
|
|
|
func dry() -> Garment & Coat {
|
|
return g!
|
|
}
|
|
}
|
|
|
|
// FIXME: Consider better diagnostics here.
|
|
|
|
class OldSwiftLaundryService : NSLaundry {
|
|
// expected-error@-1 {{type 'OldSwiftLaundryService' does not conform to protocol 'NSLaundry'}}
|
|
// expected-note@-2 {{add stubs for conformance}}
|
|
|
|
var g: Coat? = nil
|
|
|
|
func wash(_ g: Coat) { // expected-note {{candidate has non-matching type '(Coat) -> ()'}}
|
|
self.g = g
|
|
}
|
|
|
|
func bleach(_ g: Coat) {} // expected-note {{candidate has non-matching type '(Coat) -> ()'}}
|
|
|
|
func dry() -> Coat { // expected-note {{candidate has non-matching type '() -> Coat'}}
|
|
return g!
|
|
}
|
|
}
|
|
|
|
// Make sure the method lookup is not ambiguous
|
|
|
|
_ = Coat.fashionStatement.wear()
|
|
|
|
|
|
func testInheritanceFromComposition(_ object: CompositionSubObject, _ specific: CompositionSubSpecific) {
|
|
let _: NSObject = object
|
|
let _: NSCopying = object
|
|
|
|
let _: SomeSpecificSubclass = specific
|
|
let _: NSCopying = specific
|
|
}
|