Commit Graph

24025 Commits

Author SHA1 Message Date
Pavel Yaskevich
416bbaec8d [TypeChecker] InitAccessors: Fix handling of defaultable init accessor properties during default init synthesis
Default initializable init properties shouldn't prevent default
init synthesis and such properties without anything to initialize
should be considered by it.
2023-08-21 09:05:26 -07:00
Pavel Yaskevich
645e8df6bd [TypeChecker] InitAccessors: Synthesize default init for init accessor properties
Fixes a bug were default initializer for an init accessor property
hasn't been synthesized even when the property is marked as default
initializable.

Resolves: rdar://113421273
2023-08-21 09:04:34 -07:00
Alejandro Alonso
d04d8c1c49 Merge pull request #68001 from Azoy/raw-deserialize
[Sema] Fix raw layout deserialization
2023-08-19 08:55:56 -07:00
Sophia Poirier
aec59f2f9c Merge pull request #67974 from sophiapoirier/global-static-data-race-safety
enforce under strict concurrency that globals and statics be either…
2023-08-19 08:28:02 -07:00
Alejandro Alonso
dadbbb4d02 Fix raw layout deserialization
Update raw_layout.swift
2023-08-18 20:36:27 -07:00
Konrad `ktoso` Malawski
c7538c07c7 Merge pull request #68006 from ktoso/wip-null-witness-executor
[Executors] tryDiagnoseExecutor must survive null witness, when using Backdeploy library
2023-08-19 07:33:44 +09:00
Sophia Poirier
936ab20e5d enforce under strict concurrency that globals and statics be either isolated to a global actor or Sendable plus immutable
rdar://81629027 Global and static variable data-race safety
2023-08-18 15:08:42 -07:00
Allan Shortlidge
0c957a2090 Merge pull request #68009 from tshortli/deprecate-warn-on-potentially-unavailable-enum-case
Frontend: Deprecate -warn-on-potentially-unavailable-enum-case option
2023-08-18 12:37:46 -07:00
Slava Pestov
c2f1193ae3 Merge pull request #67952 from slavapestov/tuple-conformance-tbd-etc
A pile of mostly unrelated one-liners
2023-08-18 15:31:26 -04:00
Allan Shortlidge
be70c568cb Frontend: Deprecate -warn-on-potentially-unavailable-enum-case option.
When `-warn-on-potentially-unavailable-enum-case` was introduced, the build
system was required to invoke `swift-frontend` at artificially low deployment
targets when emitting `.swiftinterface` files for legacy architectures. Because
the deployment target was low, some availability diagnostics needed to be
de-fanged in order to allow module interface emission to succeed. Today, the
build system is able to use the correct deployment target when emitting module
interfaces and the `-warn-on-potentially-unavailable-enum-case` is superfluous,
so deprecate it.

Resolves rdar://114092047
2023-08-18 10:02:39 -07:00
Slava Pestov
010415f4f3 Sema: Force destructor synthesis in evaluateMembersRequest() 2023-08-18 12:12:50 -04:00
zachary0kent
802e63a778 Merge pull request #67973 from zachary0kent/lazy-immediate-globals
[Immediate] JIT'ing Globals
2023-08-18 08:53:18 -07:00
Konrad `ktoso` Malawski
13605b8285 [Executors] isStdlibDefaultImplDecl must guard from null values, coming from Backdeploy library
resolves rdar://114029779
2023-08-18 23:07:56 +09:00
Doug Gregor
1d246629a4 Merge pull request #67998 from DougGregor/observer-macros-on-computed-properties
Improve checking of macro-generated accessors against documented names
2023-08-17 20:46:35 -07:00
Doug Gregor
5d6746d974 Improve checking of macro-generated accessors against documented names
The checking of the accessors generated by a macro against the
documented set of accessors for the macro is slightly too strict and
produces misleading error messages. Make the check slightly looser in
the case where an observer-producing macro (such as
`@ObservationIgnored`) is applied to a computed property. Here, we
would diagnose that the observer did not in fact produce any
observers, even though it couldn't have: computed properties don't get
observers. Remove the diagnostic in this case.

While here, add some tests and improve the wording of diagnostics a
bit.

