Commit Graph

68066 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 Barham
ccd39760cf Merge pull request #37441 from bnbarham/serialization-crashes
[Serialization] Do not assert when inherited type is null
2021-05-18 09:14:06 +10:00
Xi Ge
0d4d98eeb0 Merge pull request #37458 from nkcsgexi/string-as-version
CanImport: allow using string literal to indicate desired version
2021-05-17 14:26:55 -07: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
b556cb5d70 IDE: Refactor SynthesizedExtensionAnalyzer to use Requirement::isSatisfied() 2021-05-17 16:34:18 -04:00
Slava Pestov
73deb7e833 Sema: Introduce a simpler form of checkGenericArguments() 2021-05-17 16:34:18 -04:00
Slava Pestov
ee33f12df7 IDE: Refactor IsDeclApplicableRequest to use Requirement::isSatisfied() 2021-05-17 16:34:17 -04:00
Slava Pestov
6cb64c4a8d AST: Refactor GenericSignature::isRequirementSatisfied() to use Requirement::isSatisfied()
This becomes a utility that maps the requirement's types into the
generic environment if needed before calling out to the new
Requirement::isSatisfied().
2021-05-17 16:34:17 -04:00
Slava Pestov
fe06df8288 AST: Move guts of checkGenericArguments() to a new Requirement::isSatisfied() method 2021-05-17 16:34:17 -04:00
Slava Pestov
40aa87c9f4 Sema: Clean up checkGenericArguments() a bit 2021-05-17 16:31:46 -04:00
Xi Ge
e0b8de4d49 Merge pull request #37455 from nkcsgexi/user-module-subminor
Serialization: embed subminor and build version in the user module version entry
2021-05-17 13:15:25 -07:00
Xi Ge
ebfa459b3e CanImport: allow using string literal to indicate desired version 2021-05-17 11:10:41 -07:00
Xi Ge
5c5715f626 Serialization: embed subminor and build version in the user module version entry 2021-05-17 10:15:47 -07:00
Alex Hoppen
3b2372307c Merge pull request #37421 from ahoppen/pr/fix-crash-complete-in-result-builder-with-nil
[CodeComplete] Fix crash when completing inside a result builder containing a variable initialized with `nil`
2021-05-17 18:56:45 +02:00
Ben Barham
c1e4362dfd [Serialization] Do not assert when inherited type is null
When compiling with allow errors, it's possible to have invalid
inherited types - both null and ErrorType.

Cleaned up the tests a little - moved the majority of
Frontend/allow-errors.swift into separate files in
Serialization/AllowErrors and use split_file.py instead of #defines.

