Commit Graph

29571 Commits

Author SHA1 Message Date
Slava Pestov
c52affbd68 Merge pull request #37440 from slavapestov/clean-up-generic-requirement-checking
Clean up duplicate logic for checking if generic requirements are satisfied
2021-05-17 19:28:18 -04:00
Ben Langmuir
006e78e672 Merge pull request #37320 from fwcd/sourcekit-diagnostic-ids
[SourceKit] Add id and category to diagnostics
2021-05-17 14:25:40 -07:00
Slava Pestov
131d3f4bce Sema: Pass down a ModuleDecl instead of a DeclContext to conformsToProtocol()
... and a bunch of follow-up simplifications pushing ModuleDecls further
up, since I couldn't resist the yak shave.
2021-05-17 16:34:18 -04:00
Slava Pestov
fe06df8288 AST: Move guts of checkGenericArguments() to a new Requirement::isSatisfied() method 2021-05-17 16:34:17 -04:00
Pavel Yaskevich
f69dfc2e9a Merge pull request #36705 from HassanElDesouky/delay-loading-localization
[Localization] Delay loading localization on startup
2021-05-14 20:26:29 -07:00
Xi Ge
e24eef4b35 driver: emit a warning when user specified flags to disable the new driver
rdar://78021402
2021-05-14 11:00:36 -07:00
Hamish Knight
5b2f40a006 Merge pull request #37411 from hamishknight/returning-so-soon 2021-05-14 13:37:17 +01:00
Hamish Knight
854a8bcb42 [IDE] Allow SourceEntityWalker to keep track of its ASTWalker
This will allow it to be queried for things like
the parent ASTNode in the current traversal.
2021-05-14 11:17:59 +01:00
swift-ci
2074057785 Merge pull request #37415 from DougGregor/remove-asynchandler 2021-05-13 19:47:46 -07:00
Doug Gregor
2b9ca315fe [Concurrency] Remove asyncHandler attribute.
The `asyncHandler` attribute turned out to be the wrong solution
to the problem of creating a sync->async bridge. Remove it.
2021-05-13 17:01:39 -07:00
Hassan
481b29b6ca [Localization] Delay loading localization
- Add `LocalizationProducerState` to manage the states of LocalizationProducers.
- Add `initializeImpl` and `initializeIfNeeded` to manage lazily initialization of `LocalizationProducer`s.
- Move constructing a localization producer from DiagEngine to `LocalizationProrducer` itself.
2021-05-14 01:28:55 +02:00
swift-ci
e87f237ea8 Merge pull request #37397 from jirid/SR-14453-remove-enable-swiftcall 2021-05-13 15:46:45 -07:00
fwcd
da77e61d76 Remove deprecation tag from use_of_qq_on_non_optional_value 2021-05-14 00:42:32 +02:00
Pavel Yaskevich
3823966e01 Merge pull request #37395 from xedin/rdar-75849035
[Concurrency] Actor cannot conform to global actor isolated protocol
2021-05-13 13:44:07 -07:00
Xi Ge
42a89af00c Merge pull request #37355 from nkcsgexi/77676064-flag
Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
2021-05-13 11:45:32 -07:00
Xi Ge
b6cd513534 Frontend: teach the compiler to use a backup directory to find .swiftinterface files to compile
This mechanism allows the compiler to use a backup interface file to build into a binary module when
a corresponding interface file from the SDK is failing for whatever reasons. This mechansim should be entirely opaque
to end users except several diagnostic messages communicating backup interfaces are used.

Part of rdar://77676064
2021-05-13 09:11:45 -07:00
Ben Barham
8569c8a51b [Refactoring] Avoid redeclarations or shadowing in async refactored code
When converting a call or function, rename declarations such that
redeclaration errors and shadowing are avoided. In some cases this will
be overly conservative, but since any renamed variable can be fixed with
edit all in scope, this is preferred over causing redeclaration errors
or possible shadowing.

Resolves rdar://73973517
2021-05-13 17:48:41 +10:00
Jiri Dutkevic
d4e5014fc8 [SR-14453] Removed unused option enable_swiftcall. 2021-05-12 17:42:47 -07:00
Pavel Yaskevich
ecfff76552 [Concurrency] Actor cannot conform to global actor isolated protocol
Attempting to conform an actor to a global actor isolated protocol
creates a clash in isolation when members are accessed so, let's
detect and diagnose that.

