Commit Graph

21519 Commits

Author SHA1 Message Date
Becca Royal-Gordon
d59d219078 Forbid @_borrowed in @abi
It has indirect effects on the accessors, so it shouldn’t matter, but we can defensively redirect the query to the API counterpart anyway.

This was the last `InferredInABIAttr` attribute, so we can now remove all of the infrastructure involved in supporting attribute inference.
2025-05-08 18:27:58 -07:00
Becca Royal-Gordon
10d49aad5d Typecheck ABI-only VarDecls
The decl checker was effectively not being run on these because we weren’t typechecking the PBD and typechecking the VarDecl itself is basically a no-op.
2025-05-08 18:27:57 -07:00
Steven Wu
8e30d7f7c7 Merge pull request #81245 from cachemeifyoucan/eng/PR-145676736-release 2025-05-08 18:21:43 -07:00
Ben Barham
464223e479 Merge pull request #81259 from bnbarham/cherry-merge-modules
[6.2][InterfaceGen] Merge exported modules with the same public name in generated interface
2025-05-08 10:17:17 -07:00
Artem Chikin
8e1bc70454 Merge pull request #81337 from artemcm/DepScanVariantError-62
[6.2 🍒][Dependency Scanning] Emit a detailed error diagnostic on Clang module variant discovery
2025-05-07 21:12:31 -07:00
John Hui
1459ecafa9 Merge pull request #81214 from j-hui/base-6.2/swift-function-as-template-arg 2025-05-07 02:08:04 -07:00
Michael Gottesman
322a376432 Merge pull request #81334 from gottesmm/release/6.2-rdar150695113
[6.2][swift-settings] Now that we aren't using it immediately, remove it from tree.
2025-05-06 22:41:46 -07:00
Alejandro Alonso
2cc9fc61f4 Merge pull request #80855 from Azoy/62-value-generic-namelookup
[6.2] [NameLookup] Allow value generics to show up as static members
2025-05-06 20:55:07 -07:00
Doug Gregor
89358d6a0e Make ConformanceIsolationRequest cache per-ProtocolConformance
This request was looking through to the root conformance, which could
mess with the caching bits. Sink the "is nonisolated conformance" bit
down into ProtocolConformance, and have the request for a non-root
conformance be defined in terms of the request for the root
conformance.
2025-05-06 16:07:25 -07:00
Michael Gottesman
e04e15f125 [swift-settings] Now that we aren't using it immediately, remove it from tree.
We can always get it back from the git history.

rdar://150695113
(cherry picked from commit 9d59dbed17)

Conflicts:
	include/swift/AST/DiagnosticsSema.def
	include/swift/Basic/Features.def
	test/abi/macOS/arm64/concurrency.swift
	test/abi/macOS/x86_64/concurrency.swift
2025-05-06 14:12:23 -07:00
Artem Chikin
7f950ff180 [Dependency Scanning] Emit a detailed error diagnostic on Clang module variant discovery
In expectation, this should never happen. Such a situation means that within the same scanning action, Clang Dependency Scanner has produced two different variants of the same module. This is not supposed to happen, but we are currently hunting down the rare cases where it does, seemingly due to differences in Clang Scanner direct by-name queries and transitive header lookup queries.
2025-05-06 10:14:14 -07:00
Max Desiatov
ea237d5548 Merge pull request #81104 from Azoy/value-generic-namelookup-warning
[AST] Temporarily downgrade value generic redeclaration to warning
2025-05-05 18:42:38 -07:00
Alejandro Alonso
12919a2300 Merge pull request #78248 from Azoy/value-generic-static-member
[NameLookup] Allow value generics to show up as static members
2025-05-05 18:42:15 -07:00
Andrew Trick
cd343dfd26 [NFC] fix a comment typo in LifetimeDependence
(cherry picked from commit ce74ca3b5332d6bf839fe2412385bf947be0d106)
2025-05-05 10:22:20 -07:00
Andrew Trick
57e9585afa Fix LifetimeDependence type inference for setters.
A setter on a non-Escapable type may have a dependency on both it's incoming
'self' and 'newValue'. If the 'newValue' dependency does not match the getter's
dependency, then lifetime diagnostics will not accept the generated '_modify'
accessor:

