Skip to content

Commit 72ffe51

Browse files
committed
Workaround for rdar://84716758
Revert part of #39505 that led to a latent bug.
1 parent aef70f0 commit 72ffe51

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

lib/SIL/IR/TypeLowering.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,15 +2629,10 @@ CanAnyFunctionType TypeConverter::makeConstantInterfaceType(SILDeclRef c) {
26292629
if (auto *derivativeId = c.getDerivativeFunctionIdentifier()) {
26302630
auto originalFnTy =
26312631
makeConstantInterfaceType(c.asAutoDiffOriginalFunction());
2632-
// Protocol witness derivatives cannot have a derivative generic signature,
2633-
// but class method derivatives can.
2634-
GenericSignature derivativeGenSig = nullptr;
2635-
if (isa<ClassDecl>(c.getAbstractFunctionDecl()->getInnermostTypeContext()))
2636-
derivativeGenSig = derivativeId->getDerivativeGenericSignature();
26372632
auto *derivativeFnTy = originalFnTy->getAutoDiffDerivativeFunctionType(
26382633
derivativeId->getParameterIndices(), derivativeId->getKind(),
26392634
LookUpConformanceInModule(&M),
2640-
derivativeGenSig);
2635+
derivativeId->getDerivativeGenericSignature());
26412636
return cast<AnyFunctionType>(derivativeFnTy->getCanonicalType());
26422637
}
26432638

test/AutoDiff/SILGen/vtable.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
// RUN: %target-swift-frontend -emit-silgen %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-silgen -requirement-machine=off %s | %FileCheck %s
2+
3+
// FIXME(rdar://84987079)
24

35
// Test derivative function vtable entries for `@differentiable` class members:
46
// - Methods.

test/AutoDiff/compiler_crashers_fixed/rdar83894546-missing-generic-requirement.swift renamed to test/AutoDiff/compiler_crashers_fixed/rdar84716758-differentiable-protocol-witness-missing-requirements.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ import _Differentiation
55
public protocol Layer {
66
associatedtype Input: Differentiable
77
associatedtype Output: Differentiable
8+
@differentiable(reverse)
89
func callAsFunction(_ input: Input) -> Output
910
}
1011

1112
public class Function<Input: Differentiable, Output: Differentiable>: Layer {
12-
public typealias Body = @differentiable(reverse) (Input) -> Output
13-
14-
@noDerivative public let body: Body
13+
@noDerivative public let body: @differentiable(reverse) (Input) -> Output
1514

16-
public init(_ body: @escaping Body) {
15+
public init(_ body: @escaping @differentiable(reverse) (Input) -> Output) {
1716
self.body = body
1817
}
1918

0 commit comments

Comments
 (0)