Skip to content

[AutoDiff] Fix false Differentiable derived conformances warning. #32527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Sema/DerivedConformanceDifferentiable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ getStoredPropertiesForDifferentiation(NominalTypeDecl *nominal, DeclContext *DC,
if (auto *originalProperty = vd->getOriginalWrappedProperty()) {
// Skip immutable wrapped properties. `mutating func move(along:)` cannot
// be synthesized to update these properties.
if (!originalProperty->getAccessor(AccessorKind::Set))
if (!originalProperty->isSettable(DC))
continue;
// Use the original wrapped property.
vd = originalProperty;
Expand Down Expand Up @@ -791,7 +791,7 @@ static void checkAndDiagnoseImplicitNoDerivative(ASTContext &Context,
// Diagnose wrapped properties whose property wrappers do not define
// `wrappedValue.set`. `mutating func move(along:)` cannot be synthesized
// to update these properties.
if (!originalProperty->getAccessor(AccessorKind::Set)) {
if (!originalProperty->isSettable(DC)) {
auto *wrapperDecl =
vd->getInterfaceType()->getNominalOrBoundGenericNominal();
auto loc =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ class SR_12793: Differentiable {
}

// Test property wrappers.
// TF-1190: Test `@noDerivative` warning for property wrapper backing storage properties.

@propertyWrapper
struct ImmutableWrapper<Value> {
Expand Down Expand Up @@ -559,10 +558,13 @@ class WrappedProperties: Differentiable {

@Wrapper var float: Generic<Float> = Generic()
@ClassWrapper var float2: Generic<Float> = Generic()
// SR-13071: Test `@differentiable` wrapped property.
@differentiable @Wrapper var float3: Generic<Float> = Generic()

@noDerivative @ImmutableWrapper var nondiff: Generic<Int> = Generic()

static func testTangentMemberwiseInitializer() {
_ = TangentVector(float: .init(), float2: .init())
_ = TangentVector(float: .init(), float2: .init(), float3: .init())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ struct SR_12793: Differentiable {
}

// Test property wrappers.
// TF-1190: Test `@noDerivative` warning for property wrapper backing storage properties.

@propertyWrapper
struct ImmutableWrapper<Value> {
Expand Down Expand Up @@ -372,10 +371,13 @@ struct WrappedProperties: Differentiable {

@Wrapper var float: Generic<Float>
@ClassWrapper var float2: Generic<Float>
// SR-13071: Test `@differentiable` wrapped property.
@differentiable @Wrapper var float3: Generic<Float>

@noDerivative @ImmutableWrapper var nondiff: Generic<Int>

static func testTangentMemberwiseInitializer() {
_ = TangentVector(float: .init(), float2: .init())
_ = TangentVector(float: .init(), float2: .init(), float3: .init())
}
}

Expand Down