@@ -84,28 +84,43 @@ func test3<T: Differentiable, U: Differentiable>(_: @differentiable (T) -> @diff
84
84
func test4< T: Differentiable , U: Differentiable > ( _: @differentiable ( T ) -> ( U ) -> Int ) { }
85
85
86
86
let diffFunc : @differentiable ( Float ) -> Float
87
+ let linearFunc : @differentiable ( linear) ( Float ) -> Float
87
88
func inferredConformances< T, U> ( _: @differentiable ( T ) -> U ) { }
89
+ func inferredConformancesLinear< T, U> ( _: @differentiable ( linear) ( T ) -> U ) { }
88
90
inferredConformances ( diffFunc)
91
+ inferredConformancesLinear ( linearFunc)
89
92
90
93
func inferredConformancesResult< T, U> ( ) -> @differentiable ( T ) -> U { }
94
+ func inferredConformancesResultLinear< T, U> ( ) -> @differentiable ( linear) ( T ) -> U { }
91
95
92
96
let diffFuncWithNondiff : @differentiable ( Float , @nondiff Int ) -> Float
97
+ let linearFuncWithNondiff : @differentiable ( linear) ( Float , @nondiff Int ) -> Float
93
98
func inferredConformances< T, U, V> ( _: @differentiable ( T , @nondiff U ) -> V ) { }
99
+ func inferredConformancesLinear< T, U, V> ( _: @differentiable ( linear) ( T , @nondiff U ) -> V ) { }
94
100
inferredConformances ( diffFuncWithNondiff)
101
+ inferredConformancesLinear ( linearFuncWithNondiff)
95
102
96
103
struct Vector < T> {
97
104
var x , y : T
98
105
}
106
+ extension Vector : Equatable where T: Equatable { }
99
107
extension Vector : Differentiable where T: Differentiable { }
108
+ extension Vector : AdditiveArithmetic where T: AdditiveArithmetic { }
100
109
101
110
// expected-note @+1 {{where 'T' = 'Int'}}
102
111
func inferredConformancesGeneric< T, U> ( _: @differentiable ( Vector < T > ) -> Vector < U > ) { }
103
112
113
+ // expected-note @+1 {{where 'T' = 'Int'}}
114
+ func inferredConformancesGenericLinear< T, U> ( _: @differentiable ( linear) ( Vector < T > ) -> Vector < U > ) { }
115
+
104
116
func nondiffVectorFunc( x: Vector < Int > ) -> Vector < Int > { }
105
117
// expected-error @+1 {{global function 'inferredConformancesGeneric' requires that 'Int' conform to 'Differentiable}}
106
118
inferredConformancesGeneric ( nondiffVectorFunc)
119
+ // expected-error @+1 {{global function 'inferredConformancesGenericLinear' requires that 'Int' conform to 'Differentiable}}
120
+ inferredConformancesGenericLinear ( nondiffVectorFunc)
107
121
108
122
func diffVectorFunc( x: Vector < Float > ) -> Vector < Float > { }
109
123
inferredConformancesGeneric ( diffVectorFunc) // okay!
110
124
111
125
func inferredConformancesGenericResult< T, U> ( ) -> @differentiable ( Vector < T > ) -> Vector < U > { }
126
+ func inferredConformancesGenericResultLinear< T, U> ( ) -> @differentiable ( linear) ( Vector < T > ) -> Vector < U > { }
0 commit comments