Commit Graph

3290 Commits

Author SHA1 Message Date
Doug Gregor
525e245e0a Merge pull request #73909 from DougGregor/let-instance-property-mutability-fix
Ensure that we do not turn rvalues into lvalues
2024-05-24 22:34:58 -07:00
Doug Gregor
d051b62676 Ensure that we do not turn rvalues into lvalues
The computation that determined whether an access to a `let` instance
property within a constructor should be an initialization conflated the
cases of "we don't have a base expression" and "the base expression is
not something that could be `self`", and incorrectly identified rvalue
bases as being "initializable". Make the interface properly separate
out these cases, so we don't turn an lvalue into an rvalue access.

Fixes rdar://128661833.
2024-05-24 18:22:04 -07:00
Arnold Schwaighofer
58cc2a4090 Merge pull request #73794 from aschwaighofer/package_cmo_opaque_type_subst
Fix opaque type substitution in the package cmo resilience domain
2024-05-23 18:53:15 -07:00
Andrew Trick
4a1662de31 Merge pull request #73792 from apple/egorzhdan/is-frt-check
[cxx-interop] Avoid treating some Obj-C types as foreign reference types
2024-05-22 08:31:02 -07:00
Ellie Shin
c0720d5fb3 Merge pull request #73686 from apple/elsh/ir-global-accessor
Fix global accessor and class linker errors in package.
2024-05-21 22:59:10 -07:00
Ellie Shin
063d159d1b Rename isFragile() as isStrictlyResilient() in var decl.
Add isStrictlyResilient() to nominal type and module decl.
2024-05-21 18:25:10 -07:00
Arnold Schwaighofer
748b69d5ad [Package CMO] Fix opaque type substitution in the package cmo resilience domain
rdar://128482863
2024-05-21 13:22:00 -07:00
Egor Zhdan
9f9fdd9b7f [cxx-interop] Avoid treating some Obj-C types as foreign reference types
This makes sure we don't apply logic that is specific to C++ reference types to Objective-C types.

Previously we were mistakenly treating some Objective-C types as foreign reference types. This meant that IRGen would try to emit calls to custom lifetime operations. This should not happen for non-C++ types.

rdar://128447046
2024-05-21 20:43:49 +01:00
Becca Royal-Gordon
d9912009b0 Merge pull request #73309 from beccadax/objcimpl-category-on-objc 2024-05-21 10:19:14 -07:00
Ellie Shin
80855c872b Fix global accessor and class linker errors.
Add global accessors to symbol list if VarDecl is fragile, i.e.
is non-resilient or its defining module allows non-resilient
access.

Don't set the class decl to hidden if it's in a package resilience
domain; even though its defining module is built resilently, the
class symbol should be visible across modules if they are in the
same package with resilience-bypass optimization. In such case,
treat its SubclassScope to Internal.

Resolves rdar://127321129
2024-05-20 14:39:37 -07:00
Michael Gottesman
d759ec97ea Merge pull request #73696 from gottesmm/rdar128216574
[sending] Add support for 'sending'
2024-05-18 05:42:41 -04:00
Becca Royal-Gordon
9db14c36ad Require @objc to be used with @implementation
…for extensions. This change also removes @implementation(CategoryName); you should attach the category name to the @objc attribute instead. And there are small changes to how much checking the compiler will do on an @objc @implementation after the decl checker has discovered a problem with it.
2024-05-17 14:57:32 -07:00
Michael Gottesman
b780ff6696 [sending] Begin parsing 'sending' while still accepting 'transferring'.
A few things:

1. Internally except for in the parser and the clang importer, we only represent
'sending'. This means that it will be easy to remove 'transferring' once enough
time has passed.

2. I included a warning that suggested to the user to change 'transferring' ->
'sending'.

3. I duplicated the parsing diagnostics for 'sending' so both will still get
different sets of diagnostics for parsing issues... but anywhere below parsing,
I have just changed 'transferring' to 'sending' since transferring isn't
represented at those lower levels.

4. Since SendingArgsAndResults is always enabled when TransferringArgsAndResults
is enabled (NOTE not vis-a-versa), we know that we can always parse sending. So
we import "transferring" as "sending". This means that even if one marks a
function with "transferring", the compiler will guard it behind a
SendingArgsAndResults -D flag and in the imported header print out sending.

rdar://128216574
2024-05-16 21:43:50 -07:00
Becca Royal-Gordon
cf541c1da9 [NFC] Hoist getAttributeInsertionLoc() up to Decl
This functionality was previously reserved for ValueDecls. Move it all the way up to Decl; in the process, make it correctly handle EnumElementDecls and EnumCaseDecls.