error: lifetime-dependent value returned by generated accessor '_modify'

To fix this, make sure that we don't (conservatively) infer a borrow
dependency on 'newValue'.

Fixes rdar://150444400

(cherry picked from commit 88bbc18730)
2025-05-05 10:22:20 -07:00
Karoy Lorentey
4cde33c4b0 Merge pull request #80867 from lorentey/is_same_metatype_condfail_6.2
[6.2][stdlib] Allow metatype comparisons to work with outdated compilers
2025-05-05 10:03:35 -07:00
Artem Chikin
bb581a885b Merge pull request #81255 from artemcm/IncrementalScanFixes_62
[6.2 🍒][Dependency Scanning] Fix search path context hashing hole and avoid serializing unnecessary field
2025-05-05 09:29:27 -07:00
Artem Chikin
8aca9b115c Merge pull request #81146 from artemcm/ParameterizeWeakQueryForSwift-62
[6.2 🍒] Modify clang declaration weakly-imported query to use Swift's code-gen target triple
2025-05-05 09:21:44 -07:00
Ben Barham
d829fcf2eb Merge exported modules with the same public name in generated interface
If a module has the same `public-module-name` as the module being
generated and its import is exported, merge it into the same generated
interface.

Fix various always-imported modules from being printed while here and
update all the tests that checked for them.

Resolves rdar://137887712.

(cherry picked from commit ddddc667c8)
2025-05-02 12:52:44 -07:00
Artem Chikin
b684af4c88 Include system-ness of framework and import search paths in the PCH hash
This hash is also used for the dependency scanning hash. In both cases, PCH contents may differ based on whether a certain module they depend on is found in a system or non-system search path. In dependency scanning, systemness should cause a full change of scanning context requiring a from-scratch scan.

Resolves rdar://150334077
2025-05-02 10:02:56 -07:00
Steven Wu
edb94fb2fb [Caching] Improve diagnostics around swift caching
Improve diagnostics message for swift caching build by trying to emit
the diagnostics early when there is more context to differentiate the
different kind of problems.

After the improvement, CAS Error should be more closer to when there is
functional problem with the CAS, rather than mixing in other kinds of
problem (like scanning dependency failures) when operating with a CAS.

rdar://145676736
(cherry picked from commit 226552bf23)
2025-05-01 16:59:43 -07:00
Artem Chikin
4ac9119bf7 Modify clang declaration weakly-imported query to use Swift's code-gen target triple
Similarly to how https://github.com/swiftlang/swift/pull/70564 configures 'ClangImporter's 'CodeGenerator' using Swift's compilation target triple, we must use the versioned version of the 'isWeakImported' query to determine linkage for imported Clang symbols.
2025-05-01 10:40:10 -07:00
John Hui
3f8e9cd993 [cxx-interop] Allow C++ function templates to be instantiated with Swift closures
Swift started to explicitly forbid the instantiation of C++ function
templates with arbitrary types in #77430, because many types cause the
Swift compiler to crash. However, those checks prevented them from being
instantiated with Swift closures (which were previously fine), causing
a regression.

This patch relaxes the convertTemplateArgument() function to also allow
converting Swift function types, and adds some tests to make sure doing
so is fine.

This patch also does some cleanup of existing tests checking the
instantiation of various types, and adds testing for C function pointers
and Obj-C blocks.

rdar://148124104
(cherry picked from commit 284de98744)
2025-04-30 13:49:23 -07:00
Andrew Trick
3efcc14d60 Merge pull request #81192 from atrick/62-var-walker-recursion
[6.2] LifetimeDependenceDiagnostics: bug fixes and output clarity
2025-04-30 07:34:14 -07:00
Slava Pestov
75181f9fa7 Merge pull request #81182 from slavapestov/fix-issue-79763-6.2
[6.2] AST: Fix existential erasure of long member types
2025-04-30 07:13:46 -04:00
Andrew Trick
5719d4c726 LifetimeDependence type checking: avoid an assertion on error.
When the type checker encounters incomplete type error, bail out early to avoid
an assertion.