Resolves rdar://78048470
2021-05-15 16:35:23 +10: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
Slava Pestov
760d7997de Merge pull request #37434 from slavapestov/fix-generic-override-crash
Sema: Fix a couple of issues with implicit overrides of generic designated initializers
2021-05-14 23:19:04 -04:00
Slava Pestov
379220b9e2 Sema: Fix a couple of issues with implicit overrides of generic designated initializers
If a base class initializer was not generic but had a contextual 'where'
clause, we would unconditionally inherit the 'where' clause in the override as
part of the fix for another issue (https://bugs.swift.org/browse/SR-14118).

However, it is possible that some of those requirements are satisfied by
the derived class itself. For example:

    class Base<T> {
        init() where T : AnyObject {}
    }

    class Derived : Base<AnyObject> {}

In this case, the implicit override Derived.init() has no generic requirements
at all. We used to assert because we would create a GSB with no generic
parameters.

It was also possible for a base class initializer to have generic
requirements that are not satisfied by the derived class. In this case,
we need to drop the initializer from consideration altogether.

While I'm here, I improved the comments in computeDesignatedInitOverrideSignature(),
which is the new name for configureGenericDesignatedInitOverride().

Fixes rdar://problem/77285618.
2021-05-14 19:02:57 -04:00
Alex Hoppen
ad5dc2d76f [CodeComplete] Fix crash when completing inside a result builder containing a variable initialized with nil
Resolves rdar://78017503
2021-05-14 17:21:26 +02:00
Alex Hoppen
b0bade6711 Merge pull request #37417 from bnbarham/add-completionhandler-attribute
[Refactoring] Add @completionHandlerAsync to sync function
2021-05-14 17:09:58 +02:00
Hamish Knight
5b2f40a006 Merge pull request #37411 from hamishknight/returning-so-soon 2021-05-14 13:37:17 +01:00
Ben Barham
762337cc9b [Refactoring] Add @completionHandlerAsync to sync function
When adding an async alternative, add the @completionHandlerAsync
attribute to the sync function. Check for this attribute in addition to
the name check, ie. convert a call if the callee has either
@completionHandlerAsync or a name that is completion-handler-like name.

The addition of the attribute is currently gated behind the experimental
concurrency flag.

Resolves rdar://77486504
2021-05-14 20:19:02 +10:00
Hamish Knight
7ab5915750 [Refactoring] Don't drop returns with expressions
Previously we were unconditionally dropping a
return statement if it was the last node, which
could cause us to inadvertently drop the result
expression as well. Instead, only drop bare
'return' statements.

rdar://77789360
2021-05-14 11:17:59 +01:00
Hamish Knight
aa189f2fe9 [Refactoring] Avoid duplicating return statements
It's possible the user has already written an
explicit return for the call to the completion
handler. In that case, avoid adding another return.

rdar://77789360
2021-05-14 11:17:59 +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
Hamish Knight
d7d58cbbb2 [Refactoring] Tweak handling of return and break placeholders
- Add a missing return to the break statement
placeholder handling.

- Only turn the `return` token into a placeholder,
as we still want to apply the transformation to
the sub expression.

This stops us from crashing by attempting to walk
into the return sub-expression.

rdar://77789360
2021-05-14 11:17:57 +01:00
swift-ci
2074057785 Merge pull request #37415 from DougGregor/remove-asynchandler 2021-05-13 19:47:46 -07:00
swift-ci
e0eff4885e Merge pull request #37287 from plotfi/cxx-interop-anon-union 2021-05-13 19:47:37 -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
Holly Borla
c305b57ba3 Merge pull request #37407 from hborla/wrapped-parameter-serialization
[Property Wrappers] Fix a crash in merge-modules with wrapped parameters.
2021-05-13 15:48:46 -07:00
swift-ci
e87f237ea8 Merge pull request #37397 from jirid/SR-14453-remove-enable-swiftcall 2021-05-13 15:46:45 -07: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
Hamish Knight
ef318a16cb Merge pull request #37387 from hamishknight/any-comments 2021-05-13 21:09:26 +01: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
Puyan Lotfi
7d7a6c6bcc [cxx-interop] Detect IndirectFields nested in non-importable anon-unions
This patch to the Clang Importer avoids an assert by detecting when an
IndirectField belongs to an anonymous union that is not importable. How
it does this is by determining if an IndirectFieldDecl's anonymous
parent field is non-importable (based on isCxxRecordImportable) and if
so skips importing the IndirectFieldDecl.

This avoids the mentioned assert because makeIndirectFieldAccessors
expects a FieldDecl of __Unnamed_union___Anonymous_field that is only
populated when the top-level union is imported from an
IndirectFieldDecl's parent. IndirectFieldDecls for the members of an
anonymous union are dependent on their parent and should not be imported
if their parent can not also be imported.

This corner case can happen in cases when an anonymous union contains an
ARC pointer, which results in a non-trivial but also inaccessible dtor.
2021-05-13 07:31:33 -10:00
Holly Borla
df43914406 [Property Wrappers] Return early from computing the backing property type
if the wrapped property came from a module file.
2021-05-13 09:16:38 -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
QuietMisdreavus
51c96a4df0 Merge pull request #37351 from apple/QuietMisdreavus/protocol-req-sourceOrigin
[SymbolGraph] add sourceOrigin field for symbols implementing remote protocol requirements
2021-05-13 09:06:37 -07:00
Hamish Knight
8cb319b640 [Refactoring] Preserve comments in async transform
Previously we would drop comments between nodes in
a BraceStmt, as we printed each node out individually.
To remedy this, always make sure we scan backwards
to find any preceding comments attached to a node,
and also keep track of any SourceLocs which we
don't print, but may have comments attached which
we want to preserve.

rdar://77401810
2021-05-13 14:16:27 +01:00
Hamish Knight
3a7a880fa0 [Refactoring] Store SourceFile on AsyncConverter 2021-05-13 14:16:26 +01: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
Slava Pestov
c74c66d479 Merge pull request #37374 from slavapestov/fix-perf-regressions
Fix a couple of performance regressions
2021-05-12 13:07:42 -04:00
Holly Borla
eeeea25695 Merge pull request #37282 from hborla/propagate-async-to-closure
[CSApply] NFC: Clean up some duplicated logic for propagating `async` from contextual types to closure types.
2021-05-12 08:56:08 -07:00
Holly Borla
e1591314cf Merge pull request #37380 from hborla/property-wrapper-inference-crash
[ConstraintSystem] Fix a constraint system crash with property wrapper inference using the $ syntax.
2021-05-12 08:55:51 -07:00