Commit Graph

22565 Commits

Author SHA1 Message Date
Slava Pestov
ab8ca27701 Merge pull request #86020 from slavapestov/opaque-archetype-sugar-type-variable
AST: Canonicalize opaque archetype substitution maps in the solver arena
2025-12-13 08:54:58 -05:00
Slava Pestov
54521bd21b AST: Canonicalize opaque archetype substitution maps in the solver arena
Preserving sugar if we have type variables uses way too much memory.

Canonicalize these substitution maps for now, as a (temporary?) workaround.

In the future, if we decide preserving sugar is more important than a
few dozen Mb of memory usage, we can also bump the arena memory limit,
instead.

Fixes rdar://166237860.
Fixes rdar://165863647.
2025-12-12 18:11:04 -05:00
Hamish Knight
a4ae17133c Merge pull request #85973 from bnbarham/convert-async-shorthand
[SourceKit] Allow converting functions containing shorthand ifs to async
2025-12-12 17:19:23 +00:00
Michael Gottesman
e186e5e5d0 Merge pull request #85972 from gottesmm/pr-9663abc1697da1382a8514e6877a6c3ce3f439b9
[concurrency] Hide Concurrency StackNesting builtins behind a feature flag
2025-12-11 21:16:37 -08:00
Hamish Knight
088bda7424 Merge pull request #85952 from hamishknight/skip-body-macro
[AST] Avoid walking macro expanded bodies in non-expanded mode
2025-12-11 14:08:45 +00:00
Ben Barham
7887ce8a8e [SourceKit] Allow converting functions containing shorthand ifs to async
Resolves rdar://154753663.
2025-12-11 21:46:37 +10:00
Michael Gottesman
7b9281fcb8 [concurrency] Hide Concurrency StackNesting builtins behind a feature flag.
rdar://166244033
2025-12-10 16:02:18 -08:00
Egor Zhdan
f995144c1d Merge pull request #85906 from egorzhdan/egorzhdan/reland-cxx-string-cs
Reapply "[ConstraintSystem] C++ Interop: Binding a string literal to `std.string` shouldn't increase the score"
2025-12-10 21:04:15 +00:00
Meghana Gupta
96cfec4f84 Merge pull request #85935 from meg-gupta/lifetimeflags
Fix swiftinterface printing of accessors and inferred lifetime dependencies when Lifetimes feature is enabled
2025-12-10 10:01:01 -08:00
Hamish Knight
a9ad4e2cae [AST] Avoid walking macro expanded bodies in non-expanded mode
Make sure we don't walk into the expansion of a body macro if the AST
walker is configured not to walk macro expansions.
2025-12-10 17:41:00 +00:00
Meghana Gupta
4089775de8 Fix swiftinterface printing of accessors and inferred lifetime dependencies when Lifetimes feature is enabled 2025-12-09 14:59:41 -08:00
Alexis Laferrière
85d522e4c2 Merge pull request #85917 from xymus/exportability-nle-classes
Sema: Allow non-open class properties to reference hidden dependencies in non-library-evolution mode
2025-12-09 13:36:01 -08:00
Hamish Knight
f25b4b4fcc Merge pull request #85897 from hamishknight/retraction
[Demangler] Handle invertible reqs for extensions in `findDeclContext`
2025-12-09 14:32:55 +00:00
Egor Zhdan
84e7f82363 Reapply "[ConstraintSystem] C++ Interop: Binding a string literal to std.string shouldn't increase the score"
This reverts commit 6852bc9834.

In addition to the original change, this makes sure that C++ `std::string` and Swift `String` are given distinct score, in order to prevent ambiguity which was causing build failures in some projects.

rdar://158439395
2025-12-09 12:55:18 +00:00
Alexis Laferrière
1fd44e67a2 Sema: Allow refs to hidden dependencies in prorperties of non-open classes
We now report properties referencing types imported from
implementation-only dependencies in non-library-evolution mode as the
memory layouts of structs and enums may be exposed to clients. Here we
exempt non-open classes from this check as clients hold pointers to
classes which hides the class internal memory layouts. Keep forbidding
it for open classes in order to error early, a client trying to subclass
an open class with such a reference from their property would already
see an error about members not deserializable.
2025-12-08 16:39:16 -08:00
Hamish Knight
45683f6561 [Sema] Exclude private initialized vars from memberwise initializer
Exclude properties with initial values from the memberwise initializer
if they are less accessible than the most accessible property, up to
`internal`. Introduce a compatibility overload that continues to
include the same properties as before until the next language mode.

This is gated behind the `ExcludePrivateFromMemberwiseInit` feature.