(cherry picked from commit 36551e370d)
2025-04-30 00:09:39 -07:00
Andrew Trick
3ca91b5665 Merge pull request #81130 from atrick/62-fix-default-init
[6.2] LifetimeDependence: fix a type checker crash on implicit init
2025-04-29 23:49:22 -07:00
Slava Pestov
9bb6673bbd AST: Fix existential erasure of long member types
Suppose protocol P has a primary associated type A, and we have
a `any P<S>` value. We form the generalization signature <T>
with substitution map {T := S}, and the existential signature
<T, Self where T == Self.A>.

Now, if we call a protocol requirement that takes Self.A.A.A,
we see this is fixed concrete type, because the reduced type of
Self.A.A.A is T.A.A in the existential signature.

However, this type parameter is not formed from the
conformance requirements of the generalization signature
(there aren't any), so we cannot directly apply the outer
substitution map.

Instead, change the outer substitution conformance lookup
callback to check if the reduced type parameter is valid
in the generalization signature, and not just rooted in a
generic parameter of the generalization signature.

If it isn't, fall back to global conformance lookup.

A better fix would introduce new requirements into the
generalization signature to handle this, or store them
separately in the generic environment itself. But this is fine
for now.

- Fixes https://github.com/swiftlang/swift/issues/79763.
- Fixes rdar://problem/146111083.
2025-04-29 19:00:50 -04:00
Guillaume Lessard
e9b21cff7d Merge pull request #80847 from glessard/rdar149227278-nonescapable-mutating-accessor-62
[6.2, LifetimeDependenceMutableAccessors] defensive feature flag
2025-04-29 12:30:10 -07:00
Andrew Trick
baa02e0529 LifetimeDependence: fix a type checker crash on implicit init
When the type checker diagnoses an error on an implicit initializer,
return immediately before handling its parameter to avoid an assert.

(cherry picked from commit e9ac803e94)
2025-04-27 22:38:34 -07:00
Andrew Trick
37a25e848a Fix LifetimeDependence attribute checking
Handle parameters with no name: foo(_:T)

(cherry picked from commit a7c9b6eccc)
2025-04-25 19:21:15 -07:00
Allan Shortlidge
b4376a9bd3 AST: Filter out some Obj-C overrides when MemberImportVisibility is enabled.
Unlike in Swift, Obj-C allows method overrides to be declared in extensions
(categories), even outside of the module that defines the type that is being
extended. When MemberImportVisibility is enabled, these overrides must be
filtered out to prevent them from hijacking name lookup and causing the
compiler to insist that the module that defines the extension be imported.

Resolves rdar://145329988.
2025-04-24 21:26:34 -07:00
Tony Allevato
592398fc3d Merge pull request #81069 from allevato/6.2-json-ast-fixes
[🍒 6.2] [AST] More JSON AST dump improvements.
2025-04-24 17:09:19 -04:00
Michael Gottesman
da57f9665c Merge pull request #80953 from gottesmm/release/6.2-135459885
[6.2][sil-isolation-info] When determining isolation of a function arg, use its VarDecl.
2025-04-24 10:14:41 -07:00
Slava Pestov
7e59265786 Merge pull request #81053 from slavapestov/fix-rdar149315905-6.2
[6.2] Workaround for performance regression with opaque archetypes
2025-04-24 12:00:20 -04:00
Tony Allevato
8ca0b416c8 Merge pull request #80498 from allevato/json-usr-fixes
[AST] More JSON AST dump improvements.
2025-04-24 07:51:57 -04:00
Slava Pestov
763beff7c6 AST: Basically revert "Rename TypeTransform::transformSubMap()"
This undoes the effect of commit 865c040c9b
since it introduced a performance regression.
2025-04-23 18:00:19 -04:00
Hamish Knight
71be544585 [ASTPrinter] Add missing null check in isNonSendableExtension
The extended nominal may not be present for an invalid extension.

rdar://149032713
2025-04-23 21:13:34 +01:00
Doug Gregor
172229eea9 Merge pull request #80988 from DougGregor/new-diagnostics-formatter-without-sourceloc-6.2 2025-04-22 20:39:31 -07:00
Hamish Knight
2332e15a17 Merge pull request #80998 from hamishknight/expanded-catch-6.2
[6.2] [ASTScope] Match parent scopes in `lookupCatchNode` for brace stmts
2025-04-23 03:56:34 +01:00
Pavel Yaskevich
af01ed473a Merge pull request #80982 from xedin/rdar-145776322-6.2
[6.2][Frontend] Promote `AsyncCallerExecution` to an upcoming feature
2025-04-22 15:51:36 -07:00
Hamish Knight
0017d5d41e [ASTScope] Match parent scopes in lookupCatchNode for brace stmts
Rather than looking for a given BraceStmtScope child for a particular
catch node, check whether the given catch node is the parent of the
innermost BraceStmtScope we've found, looking through an intermediate
source file if needed. This ensures it works correctly when the
BraceStmtScope is in a macro expansion.

rdar://149036108
2025-04-22 18:13:29 +01:00
Karoy Lorentey
3fce89c2e8 [stdlib] Allow metatype comparisons to work with outdated compilers
Add a new language feature to avoid the stdlib’s swiftinterface becoming unintelligible to outdated compiler builds due to the generalization of Builtin.is_same_metatype.

rdar://149396721
(cherry picked from commit 0c406b89e6)
2025-04-22 10:02:20 -07:00
Doug Gregor
3ecd05593e [Diagnostics] Use the swift-syntax formatting for invalid source locations, too
The diagnostics formatter from swift-syntax previously only handled
fully-formed diagnostics anchored at a particular syntax node.
Therefore, the compiler would fall back to the existing LLVM-based
diagnostic formatter for diagnostics that had no source location.

Adopt new API in the swift-syntax diagnostics formatter that renders a
diagnostic message without requiring source location information, so
that we consistently use the swift-syntax formatter when it is
selected (which is the default).

(cherry picked from commit 235242e8b3)
2025-04-22 07:00:11 -07:00
Allan Shortlidge
7ad7e220e7 Merge pull request #80976 from tshortli/revert-member-import-visibility-objc-overloads-in-extensions-6.2
[6.2] Revert "AST: Filter out some Obj-C overrides when MemberImportVisibility is enabled."
2025-04-22 01:38:12 -07:00
Pavel Yaskevich
d007d7adfb [Frontend] Rename AsyncCallerExecution upcoming feature to NonisolatedNonsendingBeDefault
(cherry picked from commit c110941c27)
2025-04-22 00:33:45 -07:00
Allan Shortlidge
a020cf8367 Revert "AST: Filter out some Obj-C overrides when MemberImportVisibility is enabled."
This reverts commit 324fa235b0.
2025-04-21 17:08:01 -07:00
Michael Gottesman
636aa31192 [sil-isolation-info] When determining isolation of a function arg, use its VarDecl.
Otherwise, we can be inconsistent with isolations returned by other parts of the
code. Previously we were just treating it always as self + nom decl, which is
clearly wrong if a type is not self (e.x.: if it is an isolated parameter).

rdar://135459885
(cherry picked from commit 0ece31e4f6)
2025-04-21 10:57:48 -07:00
Doug Gregor
ac56b63bd3 [Strict memory safety] Type alias types are only unsafe if their underlying type is
(cherry picked from commit 53ca902267)
2025-04-21 09:03:28 -07:00
Doug Gregor
93fbce0ce2 [Strict memory safety] Nested types are safe/unsafe independent of their enclosing type
When determining whether a nested type is safe, don't consider whether
its enclosing type is safe. They're independent.

(cherry picked from commit 8ec52c825c)
2025-04-21 09:03:25 -07:00