Skip to content

Commit aac118b

Browse files
committed
Preemptively rename @_versioned to @usableFromInline.
1 parent 47f49f6 commit aac118b

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2439,8 +2439,8 @@ ERROR(differentiable_attr_forward_mode_unsupported,none,
24392439
"forward-mode automatic differentiation is not supported yet", ())
24402440
ERROR(differentiable_attr_invalid_access,none,
24412441
"%select{adjoint|primal}2 %0 is required to either be public or "
2442-
"@_versioned because the original function %1 is public or @_versioned",
2443-
(DeclName, DeclName, bool))
2442+
"@usableFromInline because the original function %1 is public or "
2443+
"@usableFromInline", (DeclName, DeclName, bool))
24442444

24452445
ERROR(compiler_evaluable_bad_context,none,
24462446
"@compilerEvaluable functions not allowed here", ())

lib/Sema/TypeCheckAttr.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,8 +2249,8 @@ void AttributeChecker::visitDifferentiableAttr(DifferentiableAttr *attr) {
22492249
auto originalParamsTy = originalParams.getInterfaceType(ctx);
22502250

22512251
// If the original function and the primal/adjoint have different parents, or
2252-
// if they both have no type context and are in different modules, then
2253-
// it's an error.
2252+
// if they both have no type context and are in different modules, then it's
2253+
// an error.
22542254
// Returns true on error.
22552255
std::function<bool(FuncDecl *)> hasValidTypeContext
22562256
= [&](FuncDecl *func) {
@@ -2268,17 +2268,19 @@ void AttributeChecker::visitDifferentiableAttr(DifferentiableAttr *attr) {
22682268
return original->getParent() == func->getParent();
22692269
};
22702270

2271-
// If the original function is exported (i.e. it is public or @_versioned),
2272-
// then the primal/adjoint must also be exported.
2271+
// If the original function is exported (i.e. it is public or
2272+
// @usableFromInline), then the primal/adjoint must also be exported.
22732273
// Returns true on error.
22742274
using FuncSpecifier = DifferentiableAttr::FunctionSpecifier;
22752275
auto checkAccessControl = [&](FuncDecl *func, FuncSpecifier funcSpec,
22762276
bool isPrimal) {
2277-
auto originalAccess = original->getFormalAccess(/*useDC*/ nullptr,
2278-
/*respectVersioned*/ true);
2277+
auto originalAccess =
2278+
original->getFormalAccess(/*useDC*/ nullptr,
2279+
/*treatUsableFromInlineAsPublic*/ true);
22792280
if (originalAccess < AccessLevel::Public) return false;
2280-
auto funcAccess = func->getFormalAccess(/*useDC*/ nullptr,
2281-
/*respectVersioned*/ true);
2281+
auto funcAccess =
2282+
func->getFormalAccess(/*useDC*/ nullptr,
2283+
/*treatUsableFromInlineAsPublic*/ true);
22822284
if (funcAccess >= AccessLevel::Public) return false;
22832285
TC.diagnose(funcSpec.Loc.getBaseNameLoc(),
22842286
diag::differentiable_attr_invalid_access,

test/AutoDiff/differentiable_attr_access_control.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %target-swift-frontend -typecheck -verify %s
22

3-
// If the original function is "exported" (public or @_versioned), then its
4-
// primal/adjoint must also be exported.
3+
// If the original function is "exported" (public or @usableFromInline), then
4+
// its primal/adjoint must also be exported.
55

66
// Ok: all public.
77
@differentiable(reverse, adjoint: dfoo1(_:primal:seed:))
@@ -21,12 +21,12 @@ private func foo3(_ x: Float) -> Float { return 1 }
2121
private func dfoo3(_ x: Float, primal: Float, seed: Float) -> Float { return 1 }
2222

2323
// Error: adjoint not exported.
24-
@differentiable(reverse, adjoint: dbar1(_:primal:seed:)) // expected-error {{adjoint 'dbar1(_:primal:seed:)' is required to either be public or @_versioned because the original function 'bar1' is public or @_versioned}}
24+
@differentiable(reverse, adjoint: dbar1(_:primal:seed:)) // expected-error {{adjoint 'dbar1(_:primal:seed:)' is required to either be public or @usableFromInline because the original function 'bar1' is public or @usableFromInline}}
2525
public func bar1(_ x: Float) -> Float { return 1 }
2626
private func dbar1(_ x: Float, primal: Float, seed: Float) -> Float { return 1 }
2727

2828
// Error: primal not exported.
29-
@differentiable(reverse, primal: pbar2(_:), adjoint: dbar2(_:checkpoints:originalValue:seed:)) // expected-error {{primal 'pbar2' is required to either be public or @_versioned because the original function 'bar2' is public or @_versioned}}
29+
@differentiable(reverse, primal: pbar2(_:), adjoint: dbar2(_:checkpoints:originalValue:seed:)) // expected-error {{primal 'pbar2' is required to either be public or @usableFromInline because the original function 'bar2' is public or @usableFromInline}}
3030
@_versioned func bar2(_ x: Float) -> Float { return 1 }
3131
func pbar2(_ x: Float) -> (checkpoints: CheckpointsFoo, originalValue: Float) { return (CheckpointsFoo(), 1) }
3232
func dbar2(_ x: Float, checkpoints: CheckpointsFoo, originalValue: Float, seed: Float) -> Float { return 1 }

0 commit comments

Comments
 (0)