rdar://122416579
2025-12-08 23:22:35 +00:00
Hamish Knight
302e803b2f [AST] Store original lazy VarDecl for backing storage
Store the original VarDecl in the same map we use for tracking the
original wrapper var for property wrappers. This will allow us to
use the same logic to determine the original var for both.
2025-12-08 23:22:35 +00:00
Hamish Knight
c02fb8b1a1 [AST] Factor out printMemberwiseInit
Move the printing logic into libAST such that it can be used both by
the refactoring and by fix-it logic in Sema.
2025-12-08 23:22:35 +00:00
Alexis Laferrière
de9148e6f1 Merge pull request #85868 from xymus/exportability-nle-split
Sema: Distinguish implicitly visible memory layouts from the typical `@frozen` ones
2025-12-08 13:29:16 -08:00
Hamish Knight
d8a867df86 [Demangler] Handle invertible reqs for extensions in findDeclContext
If we didn't find an extension result, try again disregarding
invertible requirements since `demangleGenericSignature` won't
include them. This is just meant to be a quick low risk fix that we
can cherry-pick, the proper fix here is to delete all this logic and
just return the nominal along with the ABI module name to filter
lookup results.

rdar://165639044
2025-12-08 12:21:29 +00:00
Anthony Latsis
153dd02cd8 Merge pull request #85833 from swiftlang/jepa-main
[NFC] "SwiftVersion" → "LanguageMode" in `DiagnosticEngine::warnUntilSwiftVersion`, etc.
2025-12-05 09:34:30 +00:00
Alexis Laferrière
60731d957c Sema: Use ExportedLevel for isLayoutExposedToClients 2025-12-04 16:51:08 -08:00
Alexis Laferrière
bf951b1591 Sema: Intro ExportedLevel and use it for isExported 2025-12-04 16:45:33 -08:00
Anthony Latsis
88220a33c3 [NFC] "SwiftVersion" → "LanguageMode" in DiagnosticEngine::warnUntilSwiftVersion, etc. 2025-12-04 15:11:07 +00:00
Kavon Farvardin
12cb3f9a9a Merge pull request #85704 from kavon/suppressed-assoc-types-with-defaults
Sema: introduce SuppressedAssociatedTypesWithDefaults
2025-12-03 23:07:40 -08:00
Becca Royal-Gordon
5c2fe422fb Merge pull request #85517 from beccadax/mod-squad-bound-by-its-word
Don’t repeat lookup work that may not round-trip
2025-12-03 20:40:07 -08:00
Tony Allevato
88081a9308 Merge pull request #85807 from allevato/more-json-ast-fixes-2
[ASTDumper] Fix malformed JSON for `async let _ = ...`.
2025-12-03 08:22:29 -05:00
Aidan Hall
8dcc964ec0 Merge pull request #85732 from aidan-hall/refactor-lifetime-dependence
Make LifetimeDependenceChecker::checkEnumElementDecl a static method
2025-12-03 10:35:40 +00:00
Kavon Farvardin
c9d2f522c0 Sema: introduce ProtocolInversesRequest
We need special handling for protocols whose requirement
signature exists but is in a serialized state, as we
cannot run the StructuralRequirementsRequest on such
a protocol as there's no work to be done, effectively.
2025-12-02 21:09:54 -08:00
Kavon Farvardin
6f95203dfd Sema: introduce SuppressedAssociatedTypesWithDefaults
This is similar to SuppressedAssociatedTypes, but infers
default requirements when primary associated types of
protocols are suppressed. This defaulting for the primary
associated types happens in extensions of the protocol,
along with generic parameters, whenever a source-written
requirement states a conformance requirement for the protocol.

Thus, the current scheme for this defaulting is a simplistic,
driven by source-written requirements, rather than facts
that are inferred while building generic signatures.

Defaults are not expanded for infinitely many associated types.

rdar://135168163
2025-12-02 18:00:03 -08:00
Kavon Farvardin
761502fabe NFC: explain the missingInverses 2025-12-02 18:00:02 -08:00
Hamish Knight
019520b25f Merge pull request #85740 from hamishknight/out-of-place
Rework emission of EditorPlaceholderExprs
2025-12-02 23:25:40 +00:00
Tony Allevato
7ec3789cf7 [ASTDumper] Fix malformed JSON for async let _ = ....
By calling `printCommon` twice, this inserts a JSON object into
another JSON object without a key. This asserts inside LLVM's
JSON helper, but only if the compiler is built with assertions
enabled (which Xcode's compiler doesn't).

This also fixes the S-expression version, which is similarly busted:

```
(pattern_entry
  (async_let  type="Int"              (pattern_any type="Int")
  (original_init=call_expr type="Int" ...
```
2025-12-02 16:26:09 -05:00
Tony Allevato
a437c6d6f6 Merge pull request #85681 from allevato/more-json-ast-fixes
[ASTDumper] Fix some more JSON AST dump crashes.
2025-12-02 15:59:21 -05:00
Pavel Yaskevich
b6291e680d Merge pull request #85736 from xedin/rdar-122963120
[ASTPrinter] Print a fully resolved type for an outermost property wr…
2025-12-02 11:54:53 -08:00
Egor Zhdan
61fc6356e0 Merge pull request #85486 from egorzhdan/egorzhdan/wrap-in-objc
[cxx-interop] Wrap methods that take Obj-C params in `#if defined(__OBJC__)`
2025-12-01 22:58:49 +00:00
Hamish Knight
ae82b29e35 Rework emission of EditorPlaceholderExprs
Rather than synthesizing a semantic expression to emit, add a compiler
intrinsic to the stdlib that is simple enough to just SILGen the
emission.
2025-11-30 11:12:39 +00:00
Pavel Yaskevich
5b665a8426 [ASTPrinter] Print a fully resolved type for an outermost property wrapper in swift interfaces
The type of an outermost property wrapper should be printed together
with (inferred) generic arguments because otherwise if a any wrapper
in the chain has generic parameters that are not involved in
`wrappedValue:` argument it won't be impossible to infer them while
type-checking the interface file where it appears.

