Skip to content

Commit b067a9a

Browse files
authored
Merge branch 'swiftlang:main' into main
2 parents 1786cbf + 74f2c74 commit b067a9a

File tree

6 files changed

+32
-2
lines changed

6 files changed

+32
-2
lines changed

Sources/Testing/ABI/Encoded/ABI.EncodedIssue.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ extension ABI {
2828
///
2929
/// - Warning: Severity is not yet part of the JSON schema.
3030
var _severity: Severity
31+
32+
/// If the issue is a failing issue.
33+
///
34+
/// - Warning: Non-failing issues are not yet part of the JSON schema.
35+
var _isFailure: Bool
3136

3237
/// Whether or not this issue is known to occur.
3338
var isKnown: Bool
@@ -50,6 +55,7 @@ extension ABI {
5055
case .warning: .warning
5156
case .error: .error
5257
}
58+
_isFailure = issue.isFailure
5359
isKnown = issue.isKnown
5460
sourceLocation = issue.sourceLocation
5561
if let backtrace = issue.sourceContext.backtrace {

Sources/Testing/Events/TimeValue.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ struct TimeValue: Sendable {
5454

5555
@available(_clockAPI, *)
5656
init(_ instant: SuspendingClock.Instant) {
57+
#if compiler(>=6.2)
58+
self.init(SuspendingClock().systemEpoch.duration(to: instant))
59+
#else
5760
self.init(unsafeBitCast(instant, to: Duration.self))
61+
#endif
5862
}
5963
}
6064

@@ -110,7 +114,11 @@ extension Duration {
110114
@available(_clockAPI, *)
111115
extension SuspendingClock.Instant {
112116
init(_ timeValue: TimeValue) {
117+
#if compiler(>=6.2)
118+
self = SuspendingClock().systemEpoch.advanced(by: Duration(timeValue))
119+
#else
113120
self = unsafeBitCast(Duration(timeValue), to: SuspendingClock.Instant.self)
121+
#endif
114122
}
115123
}
116124

Sources/TestingMacros/Support/Additions/FunctionDeclSyntaxAdditions.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ extension FunctionDeclSyntax {
3434
.contains(.keyword(.nonisolated))
3535
}
3636

37+
/// Whether or not this function declares an operator.
38+
var isOperator: Bool {
39+
switch name.tokenKind {
40+
case .binaryOperator, .prefixOperator, .postfixOperator:
41+
true
42+
default:
43+
false
44+
}
45+
}
46+
3747
/// The name of this function including parentheses, parameter labels, and
3848
/// colons.
3949
var completeName: DeclReferenceExprSyntax {

Sources/TestingMacros/Support/DiagnosticMessage.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ struct DiagnosticMessage: SwiftDiagnostics.DiagnosticMessage {
9393
let result: (value: String, article: String)
9494
switch node.kind {
9595
case .functionDecl:
96-
result = ("function", "a")
96+
if node.cast(FunctionDeclSyntax.self).isOperator {
97+
result = ("operator", "an")
98+
} else {
99+
result = ("function", "a")
100+
}
97101
case .classDecl:
98102
result = ("class", "a")
99103
case .structDecl:

Sources/TestingMacros/TestDeclarationMacro.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public struct TestDeclarationMacro: PeerMacro, Sendable {
6161
}
6262

6363
// The @Test attribute is only supported on function declarations.
64-
guard let function = declaration.as(FunctionDeclSyntax.self) else {
64+
guard let function = declaration.as(FunctionDeclSyntax.self), !function.isOperator else {
6565
diagnostics.append(.attributeNotSupported(testAttribute, on: declaration))
6666
return false
6767
}

Tests/TestingMacrosTests/TestDeclarationMacroTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ struct TestDeclarationMacroTests {
6767
"Attribute 'Test' cannot be applied to a structure",
6868
"@Test enum E {}":
6969
"Attribute 'Test' cannot be applied to an enumeration",
70+
"@Test func +() {}":
71+
"Attribute 'Test' cannot be applied to an operator",
7072
7173
// Availability
7274
"@available(*, unavailable) @Suite struct S {}":

0 commit comments

Comments
 (0)