mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Re-baseline ValueGenericsNameLookup feature.
This commit is contained in:
@@ -261,7 +261,7 @@ LANGUAGE_FEATURE(RawIdentifiers, 451, "Raw identifiers")
|
||||
LANGUAGE_FEATURE(SendableCompletionHandlers, 463, "Objective-C completion handler parameters are imported as @Sendable")
|
||||
LANGUAGE_FEATURE(AsyncExecutionBehaviorAttributes, 0, "@concurrent and nonisolated(nonsending)")
|
||||
LANGUAGE_FEATURE(IsolatedConformances, 407, "Global-actor isolated conformances")
|
||||
LANGUAGE_FEATURE(ValueGenericsNameLookup, 452, "Value generics appearing as static members for namelookup")
|
||||
BASELINE_LANGUAGE_FEATURE(ValueGenericsNameLookup, 452, "Value generics appearing as static members for namelookup")
|
||||
LANGUAGE_FEATURE(GeneralizedIsSameMetaTypeBuiltin, 465, "Builtin.is_same_metatype with support for noncopyable/nonescapable types")
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(ABIAttributeSE0479, 479, "@abi attribute on functions, initializers, properties, and subscripts")
|
||||
LANGUAGE_FEATURE(AlwaysInheritActorContext, 472, "@_inheritActorContext(always)")
|
||||
|
||||
@@ -400,54 +400,6 @@ bool swift::usesFeatureIsolatedDeinit(const Decl *decl) {
|
||||
}
|
||||
}
|
||||
|
||||
class UsesTypeValueExpr : public ASTWalker {
|
||||
public:
|
||||
bool used = false;
|
||||
|
||||
PreWalkResult<Expr *> walkToExprPre(Expr *expr) override {
|
||||
if (isa<TypeValueExpr>(expr)) {
|
||||
used = true;
|
||||
return Action::Stop();
|
||||
}
|
||||
|
||||
return Action::Continue(expr);
|
||||
}
|
||||
};
|
||||
|
||||
static bool usesFeatureValueGenericsNameLookup(Decl *decl) {
|
||||
// Be conservative and mark any function that has a TypeValueExpr in its body
|
||||
// as having used this feature. It's a little difficult to fine grain this
|
||||
// check because the following:
|
||||
//
|
||||
// func a() -> Int {
|
||||
// A<123>.n
|
||||
// }
|
||||
//
|
||||
// Would appear to have the same expression as something like:
|
||||
//
|
||||
// extension A where n == 123 {
|
||||
// func b() -> Int {
|
||||
// n
|
||||
// }
|
||||
// }
|
||||
|
||||
auto fn = dyn_cast<AbstractFunctionDecl>(decl);
|
||||
|
||||
if (!fn)
|
||||
return false;
|
||||
|
||||
auto body = fn->getMacroExpandedBody();
|
||||
|
||||
if (!body)
|
||||
return false;
|
||||
|
||||
UsesTypeValueExpr utve;
|
||||
|
||||
body->walk(utve);
|
||||
|
||||
return utve.used;
|
||||
}
|
||||
|
||||
static bool usesFeatureCoroutineAccessors(Decl *decl) {
|
||||
auto accessorDeclUsesFeatureCoroutineAccessors = [](AccessorDecl *accessor) {
|
||||
return requiresFeatureCoroutineAccessors(accessor->getAccessorKind());
|
||||
|
||||
@@ -319,15 +319,11 @@ extension InlineArray where Element: Copyable {
|
||||
@available(SwiftStdlib 6.2, *)
|
||||
@_alwaysEmitIntoClient
|
||||
public init(repeating value: Element) {
|
||||
#if $ValueGenericsNameLookup
|
||||
_storage = Builtin.emplace {
|
||||
let buffer = unsafe Self._initializationBuffer(start: $0)
|
||||
|
||||
unsafe buffer.initialize(repeating: value)
|
||||
}
|
||||
#else
|
||||
fatalError()
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-emit-module-interface(%t.swiftinterface) %s -module-name ValueGeneric -disable-availability-checking
|
||||
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name ValueGeneric -disable-availability-checking
|
||||
// RUN: %FileCheck %s < %t.swiftinterface
|
||||
// RUN: %FileCheck --implicit-check-not=ValueGenericsNameLookup %s < %t.swiftinterface
|
||||
|
||||
// CHECK: public struct Slab<Element, let N : Swift.Int>
|
||||
public struct Slab<Element, let N: Int> {
|
||||
@@ -27,21 +27,18 @@ public func usesConcreteSlab(_: Slab<Int, 2>) {}
|
||||
// CHECK: public func usesNegativeSlab(_: ValueGeneric.Slab<Swift.String, -10>)
|
||||
public func usesNegativeSlab(_: Slab<String, -10>) {}
|
||||
|
||||
// CHECK: $ValueGenericsNameLookup
|
||||
@inlinable
|
||||
public func test() -> Int {
|
||||
// CHECK: Slab<Int, 123>.N
|
||||
Slab<Int, 123>.N
|
||||
}
|
||||
|
||||
// CHECK: $ValueGenericsNameLookup
|
||||
@inlinable
|
||||
public func test2() -> Int {
|
||||
// CHECK: type(of: Slab<Int, 123>()).N
|
||||
type(of: Slab<Int, 123>()).N
|
||||
}
|
||||
|
||||
// CHECK: $ValueGenericsNameLookup
|
||||
@inlinable
|
||||
public func test3() {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user