Commit Graph

24873 Commits

Author SHA1 Message Date
Kavon Farvardin
dfe3d2a42c Merge pull request #70488 from kavon/ncgenerics-stdlib-building-v2
[NCGenerics] Fix more issues while building the stdlib
2023-12-19 10:19:25 -08:00
Kavon Farvardin
34f359d8d0 [NCGenerics] fix TypeLowering 2023-12-18 18:55:56 -08:00
Angela Laar
c1af52c2f2 Merge pull request #70419 from angela-laar/group-actor-isolation-errors
Group actor isolation errors
2023-12-18 08:42:26 -08:00
Kavon Farvardin
15a6c01a16 Merge pull request #70513 from kavon/delet-underscore-copyable
[NCGenerics] delete `_Copyable` from stdlib
2023-12-16 13:59:58 -08:00
Slava Pestov
f68e0c90f9 Merge pull request #70496 from slavapestov/fix-issue-61934
Sema: Implement missing case in existential erasure
2023-12-16 15:27:55 -05:00
Kavon Farvardin
b43f861827 [NCGenerics] delete _Copyable from stdlib
resolves rdar://115793371
2023-12-16 11:17:31 -08:00
Sima Nerush
2fd5843a79 Merge pull request #70355 from simanerush/pack-iteration-fixes
[SE-0408] Pack iteration review feedback!
2023-12-16 09:50:31 -08:00
Slava Pestov
2b28cb1647 Sema: Implement missing case in existential erasure
Fixes https://github.com/apple/swift/issues/61934.
2023-12-16 12:24:34 -05:00
Sima Nerush
0482bd3652 [Sema] Refactor code and improve documentation pertaining to SE-0408. 2023-12-15 20:39:40 -08:00
Hamish Knight
f10365597d [AST] Use PatternBindingDecl::createImplicit in more places
And simplify the implementation of `create`.
2023-12-15 21:44:30 +00:00
Artem Chikin
33e09f9e87 Merge pull request #70211 from artemcm/ParallelScanFixes
[Dependency Scanning] Remove/move mutable state from parallel scanner workers
2023-12-15 11:14:16 -08:00
Doug Gregor
ab5ab28010 Merge pull request #70454 from DougGregor/full-typed-throws-inference
[Typed throws] Implement thrown type inference for do..catch within closures
2023-12-14 16:09:33 -08:00
Andrew Trick
ace9937e95 Rename NonesapableTypes feature
Follow the feature flag convention for capitalization and be
consistent with the related NoncopyableGenerics feature.

This is a new feature that no wild Swift code has used it yet:

commit e99ce1cc5d
Author: Kavon Farvardin <kfarvardin@apple.com>
Date:   Tue Dec 5 23:25:09 2023

    [NCGenerics] add `~Escapable`

    Basic implementation of `~Escapable` in the type system.
2023-12-14 11:32:03 -08:00
Angela Laar
aed7edfdcf Only group isolation errors if needed 2023-12-14 10:27:52 -08:00
Alex Hoppen
4de38334e0 Merge pull request #70389 from ahoppen/ahoppen/delete-old-namematcher
[SourceKit] Delete old C++ `NameMatcher`
2023-12-14 09:06:44 -08:00
Sophia Poirier
55f9057e61 Merge pull request #70453 from sophiapoirier/unguard-nonisolated-unsafe-feature
[Concurrency] unguard nonisolated(unsafe) attribute from GlobalConcurrency experimental feature
2023-12-14 08:29:21 -08:00
Becca Royal-Gordon
e9672194b4 Merge pull request #69468 from beccadax/c-implementation
Make @objcImpl work with @_cdecl
2023-12-14 00:36:12 -08:00
Rintaro Ishizaki
6783efd95f Merge pull request #70413 from rintaro/ast-stmtcondeleemnt-pointerunion
[AST] Make `StmtConditionElement` a single `PointerIntPair`
2023-12-13 18:36:50 -08:00
Doug Gregor
ae5f66ac11 Record throwing property accesses as potential throw sites 2023-12-13 16:36:14 -08:00
Pavel Yaskevich
2924ce0353 Merge pull request #70409 from xedin/rdar-119001449
[ConstraintSystem] Run `salvage` even if diagnostics are suppressed
2023-12-13 16:16:37 -08:00
Alexis Laferrière
dda7e96503 Merge pull request #70424 from xymus/ambiguity
AST: Specify the module name in errors on ambiguities across modules
2023-12-13 16:07:41 -08:00
Doug Gregor
956c330611 [Constraint solver] Encode thrown error type in references to subscripts
A reference to a subscript (whether instance or static) produces a
function type, which is then applied as part of an application
constraint. Make sure that we encode whether the subscript can throw,
and the thrown error type if present, in that function type. This lets
us correctly treat subscripts as a potential throw sites.
2023-12-13 15:22:21 -08:00
Sophia Poirier
d319404e16 [Concurrency] unguard nonisolated(unsafe) attribute from GlobalConcurrency experimental feature 2023-12-13 15:06:07 -08:00
Doug Gregor
8ad137fb51 [Typed throws] Infer thrown error type for do..catch blocks within closures.
Start classifying all potential throw sites within a constraint
system and associate them with the nearest enclosing catch node. Then,
determine the thrown error type for a given catch node by taking the
union of the thrown errors at each potential throw site. Use this to
compute the error type thrown from the body of a `do..catch` block
within a closure.

