mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
We've been converging the implementations of educational notes and diagnostic groups, where both provide category information in diagnostics (e.g., `[#StrictMemorySafety]`) and corresponding short-form documentation files. The diagnostic group model is more useful in a few ways: * It provides warnings-as-errors control for warnings in the group * It is easier to associate a diagnostic with a group with GROUPED_ERROR/GROUPED_WARNING than it is to have a separate diagnostic ID -> mapping. * It is easier to see our progress on diagnostic-group coverage * It provides an easy name to use for diagnostic purposes. Collapse the educational-notes infrastructure into diagnostic groups, migrating all of the existing educational notes into new groups. Simplify the code paths that dealt with multiple educational notes to have a single, possibly-missing "category documentation URL", which is how we're treating this.
90 lines
3.6 KiB
Swift
90 lines
3.6 KiB
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
// Has a lot of invalid 'appendInterpolation' methods
|
|
public struct BadStringInterpolation: StringInterpolationProtocol {
|
|
// expected-error@-1{{type conforming to 'StringInterpolationProtocol' does not implement a valid 'appendInterpolation' method}} {{documentation-file=string-interpolation-conformance}}
|
|
|
|
public init(literalCapacity: Int, interpolationCount: Int) {}
|
|
public mutating func appendLiteral(_: String) {}
|
|
|
|
public static func appendInterpolation(static: ()) {
|
|
// expected-warning@-1{{'appendInterpolation' method will never be used because it is static}} {{10-17=}} {{documentation-file=string-interpolation-conformance}}
|
|
}
|
|
|
|
private func appendInterpolation(private: ()) {
|
|
// expected-warning@-1{{'appendInterpolation' method is private, but 'BadStringInterpolation' is public}}
|
|
}
|
|
|
|
func appendInterpolation(default: ()) {
|
|
// expected-warning@-1{{'appendInterpolation' method is internal, but 'BadStringInterpolation' is public}}
|
|
}
|
|
|
|
public func appendInterpolation(intResult: ()) -> Int {
|
|
// expected-warning@-1{{'appendInterpolation' method does not return 'Void' or have a discardable result}} {{10-10=@discardableResult }} {{documentation-file=string-interpolation-conformance}}
|
|
}
|
|
}
|
|
|
|
// Has no 'appendInterpolation' methods at all
|
|
public struct IncompleteStringInterpolation: StringInterpolationProtocol {
|
|
// expected-error@-1{{type conforming to 'StringInterpolationProtocol' does not implement a valid 'appendInterpolation' method}}
|
|
|
|
public init(literalCapacity: Int, interpolationCount: Int) {}
|
|
public mutating func appendLiteral(_: String) {}
|
|
}
|
|
|
|
// Has only good 'appendInterpolation' methods.
|
|
public struct GoodStringInterpolation: StringInterpolationProtocol {
|
|
public init(literalCapacity: Int, interpolationCount: Int) {}
|
|
public mutating func appendLiteral(_: String) {}
|
|
|
|
public func appendInterpolation(noResult: ()) {}
|
|
|
|
public func appendInterpolation(voidResult: ()) -> Void {}
|
|
|
|
@discardableResult
|
|
public func appendInterpolation(discardableResult: ()) -> Int {}
|
|
}
|
|
|
|
// Has only good 'appendInterpolation' methods, but they're in an extension.
|
|
public struct GoodSplitStringInterpolation: StringInterpolationProtocol {
|
|
public init(literalCapacity: Int, interpolationCount: Int) {}
|
|
public mutating func appendLiteral(_: String) {}
|
|
}
|
|
|
|
extension GoodSplitStringInterpolation {
|
|
public func appendInterpolation(noResult: ()) {}
|
|
|
|
public func appendInterpolation(voidResult: ()) -> Void {}
|
|
|
|
@discardableResult
|
|
public func appendInterpolation(discardableResult: ()) -> Int {}
|
|
}
|
|
|
|
// Has only good 'appendInterpolation' methods, and is not public.
|
|
struct GoodNonPublicStringInterpolation: StringInterpolationProtocol {
|
|
init(literalCapacity: Int, interpolationCount: Int) {}
|
|
mutating func appendLiteral(_: String) {}
|
|
|
|
func appendInterpolation(noResult: ()) {}
|
|
|
|
public func appendInterpolation(voidResult: ()) -> Void {}
|
|
|
|
@discardableResult
|
|
func appendInterpolation(discardableResult: ()) -> Int {}
|
|
}
|
|
|
|
// Has a mixture of good and bad 'appendInterpolation' methods.
|
|
// We don't emit any errors in this case--we assume the others
|
|
// are implementation details or something.
|
|
public struct GoodStringInterpolationWithBadOnesToo: StringInterpolationProtocol {
|
|
public init(literalCapacity: Int, interpolationCount: Int) {}
|
|
public mutating func appendLiteral(_: String) {}
|
|
|
|
public func appendInterpolation(noResult: ()) {}
|
|
|
|
public static func appendInterpolation(static: ()) {}
|
|
private func appendInterpolation(private: ()) {}
|
|
func appendInterpolation(default: ()) {}
|
|
public func appendInterpolation(intResult: ()) -> Int {}
|
|
}
|