Fixes rdar://113710199.
2023-08-17 16:59:42 -07:00
Pavel Yaskevich
d725e38cd2 Merge pull request #67971 from amritpan/kp-function-application
[ConstraintSystem] Resolve key path function applications via resolveKeyPath
2023-08-16 23:12:44 -07:00
Doug Gregor
b126a0f34b Merge pull request #67977 from DougGregor/extension-macro-conformances-and-witnesses
[Macros] Fix handling of extension macro conformances and witnesses
2023-08-16 22:46:06 -07:00
zachary0kent
25f078adb5 Merge branch 'main' into lazy-immediate 2023-08-16 19:45:27 -07:00
Zak Kent
831cfb575d [Sema] [NFC] Don't accumulate lazily typechecked functions in lazy immediate mode 2023-08-16 19:30:31 -07:00
Doug Gregor
b7bfaf3522 [Macros] Fix handling of extension macro conformances and witnesses
Fix two inter-related issues with extension macros that provide
conformances to a protocol, the combined effect of which is that one
cannot meaningfully provide extension macros that implement
conformances to a protocol like Equatable or Hashable that also
supports auto-synthesis.

The first issue involves name lookup of operators provided by macro
expansions. The logic for performing qualified lookup in addition to
unqualified lookup (for operators) did not account for extension
macros in the same manner as it did for member macros, so we would not
find a macro-produced operator (such as operator==) in witness
matching.