Resolves: rdar://75849035
2021-05-12 16:00:25 -07:00
Artem Chikin
364f154fff Merge pull request #37350 from artemcm/DeployTargetIndependentAvailabilityDiagnostic
Warn about unnecessary availability independently from the deployment target
2021-05-12 15:39:45 -07:00
Artem Chikin
5146bd5191 Report unnecessary availability warnings independently from the deployment target
This change separates emission of the diagnostics like:
```
unnecessary check for 'Platform'; enclosing scope ensures guard will always be true
```
from the deployment target of the current compilation. Instead, these diagnostics will only be emitted if the enclosing scope guard is explicitly specified by the user with an `#availability` attribute.

This fixes cases like the following:
```
@available(macOS 11.0, *)
class Foo {
    func foo() {
        if #available(macOS 11.1, *) {}
    }
}
```
Compiling this with `-target x86_64-apple-macos11.2` results in:
```
warning: unnecessary check for 'macOS'; enclosing scope ensures guard will always be true
        if #available(macOS 11.1, *) {}
.../test.swift:2:7: note: enclosing scope here
class Foo {
```
Even though in source-code the enclosing scope (`Foo`) of this guard does not ensure it will always be true.
This happens because availability range is propagated by intersecting ranges top-down from the root `TypeRefinementContext`, which is defined by the deployment target, causing the availability range on class `Foo` to become `11.2`.

Users may be sharing the same piece of source-code across different projects with their own respective deployment targets which makes such target-dependent warnings confusing at some times, and not-useful at others.
We should rather have the warning simply reflect what is in the source.

