Skip to content

Commit be8131b

Browse files
authored
Merge pull request #21568 from dan-zheng/derive-math-protocols
[API] Derive conformances for `AdditiveArithmetic` and `VectorNumeric`.
2 parents cb2eacc + b38b56b commit be8131b

9 files changed

+683
-2
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2417,6 +2417,10 @@ ERROR(parameterized_no_parameters_struct,none,
24172417
ERROR(parameterized_invalid_parameters_struct,none,
24182418
"cannot automatically synthesize %0 because 'Parameters' struct is "
24192419
"invalid", (Type))
2420+
ERROR(broken_additive_arithmetic_requirement,none,
2421+
"AdditiveArithmetic protocol is broken: unexpected requirement", ())
2422+
ERROR(broken_vector_numeric_requirement,none,
2423+
"VectorNumeric protocol is broken: unexpected requirement", ())
24202424

24212425
NOTE(codable_extraneous_codingkey_case_here,none,
24222426
"CodingKey case %0 does not match any stored properties", (Identifier))

include/swift/AST/KnownIdentifiers.def

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,23 @@ IDENTIFIER_WITH_NAME(value_, "_value")
117117
IDENTIFIER(with)
118118

119119
// SWIFT_ENABLE_TENSORFLOW
120+
IDENTIFIER(TensorFlow)
121+
// KeyPathIterable
120122
IDENTIFIER(AllKeyPaths)
121123
IDENTIFIER(allKeyPaths)
122124
IDENTIFIER(recursivelyAllKeyPaths)
123125
IDENTIFIER(allWritableKeyPaths)
124126
IDENTIFIER(recursivelyAllWritableKeyPaths)
127+
// AdditiveArithmetic, VectorNumeric
128+
IDENTIFIER(zero)
129+
IDENTIFIER(Scalar)
130+
// ParameterGroup, Parameterized
125131
IDENTIFIER(allParameters)
126132
IDENTIFIER(Parameter)
127133
IDENTIFIER(Parameters)
128-
IDENTIFIER(TensorFlow)
134+
// Differentiable
129135
IDENTIFIER(CotangentVector)
130136
IDENTIFIER(TangentVector)
131-
IDENTIFIER(zero)
132137

133138
// Kinds of layout constraints
134139
IDENTIFIER_WITH_NAME(UnknownLayout, "_UnknownLayout")

lib/Sema/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ add_swift_host_library(swiftSema STATIC
2727
DerivedConformanceEquatableHashable.cpp
2828
DerivedConformanceError.cpp
2929
# SWIFT_ENABLE_TENSORFLOW
30+
DerivedConformanceAdditiveArithmeticVectorNumeric.cpp
3031
DerivedConformanceKeyPathIterable.cpp
3132
DerivedConformanceParameterGroup.cpp
3233
DerivedConformanceParameterized.cpp
34+
# SWIFT_ENABLE_TENSORFLOW END
3335
DerivedConformanceRawRepresentable.cpp
3436
DerivedConformances.cpp
3537
InstrumenterSupport.cpp

0 commit comments

Comments
 (0)