Resolves: rdar://122963120
2025-11-28 22:00:14 -08:00
Aidan Hall
df1de0961a Make LifetimeDependenceChecker::checkEnumElementDecl a static method
Lifetime dependence checking for enum elements is simple, and almost entirely
contained within this method. Making it a static method separates it from the
mostly unrelated code for AbstractFunctionDecl.

We could have made it a stand-alone function; this just minimises the diff size.

This is a preliminary step in refactoring LifetimeDependenceChecker to support
closures.
2025-11-28 17:23:33 +00:00
Tony Allevato
8805d94c79 [ASTDumper] Print decl-refs, not full decls, for function captures.
This avoids infinite recursion when a function captures itself; e.g.,

```swift
func foo() {
  func bar() {
    bar()
  }
  bar()
}
```

It also just avoids printing unnecessarily verbose information,
since those decls would have already been dumped elsewhere in the
tree.
2025-11-24 13:12:02 -05:00
Tony Allevato
7cca6d6a1a [ASTDumper] Don't attempt to compute type USR for ModuleTypes.
`ModuleType`s show up in some rare places, like the left-hand-side of
a `DotSyntaxBaseIgnoredExpr` for a module-qualified function call.
ASTMangler does not support these because they're not real types.
2025-11-24 12:51:08 -05:00
Slava Pestov
fa55b2520d Merge pull request #85593 from slavapestov/lazy-opaque-type-decl
Serialization: Lazily deserialize OpaqueTypeDecl's underlying substitutions
2025-11-21 00:43:22 -05:00
Sam Pyankov
7c8766fac8 Merge pull request #85571 from sepy97/desugar-inherited-ParaProtoType
ModuleInterface: Avoid printing generic arguments of a ParameterizedProtocolType in inheritance clause
2025-11-20 18:29:52 -08:00
Slava Pestov
27097430cc Serialization: Lazily deserialize OpaqueTypeDecl's underlying substitutions
We need to serialize the underlying type substitution map for an
inlinable function. However, there is no reason to deserialize it
eagerly, since doing so can lead to cycles. It is better for
correctness and performance to only deserialize it when needed.

Technically this fixes a regression from #84299, but the actual
problem was there all along, it was just exposed by my change
on a specific project.

Fixes rdar://163301203.
2025-11-20 18:13:50 -05:00
Henrik G. Olsson
2211824798 Merge pull request #85468 from hnrklssn/revert-dedup-clang-module-imports
Revert "Sema: Prefer the submodule import for access-levels diagnostics"
2025-11-20 10:22:45 -08:00
Aidan Hall
2c9013b2a4 Merge pull request #84648 from swiftlang/users/kovdan01/ast-bridges-for-autodiff-closure-spec
Bridging: Implement bridges required for ongoing AutoDiff changes
2025-11-20 14:45:28 +00:00
Henrik G. Olsson
ba7b9b0d6b Revert "Sema: Prefer the submodule import for access-levels diagnostics"
This reverts commit ca8792ca37.

Revert "[ImportResolution] Gracefully handle importing broken clang module"

This reverts commit edb48dff8c.

Revert "[ImportResolution] Don't deduplicate scoped imports"

This reverts commit da96079eb0.

Revert "[ImportResolution] Deduplicate top-level clang modules from import list"

This reverts commit 0ea5677aa1.

Reverting due to namelookup errors.

rdar://164588082
2025-11-19 23:10:14 -08:00
Sam Pyankov
480b64ef50 ModuleInterface: Avoid printing generic arguments of a ParameterizedProtocolType in inheritance clause
When emitting module interfaces, parameterized protocols in inheritance clauses were being printed with generic arguments (public struct T: Fancy<Float64>), causing errors with protocol conformance verification.
The fix strip ParameterizedProtocolType to its base protocol type when printing inherited types, producing the correct inheritance clause.

Resolves: rdar://161925627
2025-11-19 10:27:15 -08:00
Hamish Knight
4992c7ab8b Merge pull request #85538 from hamishknight/binding-fixes
[Sema] A couple of binding-related crasher fixes
2025-11-18 19:48:25 +00:00
Egor Zhdan
4234fb7358 Merge pull request #85340 from egorzhdan/egorzhdan/revert-cs-std-string
Revert "[ConstraintSystem] C++ Interop: Binding a string literal to `std.string` shouldn't increase the score"
2025-11-18 18:51:12 +00:00