This behavior is limited to the upcoming feature `FullTypedThrows`.
2023-12-13 14:59:23 -08:00
Angela Laar
60f3c692be Fix tests 2023-12-13 14:05:37 -08:00
Pavel Yaskevich
e264e8d97c Merge pull request #70382 from xedin/improve-sendability-checking-of-keypth-to-func
[CSBindings] keypath-to-function conversion should respect sendabilit…
2023-12-13 13:53:43 -08:00
Artem Chikin
674dfb3bd4 [Dependency Scanning] Move generation of a named import path 'Identifier' out of the individual scanning workers up into the parent scanner. This operation mutates the scanner ASTContext by potentially adding new identifiers to it and is therefore not thread-safe. 2023-12-13 13:17:05 -08:00
Rintaro Ishizaki
d6556434cd [AST] Make 'StmtConditionElement' a single 'PointerUnion'
Previously, 'IntroducerLoc' and 'ThePattern' were only used for pattern
binidng cases. Create a new 'ConditionalPatternBindingInfo' type to
cover such cases, and make 'StmtConditionElement' a pure 'PointerUnion'
type.

This makes it clear which fields are used in which condition kind. Also,
we can expect overall size reduction of StmtCondition when the
majority of the conditions are simple boolean expressions.
2023-12-13 12:52:53 -08:00
Doug Gregor
e1be9c312b Eliminate the DeclContext from ExplicitCaughtTypeRequest
Correctly determining the DeclContext needed for an
ExplicitCaughtTypeRequest is tricky for a number of callers, and
mistakes here can easily lead to redundant computation of the caught
type, redundant diagnostics, etc.

Instead, put a `DeclContext` into `DoCatchStmt`, because that's the
only catch node that needs a `DeclContext` but does not have one.
2023-12-13 11:42:56 -08:00
Alexis Laferrière
72083bf7e3 Diagnostics: Specify the module name on ambiguities across modules
When a file defining an API is included in two modules, clients calling
that API may get an error about the ambiguity on the duplicated API.
That error is not very helpful when it takes into account the
swiftsourceinfo data and points to the source file instead of the
module. In such a case the notes point twice to the same file and line
of code.

Improve this diagnostic by appending the module name to the notes when a
candidate is found outside of the module.

rdar://116255141
2023-12-13 11:12:39 -08:00
Becca Royal-Gordon
9bd70f3aec Test cImpl type and name mismatches 2023-12-13 11:09:50 -08:00
Becca Royal-Gordon
426e5beb8d Begin checking cdecl implementations
This commit diagnoses cdecl implementations with no matching imported declaration, and also runs them through the ObjCImplementationChecker. Actually testing that the ObjCImplementationChecker diagnoses various failure conditions correctly will be added in a subsequent commit.
2023-12-13 11:09:50 -08:00
Becca Royal-Gordon
6591d4ea82 [NFC] Add accessor for @_cdecl name
It also reads the C name out of imported C functions, which will be convenient for @cdecl @implementation.
2023-12-13 11:09:50 -08:00
Becca Royal-Gordon
b635cab73e [NFC] ObjCImpl: Factor out addRequirement/Candidate 2023-12-13 11:09:50 -08:00
Becca Royal-Gordon
6afbb96fdf [NFC] Abstract selector access in ObjCImpl checker 2023-12-13 11:09:50 -08:00
Becca Royal-Gordon
8651af4325 Make @objcImpl work with @_cdecl
No real diagnostics yet, but we’re emitting mostly correct code.
2023-12-13 11:09:49 -08:00
Doug Gregor
3f518a3b79 [Macros] Don't apply member attribute macros to accessors
Accessors are conceptually nested within their property or subscript
declarations, so member-attribute macros should only apply to the
property or subscript declarations. This eliminates what appears to be
redundant macro expansion.