This change also allows us to generalize `swift::fixDeclarationObjCName()` to work on extensions, though we do not use that capability in this commit.
2024-05-16 18:05:23 -07:00
Becca Royal-Gordon
07b9fe9ce6 Support @objc(CustomName) on extensions
This now specifies a category name that’s used in TBDGen, IRGen, and PrintAsClang. There are also now category name conflict diagnostics; these subsume some @implementation diagnostics.

(It turns out there was already a check for @objc(CustomName) to make sure it wasn’t a selector!)
2024-05-16 13:40:13 -07:00
Becca Royal-Gordon
4ba2f6e95c [NFC] Fix objcImpl request cache
Several offsetting bugs both broke the caching of `ObjCInterfaceAndImplementationRequest` and caused it to usually miss. Fix this whole painful mess. Also has collateral improvements to simple_display().
2024-05-16 13:34:55 -07:00
Michael Gottesman
e3e78ad6bb [sending] Change the internals of sending to be based around 'sending' instead of 'transferring'.
We still only parse transferring... but this sets us up for adding the new
'sending' syntax by first validating that this internal change does not mess up
the current transferring impl since we want both to keep working for now.

rdar://128216574
2024-05-16 12:20:45 -07:00
Ellie Shin
1257db7342 Merge pull request #73566 from apple/elsh/sil-new-attr
[SIL] Add [serialized_for_package] to control package-wide resilience domain in Package-CMO.
2024-05-16 10:17:35 -07:00
Ellie Shin
e632c5ec96 -Add package-cmo check to bypassResilienceInPackage method.
-Fix SILDeclRef getLinkageLimit() for GlobalAccessor to return
Limit::None if bypassResilienceInPackage is enabled.
2024-05-15 16:25:16 -07:00
Doug Gregor
b641c54ee2 Generalize AbstractStorageDecl::isSettable() to return a three-state value
This operation determines whether a particular storage declaration,
when accessed from a particular location, is mutable or not. It has a
particular semantic that `let` declarations, when accessed from an
initializer, are considered mutable even though they can only be
assigned. There is similar logic for init accessors.

Tease apart "truly mutable" from "initializable because we're in an
initializer", introducing AbstractStorageDecl::mutability() to
represent all three states. isSettable() remains available as a thin
shim over mutability() and all clients are unchanged thus far, making
this a no-op refactoring.
2024-05-14 14:35:11 -07:00
Slava Pestov
7e36060331 AST: Remove VarDecl::getOpenedElementEnvironment() 2024-05-10 17:21:17 -04:00
Slava Pestov
8d3064532c AST: Use hasPrimaryArchetype() in a few places 2024-05-10 17:21:17 -04:00
Slava Pestov
4597cc3d74 AST: Change condition to assert in TypeAliasDecl::setUnderlyingType() 2024-05-10 17:21:17 -04:00
Ellie Shin
d182d01c28 Handle package exportability.
This PR treats package access level as exportable, preventing
internally imported types from accidentally being declared in
package decl signatures.

Added package-specific cases to ExportabilityReason and
DisallowedOriginKind to track the validity of imported types
at use sites with package access scope. Added tests to cover
variety of use cases.

Resolves rdar://117586046&125050064&124484388&124306642
2024-05-02 05:17:03 -07:00
Becca Royal-Gordon
07b2b9a01f [NFC] Add @objc to imported ObjC categories
This contains the category name, if there is one.
2024-05-01 12:18:19 -07:00
Becca Royal-Gordon
c3225b066e [NFC] Merge two category name accessors 2024-05-01 12:18:19 -07:00
Slava Pestov
e342a38b87 Sema: Convert TypeChecker::computeCaptures() into two requests
We now compute captures of functions and default arguments
lazily, instead of as a side effect of primary file checking.

Captures of closures are computed as part of the enclosing
context, not lazily, because the type checking of a single
closure body is not lazy.

This fixes a specific issue with the `-experimental-skip-*` flags,
where functions declared after a top-level `guard` statement are
considered to have local captures, but nothing was forcing these
captures to be computed.

