You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During protocol witness matching for a protocol requirement with
`@differentiable` attributes, implicit `@differentiable` attributes may be
created for the witness under specific conditions (when the witness has a
`@differentiable` attribute with superset differentiability parameters, or
when the witness has less-than-public visibility).
Do not generate implicit `@differentiable` attributes for protocol witnesses
when the protocol conformance is declared from a separate file or type context
from the witness.
Resolves SR-13455.
// expected-note @+1 {{candidate is missing explicit '@differentiable' attribute to satisfy requirement 'internalMethod1' (in protocol 'Protocol1'); explicit attribute is necessary because candidate is declared in a different type context or file than the conformance of 'ConformingStruct' to 'Protocol1'}} {{3-3=@differentiable }}
36
+
func internalMethod1(_ x:Float)->Float{
37
+
x
38
+
}
39
+
40
+
// Error for missing `@differentiable` superset attribute.
41
+
// expected-note @+2 {{candidate is missing explicit '@differentiable' attribute to satisfy requirement 'internalMethod2' (in protocol 'Protocol1'); explicit attribute is necessary because candidate is declared in a different type context or file than the conformance of 'ConformingStruct' to 'Protocol1'}} {{3-3=@differentiable }}
42
+
@differentiable(wrt: x)
43
+
func internalMethod2(_ x:Float)->Float{
44
+
x
45
+
}
46
+
47
+
// Error for missing `@differentiable` subset attribute.
48
+
// expected-note @+2 {{candidate is missing explicit '@differentiable(wrt: x)' attribute to satisfy requirement 'internalMethod3' (in protocol 'Protocol1'); explicit attribute is necessary because candidate is declared in a different type context or file than the conformance of 'ConformingStruct' to 'Protocol1'}} {{3-3=@differentiable(wrt: x) }}
// expected-note @+1 {{protocol requires function 'callAsFunction' with type '(Float) -> Float'}}
6
+
func callAsFunction(_ input:Float)->Float
7
+
}
8
+
9
+
protocolP2:P1{}
10
+
11
+
extensionP2{
12
+
@differentiable(wrt:(self, input))
13
+
// expected-note @+1 {{candidate is missing explicit '@differentiable(wrt: self)' attribute to satisfy requirement 'callAsFunction' (in protocol 'P1'); explicit attribute is necessary because candidate is declared in a different type context or file than the conformance of 'ConformingStruct' to 'P1'}}
0 commit comments