Commit Graph

21693 Commits

Author SHA1 Message Date
Slava Pestov
afbd81a599 AST/Sema: Use ProtocolConformanceRef::getTypeWitness() 2024-09-19 14:18:33 -04:00
Slava Pestov
26241a50f3 AST: Remove DependentMemberType::substBaseType() 2024-09-19 14:18:33 -04:00
Slava Pestov
43b74934ff AST: Refactor ParameterizedProtocolType::getRequirements() 2024-09-19 14:18:33 -04:00
Slava Pestov
508dacc3a2 AST: Add ProtocolConformanceRef::getTypeWitness() 2024-09-19 14:18:33 -04:00
Slava Pestov
da0130d297 AST: Replace calls to substBaseType() with getAssociatedType() 2024-09-19 14:18:32 -04:00
Slava Pestov
a8ed7ba61d AST: Allow ProtocolConformanceRef::getAssociatedType() with invalid conformance 2024-09-19 14:18:32 -04:00
Slava Pestov
532e048abb AST: Remove DependentMemberType::substRootParam() 2024-09-19 14:18:32 -04:00
Slava Pestov
7f83f16e68 AST: Simplify and optimize getTypeOfMember() 2024-09-19 14:18:31 -04:00
Sima Nerush
7e5a57a07a Guard the changes behind an experimental feature flag. 2024-09-19 10:09:56 -07:00
Slava Pestov
490c26f94d AST: Remove a usage of TypeSubstitutionMap 2024-09-19 12:54:26 -04:00
swift-ci
df338c19a8 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-19 09:34:45 -07:00
Gábor Horváth
4d01253674 Merge pull request #76429 from swiftlang/gaborh/safe-cxx-interop-mode
[cxx-interop] Introduce a safe C++ interop mode
2024-09-19 17:25:28 +01:00
Michael Gottesman
fb281331b3 Merge pull request #76558 from gottesmm/pr-39b63781333d46b16f086a7c192efc67b26255db
[concurrency] Behind the flag UnspecifiedMeansMainActorIsolated, try inferring by default main actor isolation instead of nonisolated for unspecified.
2024-09-19 09:18:33 -07:00
Gabor Horvath
929c0ca7d8 [cxx-interop] Introduce a safe C++ interop mode
In this mode all C++ types are imported as unsafe by default. Users
explicitly marking types are escapable or not escapable can make them
imported as safe. In the future, we also want to import unannotated
functions as unsafe and add more logic to infer types that are actually
safe, like agregates of escapable types.
2024-09-19 12:34:07 +01:00
Doug Gregor
5b2520e379 Remove IfConfigDecl from the AST
The swift-syntax tree retains information about the parsed #if
regions. Drop it from the semantic AST.
2024-09-18 20:51:54 -07:00
swift-ci
8cb717628d Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 16:57:07 -07:00
Tony Allevato
4bb9a587fa Merge pull request #76456 from allevato/system-module-check
[AST] Make `IsNonUserModuleRequest` consider `SourceFile` inputs as well.
2024-09-18 19:36:18 -04:00
Michael Gottesman
3843899c19 [concurrency] Behind the flag UnspecifiedMeansMainActorIsolated, try inferring by default main actor isolation instead of nonisolated for unspecified.
Just to play with.
2024-09-18 13:23:23 -07:00
swift-ci
6964118e7e Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 13:17:04 -07:00
Doug Gregor
3a570e060c Merge pull request #76551 from DougGregor/one-loc-to-file-lookup
Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
2024-09-18 12:55:08 -07:00
swift-ci
5039a2d86c Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 10:55:29 -07:00
Doug Gregor
da0c70f301 Merge pull request #76512 from DougGregor/sourcefile-nonopt-buffer
Ensure that SourceFiles always have a backing buffer in the SourceManager
2024-09-18 10:54:52 -07:00
Michael Gottesman
2eea17ac1d Merge pull request #76491 from gottesmm/rdar135594964
[sending] Look through the sending type repr when printing the type of a function result using the type repr fallback path.
2024-09-18 10:38:55 -07:00
swift-ci
ab164eab78 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-18 09:36:24 -07:00
Pavel Yaskevich
43e19358d7 Merge pull request #76458 from xedin/rdar-131347583
[Concurrency] Allow global actor mismatches while overriding `@precon…
2024-09-18 09:16:57 -07:00
Doug Gregor
8febd3fb32 Reimplement ModuleDecl::getSourceFileContainingLocation() using SourceManager
ModuleDecl kept track of all of the source files in the module so that it
could find the source file containing a given location, which relied on
a sorted array all of these source files. SourceManager has its own
similar data structure for a similar query mapping the locations to
buffer IDs.

Replace ModuleDecl's dats structure with a use of the SourceManager's version
with the mapping from buffer IDs to source files.
2024-09-18 07:45:50 -07:00
Michael Gottesman
15a34a530f [sending] Look through the sending type repr when printing the type of a function result using the type repr fallback path.
When we print types in the AST printer if for some reason we cannot find the
appropriate type to print or if the user explicitly asks, we fall back and use a
type repr instead.

This behavior causes a problem due to the implementation of sending results
using a sending type repr to communicate that the relevant function has a
sending result, but we actually do not use the sending type repr from that point
on. So as a result, in this fallback case, we put in one too many sending on the
result.

rdar://135594964
2024-09-17 16:54:42 -07:00
Doug Gregor
6f88c228df Maintain a buffer ID -> source file(s) mapping in the source manager
Now that every source file has a buffer ID, introduce the reverse mapping
so clients can find the source file(s) in their module that reference
that buffer ID.
2024-09-17 14:01:58 -07:00
Doug Gregor
0bd519599f Silence warning about mismatched signs 2024-09-17 13:16:15 -07:00
Doug Gregor
031be421d1 Ensure that we don't get a very-likely-wrong buffer ID
-1 was once used as a sentinel value for "no buffer"; make sure it
doesn't persist anywhere.
2024-09-17 07:41:02 -07:00
Tony Allevato
67d9eecd50 [AST] Make IsNonUserModuleRequest consider SourceFile inputs as well.
We're using a small custom frontend tool to generate indexstore data for `.swiftinterface` files in the SDKs. We do this by treating the `.swiftinterface` file as the input of an interface compilation, but this exits early because it treats it as a `SourceFile` instead of an external `LoadedFile`. This happens even if we call `setIsSystemModule(true)` unless we skip setting the SDK path, but that causes other problems. It seems harmless to check for `SourceFile`s as well, so that a tool processing an SDK interface as a direct input still gets the right state.
2024-09-17 09:44:42 -04:00
Konrad `ktoso` Malawski
7d1ce789ad Revert "Revert "Isolated synchronous deinit"" 2024-09-17 17:35:38 +09:00
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -07:00
swift-ci
22caa59910 Merge remote-tracking branch 'origin/main' into rebranch 2024-09-16 20:34:39 -07:00
Doug Gregor
05e8140c6d Provide macro module name in MacroExpansionExpr creation
This properly passes the module name through from attached macros to
the freestanding macro that are used under-the-hood for type checking.
2024-09-16 16:44:17 -07:00
Ben Barham
a7b50f357f Merge remote-tracking branch 'origin/main' into manual-main-merge
Conflicts:
  - `lib/Driver/ToolChains.cpp` conflicting with the `addAllArgs` rename
    for multiple options
2024-09-16 13:53:18 -07:00
Meghana Gupta
58c6a2fb31 Merge pull request #76455 from meg-gupta/enablestdlib
Enable NonEscapableTypes in standard library and make the feature suppressible
2024-09-16 11:52:41 -07:00
Slava Pestov
d57b6d748b RequirementMachine: Forgot to re-enable an assert 2024-09-14 23:33:11 -04:00
Slava Pestov
fbe3d71b19 RequirementMachine: Small cleanup 2024-09-14 23:33:11 -04:00
Hamish Knight
46121844ce Merge pull request #76444 from hamishknight/remove-typealias-special-case
[Sema] Remove workaround from `TypeExpr::createForSpecializedDecl`
2024-09-14 15:32:58 +01:00
Slava Pestov
f35c90a6b7 Merge pull request #76445 from slavapestov/maptypeintocontext
Overhaul mapTypeIntoContext()
2024-09-14 08:45:20 -04:00
Allan Shortlidge
02dbb96b94 AST: Rename AvailabilityContext to AvailabilityRange.
The generality of the `AvailabilityContext` name made it seem like it
encapsulates more than it does. Really it just augments `VersionRange` with
additional set algebra operations that are useful for availability
computations. The `AvailabilityContext` name should be reserved for something
pulls together more than just a single version.
2024-09-13 16:25:18 -07:00
Meghana Gupta
68bfc0d3b4 Make NonEscapableTypes as a suppressible experimental feature 2024-09-13 13:13:17 -07:00
Kavon Farvardin
626e5118d1 Merge pull request #76432 from kavon/sink-opaque-return-fix
ASTMangler: sink fix to be more safe
2024-09-13 13:08:10 -07:00
Slava Pestov
4afdc9d0bf AST: Lazily map archetype superclass into context
We don't really want to support this, at least not yet, but there
are ways to sneak it past the diagnostic that are hard to close.

Fixes rdar://problem/135348472.
2024-09-13 15:34:48 -04:00
Slava Pestov
08bb0017f5 AST: Add GenericSignatureImpl::getReducedTypeParameter()
This avoids a bit of indirection when the input is already known to be
a type parameter, and not just a type that contains type parameters.
2024-09-13 15:19:48 -04:00
Slava Pestov
be9d999e64 AST: Simplify GenericSignature::getLocalRequirements() 2024-09-13 15:19:48 -04:00
Slava Pestov
4923521227 AST: Re-implement GenericEnvironment::mapTypeIntoContext() using TypeTransform 2024-09-13 15:19:48 -04:00
Pavel Yaskevich
22b9dd7f7b [Concurrency] Allow global actor mismatches while overriding @preconcurrency members in Swift 5 mode
Downgrade a mismatch on global actor attributes to a warning until
Swift 6 to enable class authors to introduce concurrency annotations
to overridable members.

Resolves: rdar://131347583
2024-09-13 11:28:47 -07:00
Slava Pestov
a19ee6366e AST: Remove useless overload of GenericEnvironment::mapTypeIntoContext() 2024-09-13 08:12:51 -04:00