Fixes rdar://problem/125981663.
2024-04-20 22:16:25 -04:00
Slava Pestov
55ff73f205 AST: Stronger assertions around CaptureInfo 2024-04-19 17:59:58 -04:00
Anthony Latsis
fa6924a34e ParamDecl: Defend against default argument kind overwrites 2024-04-19 16:57:05 +03:00
Anthony Latsis
516efdf43f [NFC] Parse: Remove needless setDefaultArgumentKind call 2024-04-19 16:57:05 +03:00
Anthony Latsis
1d3a5860e2 [NFC] ParamDecl: Extract write of type-checked default expr into its own method 2024-04-19 16:57:05 +03:00
Anthony Latsis
61bdbd2fe3 Move unsupported super use diagnosis form Parse to Sema 2024-04-19 16:57:04 +03:00
nate-chandler
b00b5aad4f Merge pull request #72646 from nate-chandler/bitwise-copyable/20240327/1
[BitwiseCopyable] Allow suppression via ~.
2024-04-18 07:05:10 -07:00
Allan Shortlidge
bd59db6e15 AST: Refactor missing import diagnostic into standalone utility.
NFC.
2024-04-16 16:29:51 -07:00
Nate Chandler
ba467d2bd2 [Sema] Enable suppression of inferred conformances.
Add the machinery to support suppression of inference of conformance to
protocols that would otherwise be derived automatically.

This commit does not enable any conformances to be suppressed.
2024-04-15 16:46:22 -07:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Meghana Gupta
4b440a1d80 Merge pull request #72916 from meg-gupta/lifetimedepreq
Requestify LifetimeDependenceInfo
2024-04-09 11:28:18 -07:00
Konrad `ktoso` Malawski
7cd9063ba5 [Distributed] Diagnose missing import also for funcs in extensions
Resolves rdar://125813581
2024-04-09 17:08:27 +09:00
Meghana Gupta
bfa6c57ac4 Requestify LifetimeDependenceInfo
Query and cache lifetime dependence info via evaluator requests
2024-04-08 15:15:36 -07:00
Holly Borla
415715ef55 Merge pull request #72863 from hborla/nested-sendable-class
[Concurrency] Classes nested in actors are not semantically final.
2024-04-05 11:39:50 -07:00
Holly Borla
537d7a5a5a [Concurrency] Classes nested in actors are not semantically final.
The check for actor methods in `isSemanticallyFinal` was accidentally
kicking in for class members, which avoided `Sendable` checking on
classes nested in actors.
2024-04-05 08:37:25 -07:00
Michael Gottesman
04e8badb8c [concurrency] Add a new method ActorIsolation::forActorInstanceSelf.
This occurs when working with ActorIsolation in SIL.

This lets us avoid needing to depend on the AST for getting ActorIsolation for
self parameters. Now, we can just create the actor isolation we need based off
of the decl that we have.

The code is based off of forActorInstanceSelf(ValueDecl *decl) along the path
where it just creates isolation based off of the decl's nominal type decl (which
is equivalent to what we are trying to do here).
2024-04-04 10:58:57 -07:00
Ben Barham
293a4341c9 Merge pull request #72744 from bnbarham/rename-endswith
Rename `StringRef::endswith` references to `StringRef::ends_with`
2024-04-02 20:08:01 -07:00
Allan Shortlidge
d421f55009 AST: Request-ify ValueDecl::findImport().
To prevent performance regressions from calling `findImport()` more frequently,
request-ify the computation.

NFC.

Prerequisite of rdar://16154294
2024-04-01 17:44:08 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Doug Gregor
79b78acdf6 Use SuppressibleProtocolSet as InvertibleProtocolSet
Collapse the representations of "suppressible" and "invertible"
protocol sets. Only minor adjustments were required.
2024-03-29 11:31:48 -07:00
Doug Gregor
994e342c98 [Demangle-to-AST] Match invertible-generics extensions with no signature
Introduce a predicate that determines when a given extension corresponds
to what one would get by existing the nominal type without spelling out
any constraints. This differs from the notion of a "constrained
extension" when the nominal type suppresses conformances on any of its
generic parameters, e.g.,

    struct X<T: ~Copyable> { ... }

    // doesn't spell out any constraints, but is constrained because it
    // implicitly adds T: ~Copyable.
    extension X { ... }

    // does spell out constraints, but is not constrained because the
    // generic signature matches that of X.
    extension X where T: ~Copyable { }

Use this predicate when demangling a name to metadata, because name
mangling for extensions suppresses the generic signature for cases
where one "doesn't spell out any constraints."
2024-03-27 17:07:41 -07:00
Doug Gregor
bbfdf7b36a Merge pull request #72470 from DougGregor/dynamic-suppressible-protocols
Metadata and runtime support for suppressible protocol requirements
2024-03-27 11:49:00 -07:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00