Resolves rdar://77607488
2021-05-12 11:57:57 -07:00
Pavel Yaskevich
d500f9cc8a Merge pull request #37373 from xedin/rdar-76058892
[CSSimplify] Increase fix impact when passing closure to a non-function type parameter
2021-05-12 00:30:17 -07:00
Xi Ge
93eae81b04 Merge pull request #37375 from nkcsgexi/diagnose-new-driver-only-options
Driver: diagnose options that are only supported in the new driver
2021-05-11 19:05:30 -07:00
fredriss
3ed11125f3 Merge pull request #37325 from fredriss/async-task-id
[Concurrency] Add a unique Task ID to AsyncTask
2021-05-11 17:59:47 -07:00
Xi Ge
01b1aea958 Driver: diagnose options that are only supported in the new driver 2021-05-11 16:28:57 -07:00
Pavel Yaskevich
c346bbd514 [Diagnostics] Point out where anonymous closure parameters are used in a multi-statement closure 2021-05-11 15:07:44 -07:00
Dario Rexin
29883c806f [Sema] Refactor enum Codable synthesis (#36685) 2021-05-11 13:40:39 -07:00
fwcd
3d78bd74ee Unmark notes as deprecations 2021-05-11 17:38:41 +02:00
Fred Riss
bbda706393 [Concurrency] Add a unique Task ID to AsyncTask
This commit changes JobFlags storage to be 32bits, but leaves the runtime
API expressed in terms of size_t. This allows us to pack an Id in the
32bits we freed up.

The offset of this Id in the AsyncTask is an ABI constant. This way
introspection tools can extract the currently running task identifier
without any need for special APIs.
2021-05-11 08:28:17 -07:00
swift-ci
44626919de Merge pull request #37356 from eltociear/patch-17 2021-05-11 01:24:45 -07:00
Ikko Ashimine
4dea05ff45 [SIL] Fix typo in SILNodes.def
heirarchy -> hierarchy
2021-05-11 11:19:36 +09:00
Konrad `ktoso` Malawski
6cbb792f92 [TaskLocals] Propagate task-locals through async{} 2021-05-11 11:06:17 +09:00
Konrad `ktoso` Malawski
82e91b7785 [TaskLocals] Enable sync functions to bind task-locals; Keep Storage in TLS 2021-05-11 11:06:16 +09:00
Pavel Yaskevich
2fdebccbd7 Merge pull request #37342 from xedin/rdar-77466241
[ResultBuilders] Diagnose pre-check errors inline
2021-05-10 15:53:26 -07:00
Rintaro Ishizaki
861bbcc5d6 Merge pull request #37330 from rintaro/ide-completion-rdar75620636
[CodeCompletion] Make object literals optional
2021-05-10 13:47:10 -07:00
Dario Rexin
efe6973293 [Concurrency] Reduce overhead of Task.yield and Task.sleep (#37090)
* [Concurrency] Reduce overhead of Task.yield and Task.sleep

Instead of creating a new task, we create a simple job that wraps a Builtin.RawUnsafeContinuation and resumes the continuation when it is executed. The job instance is allocated on the task local allocator, meaning we don't malloc anything.

* Update stdlib/public/Concurrency/Task.swift

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>

Co-authored-by: Konrad `ktoso` Malawski <konrad.malawski@project13.pl>
2021-05-10 11:51:20 -07:00
Pavel Yaskevich
4b0d9a2509 [ResultBuilders] Diagnose pre-check errors inline
Not all of the pre-check errors could be diagnosed by re-running
`PreCheckExpression` e.g. key path expressions are mutated to
a particular form after an error has been produced.

To make the behavior consistent, let's allow pre-check to emit
diagnostics and unify pre-check and constraint generation fixes.

Resolves: rdar://77466241
2021-05-10 11:06:58 -07:00
adrian-prantl
6d5d4e6dc7 Merge pull request #37331 from adrian-prantl/77530286
Add a missing check for the number of children before accessing them.
2021-05-10 09:21:41 -07:00
Slava Pestov
e91b305b94 Merge pull request #37154 from slavapestov/new-redundant-requirements-algorithm-part-2
GSB: New algorithm for computing redundant requirements
2021-05-08 16:50:27 -04:00
fwcd
d9e2bcd9ba Mark deprecation/no-usage diagnostics 2021-05-08 16:29:51 +02:00
fwcd
9a86d2ecd2 Add diagnostic categories indicating deprecations and non-usage 2021-05-08 16:19:59 +02:00
swift-ci
7f4a1d5e20 Merge pull request #37334 from DougGregor/implicit-self-capture-feature 2021-05-07 22:22:19 -07:00
Doug Gregor
9411baab9f Add feature for _implicitSelfCapture attribute.
Fixes rdar://77681413.
2021-05-07 19:53:31 -07:00
Rintaro Ishizaki
5ea60e8044 Merge pull request #37300 from rintaro/ide-completion-rdar76355581
[CodeCompletion] Complete pattern introducer for 'for'
2021-05-07 18:41:04 -07:00
Adrian Prantl
a50c048aa0 Add a missing check for the number of children before accessing them.
parentDemangling is going to be added as the first child of the return node, so
we can't construct one unless we have both children.

rdar://77530286
2021-05-07 16:49:31 -07:00
Rintaro Ishizaki
da96ef1f51 [CodeCompletion] Make object literals optional
For example, non-Darwin platforms probably don't want
`#colorLiteral(red:green:blue":alpha:)` and `#imageLiteral(named:)`.
Add an completion option to include them, which is "on" by default.

rdar://75620636
2021-05-07 16:27:13 -07:00
Slava Pestov
e45b566642 GSB: Try harder to prove derivation via redundant requirements
Consider a signature with a conformance requirement, and two
identical superclass requirements, both of which make the
conformance requirement redundant.

The conformance will have two requirement sources, the explicit
source and a derived source based on one of the two superclass
requirements, whichever one was processed first.

If we end up marking the *other* superclass requirement as
redundant, we would incorrectly conclude that the conformance
was not redundant. Instead, if a derived source is based on a
redundant requirement, we can't just discard it right away;
instead, we have to check if that source could have been
derived some other way.
2021-05-07 18:43:57 -04:00
Slava Pestov
2d77260d1a GSB: Clean up and comment redundant requirement algorithm some more 2021-05-07 18:43:52 -04:00
Slava Pestov
aa865a2133 GSB: Stop computing 'derived via concrete' sources 2021-05-07 18:43:52 -04:00
Slava Pestov
710621c2eb GSB: Remove checkConformanceConstraints() 2021-05-07 18:43:52 -04:00