The second issue is more fundamental, which is that the conformance
lookup table would create `NormalProtocolConformance` instances for
pre-macro-expansion conformance entries, even though these should
always have been superseded by explicit conformances within the macro
expansion buffers. The end result is that we could end up with two
`NormalProtocolConformance` records for the same conformance. Some
code was taught to ignore the pre-expansion placeholder conformances,
other code was not. Instead, we now refuse to create a
`NormalProtocolConformance` for the pre-expansion entries, and remove
all of the special-case checks for this, so we always using the
superseding explicit conformances produced by the macro expansions (or
error if the macros don't produce them).

Fixes rdar://113994346 / https://github.com/apple/swift/issues/66348
2023-08-16 19:18:36 -07:00
Pavel Yaskevich
c38b9b1e08 Merge pull request #67945 from xedin/remove-runtimeMetadata
[Frontend] NFC: Remove code and tests related to rejected @runtimeMetadata feature
2023-08-16 17:16:46 -07:00
Pavel Yaskevich
ab4116717c Merge pull request #67948 from xedin/rdar-113760727
[CSSimplify] Adjust {Any, Partial}KeyPath bindings right before resolving
2023-08-16 15:58:15 -07:00
Amritpan Kaur
f4764b32bf [CSSimplify] Attempt tryMatchRootAndValueFromType even if
missing member.
2023-08-16 14:28:05 -07:00
Amritpan Kaur
6d08e74915 [CSBindings] Add check to include key path function applications. 2023-08-16 12:53:54 -07:00
Amritpan Kaur
feb0f34993 [CSSimplify] For function type binding for key path types, add flag
to allow it to go through resolveKeyPath in matchTypesBindTypeVar.
2023-08-16 12:53:54 -07:00
Doug Gregor
b2f46ba26f Merge pull request #67957 from ktoso/wip-dont-use-loc-validness-in-diagnostics-determination-113913291
[Executors] Do not consider Loc validity in determining to emit error/warning about enqueue(_:)
2023-08-16 12:04:35 -07:00
Konrad `ktoso` Malawski
5e43ba9895 Don't trigger warnings about stdlib itself when user code might trigger them
The standard library's enqueue() does not play by the same rules -- we
provide "deprecated" implementations in  order to remain source/binary
compatible, and showing warnings about this when users make mistake will
only be misleading.
2023-08-16 22:22:37 +09:00
Konrad `ktoso` Malawski
d0b6f4ef10 dont use loc validity to determine if we should diagnose; instead, error if all implementations are "default from stdlib" because end-user MUST implement at least one of them 2023-08-16 20:25:32 +09:00
Becca Royal-Gordon
fa0e6285fc Merge pull request #67925 from beccadax/objcimpl-warning-main
Temporarily soften @objcImpl errors into warnings
2023-08-16 01:34:39 -07:00
Pavel Yaskevich
b34f9720e4 [CSSimplify] Adjust {Any, Partial}KeyPath bindings right before resolving
A type variable that represents a key path literal cannot be bound
directly to `AnyKeyPath` or `PartialKeyPath`, such types could only
be used for conversions.
It used to be the task of the binding inference to infer `AnyKeyPath`
and `PartiaKeyPath` as a `KeyPath` using previously generated type
variables for a root and value associated with key path literal
(previously stored in the locator).

Recently we switched over to storing key path information in the
constraint system and introduced `resolveKeyPath` method to gain
more control over how key path type variable gets assigned.

Getting information from the constraint system creates a problem
for the inference because "undo" for some bindings would be run
after solver scope has been erased, so instead of modifying bindings
in `inferFromRelational`, let's do that in `resolveKeyPath` right
before the key path type variable gets bound which seems to be a
better place for that logic anyway.

Resolves: rdar://113760727
2023-08-15 13:50:54 -07:00
Pavel Yaskevich
b37cebbf94 [Sema] [AST] NFC: Remove @runtimeMetadata related code 2023-08-15 12:17:26 -07:00
Slava Pestov
2fcfa7e357 Sema: Fix unused variable warning in noassert build 2023-08-15 13:52:02 -04:00
Pavel Yaskevich
cedbdf920c Merge pull request #67759 from xedin/rdar-112617922
[CSSimplify] Relax `isBindable` requirements for pack expansion variables
2023-08-15 09:00:12 -07:00
Pavel Yaskevich
37477b3f04 Merge pull request #67915 from xedin/rdar-113745963
Revert "[CSBindings] Prefer conjunctions over closure variables without bindings"
2023-08-14 17:09:36 -07:00
Becca Royal-Gordon
ad960a1e2d Temporarily soften @objcImpl errors into warnings
Temporarily cherry-pick Swift 5.9’s behavior of turning @objcImplementation errors into warnings to 5.10 until we fix the last few bugs in these diagnostics.
2023-08-14 16:49:51 -07:00
swift-ci
1a010ddd79 Merge pull request #67904 from beccadax/your-candidate-is-not-required
Handle inherited required inits in @objcImpl
2023-08-14 13:32:47 -07:00
Zak Kent
d1c5b4a7ad [Parse] [Sema] Ensure lazy immediate mode only enabled when requested 2023-08-14 13:28:22 -07:00
Zak Kent
148cd6acc4 [Immediate] [Sema] Implemented Lazy Type Checking
Implements lazy type checking in Swift Immediate mode,
allowing functions to be type-checked as they are
executed.
2023-08-14 13:28:22 -07:00
Zak Kent
17fedabb5e [Immediate] Implemented SwiftMaterializationUnit
Implemented SwiftMaterializationUnit, supporting
lazy compilation of individual Swift functions.
2023-08-14 13:28:22 -07:00
Becca Royal-Gordon
37e42d178f Handle inherited required inits in @objcImpl
Because `required init`s do not have the `override` keyword, they are always treated as member implementations (if they pass other checks). However, these methods sometimes actually are overrides, and when they are, they should not be treated as member implementations. This results in required inits being treated as candidates when there won’t be a requirement for them to match.

Hack around this by separately checking for this situation and skipping the affected members.

Fixes rdar://112910098.
2023-08-14 11:06:35 -07:00
Pavel Yaskevich
64a654dc0d Revert "[CSBindings] Prefer conjunctions over closure variables without bindings"
This reverts commit 11ee82de7b.
2023-08-14 10:02:05 -07:00
Frederick Kellison-Linn
b2b768f40f Merge pull request #67479 from Jumhyn/enum-expr-optional-matching
[TypeCheckPattern] Attempt ExprPattern conversion before failing pattern coercion to optional
2023-08-11 13:02:28 -04:00
Holly Borla
e13f72e615 Merge pull request #67889 from hborla/extension-macro-multiple-conformances
[Macros] Fix the formatting of the conformance list buffer for extension macro expansion.
2023-08-11 09:37:32 -07:00
Slava Pestov
bc1761a5cb Merge pull request #67876 from slavapestov/tuple-conformance-fixes
Tuple conformance fixes
2023-08-11 09:39:28 -04:00
Hamish Knight
1ef4f801db Merge pull request #67800 from hamishknight/conjunction-order 2023-08-11 10:33:11 +01:00
Holly Borla
0be80c8287 [Macros] Separate each protocol name with commas when forming the conformance
list buffer for extension macro expansion.
2023-08-10 22:13:22 -07:00
Slava Pestov
1f23f7ad67 Sema: Don't emit bogus warnings about Sendable tuple conformance 2023-08-10 16:01:17 -04:00
Allan Shortlidge
22a18e5f2a Merge pull request #67850 from tshortli/unavailable-inlinable-computed-property-availability
Sema: Correct availability for @inlinable global var accessors bodies
2023-08-10 10:17:34 -07:00
Slava Pestov
c6387fd079 Merge pull request #67839 from slavapestov/tuple-conformance-sendable-copyable
Replace bespoke Sendable and Copyable conformance on tuples with tuple conformances
2023-08-10 07:22:14 -04:00
Allan Shortlidge
2cc1a9311d Sema: Correct availability for @inlinable global var accessors bodies.
The bodies of unavailable functions should be typechecked as if they would
always run at the deployment target, even if they are `@inlinable`. This was
not the case in the bodies of unavailable `@inlinable` global var accessor,
though, because the availability of the accessor, rather than enclosing var,
was being queried. The fix is to use `getSemanticUnavailableAttr()`.

Resolves rdar://113642576
2023-08-09 21:49:30 -07:00