Fixes rdar://118956800.
2023-12-13 09:26:52 -08:00
Doug Gregor
2cf7b3a063 Merge pull request #70426 from DougGregor/catch-node-refinement
Tighten CatchNode from an AbstractClosureExpr to a ClosureExpr.
2023-12-13 02:32:21 -08:00
Doug Gregor
25faa002a4 Merge pull request #70397 from DougGregor/cleanup-caught-error-type
[Typed throws] Cleanups for the caught error type computation
2023-12-12 23:13:00 -08:00
Doug Gregor
05a4a822ba Tighten CatchNode from an AbstractClosureExpr to a ClosureExpr.
Only real closures can have thrown error types, so we can use the
tighter bound for closures and simplify various CatchNode operations.
2023-12-12 22:30:18 -08:00
Angela Laar
737665cbac [Sema] Group isolation errors in checkApply 2023-12-12 16:23:13 -08:00
Angela Laar
4d2b01b0be Group Actor Isolation errors
The number of errors in a function scope can scale exponentially,
making it hard to root cause and resolve unless we group them into
a single error. Grouping the error diagnostics will considerably
improve the concurrency user experience.
2023-12-12 16:23:10 -08:00
Doug Gregor
010a41243e Fix minor regressions from refactoring of caught error types 2023-12-12 15:39:56 -08:00
Alex Hoppen
e8d148ab86 [build] Move addition of SWIFT_BUILD_SWIFT_SYNTAX preprocessor flag to top-level CMakeLists.txt 2023-12-12 12:58:15 -08:00
Pavel Yaskevich
00bb7d31d8 [CodeCompletion] Use solveForCodeCompletion in getTypeOfExpressionWithoutApplying
Using `ConstraintSystem::solve` would mean re-solving now since
`SuppressDiagnostics` doesn't suppress `salvage`.
2023-12-12 12:30:15 -08:00
Pavel Yaskevich
09a5b99446 [ConstraintSystem] Run salvage even if diagnostics are suppressed
There are some situations where the solver is able to find a valid
solution only during `salvage` (mostly but not limited to unavailable
declarations), which means that we need to keep running `salvage`
even if the diagnostics are suppressed until the underlying issues
in the normal solving mode are fixed.

One of the issues:

```swift
extension Unmanaged {
  @inline(__always)
  internal static func passRetained(_ instance: __owned Instance?) -> Self? {
    guard let instance = instance else { return nil }
    return .passRetained(instance)
  }
}
```

`.passRetained(instance)` is ambiguous during normal solving but
is able to find a solution during `salvage` because it attemtps
more type bindings.

Resolves: rdar://119001449
2023-12-12 10:53:06 -08:00
Slava Pestov
0f71674f9c Merge pull request #70378 from slavapestov/a-major-category-of-problem
Sema: Teach TypeReprCycleCheckWalker to avoid more cycles
2023-12-12 13:40:36 -05:00
Hamish Knight
f25e92f697 Merge pull request #70319 from hamishknight/context-switch
[Sema] Correctly re-contextualize `if`/`switch` exprs in lazy vars
2023-12-12 12:15:50 +00:00
Konrad `ktoso` Malawski
828f589be4 Initial Task Executor implementation Task(on:), addTask(on:) etc. (#68793)
Co-authored-by: John McCall <rjmccall@gmail.com>
2023-12-12 17:14:24 +09:00
Doug Gregor
3369e3349f [Typed throws] Handle explicitly-specified throws on do..catch in closures
Teach the constraint system to use the same primitives as elsewhere to
determine the type context for a `throw` statement and the caught
error type within a `do..catch` statement. This makes
explicitly-specified `throws` work on `do..catch` that occurs in
closures.

Cleans up some redundant computations for caught error types.
2023-12-12 00:06:17 -08:00