Commit Graph

13545 Commits

Author SHA1 Message Date
Richard Wei
e29c19cf8b [AutoDiff] [Sema] Fix '@differentiable' witness matching regression. (#34533)
When checking protocol conformances with `@differentiable` requirements, the type checker is supposed to accept omissions of `@differentiable` attributes when there exsits an attribute that covers a superset of the differentiation configuration. This was accidentally regressed in apple/swift#33776 which made the following test case fail to compile. This is fixed by adjusting the witness matching conditions.

```swift
// rdar://70348904 reproducer:
public protocol P: Differentiable {
    @differentiable(wrt: self)
    @differentiable(wrt: (self, x))
    func foo(_ x: Float) -> Float
}

public struct S: P {}

extension S {
    // This had worked until apple/swift#33776.
    @differentiable(wrt: (self, x))
    public func foo(_ x: Float) -> Float { x }
}
```

Also fix some suboptimal diagnostics where more information could be shown.

Resolves rdar://70348904.
2020-11-01 17:10:03 -08:00
Ben Barham
4cf7426698 [CodeCompletion] Do not include decl completion in its own initializer
`::lookupVisibleDecls` had an inline consumer in order to remove
"unusable" results. Refactor this method, moving the consumer (now
`UsableFilteringDeclConsumer`) to allow its use when looking up top
level module declarations.

Also use the `AccessFilteringDeclConsumer` in preference to a condition
in `addVarDecl`.

Resolves rdar://56755598
2020-11-02 08:49:05 +10:00
Doug Gregor
120307479f Merge pull request #34527 from DougGregor/global-actor-struct-property
[Concurrency] Disallow global actor annotations on stored properties of structs
2020-11-01 09:27:12 -08:00
Doug Gregor
723d785a58 [Concurrency] Ban non-escaping closures in @asyncHandler
An asynchronous handler appears to be a synchronous function, but
actually runs its body in a detached task. That means that any
non-escaping closure parameters to the asynchronous handler will
effectively escape. Fixes rdar://70820569.
2020-10-31 22:08:22 -07:00
Doug Gregor
4651af1803 [Concurrency] Disallow global actor annotations on stored properties of structs.
They don't make sense because stored properties of structs have the
isolation of their enclosure values. Fixes rdar://70881253
2020-10-30 22:15:12 -07:00
Alejandro Alonso
424802fb34 Revert SE-0283 (#34492)
Reverted despite build failures.
2020-10-29 17:32:06 -07:00
Ben Barham
142b726708 Merge pull request #34487 from bnbarham/benb/remove-unused-code
[Parse] Remove unused declaration and diagnostic message
2020-10-30 07:53:47 +10:00
Slava Pestov
b03d2464be Merge pull request #34473 from slavapestov/export-context-os-version
Put the AvailabilityContext into the ExportContext
2020-10-29 16:39:52 -04:00
Slava Pestov
ae5bca927a Sema: Check result builder availability 2020-10-29 14:00:04 -04:00
Joe Groff
096828e5ab Merge pull request #34358 from jckarter/imported-async-type-lowering
Type lowering and SILGen for imported ObjC async decls.
2020-10-29 08:46:16 -07:00
Jonas Devlieghere
ed3ac15239 Merge pull request #34442 from JDevlieghere/file-collector-base
Change interfaces to accept a FileCollectorBase
2020-10-29 08:24:24 -07:00
eeckstein
7dd38bb444 Merge pull request #34376 from eeckstein/bug-report-message
update and unify the "please file a bug report" message
2020-10-29 08:37:01 +01:00
Jonas Devlieghere
d01474cc72 Change interfaces to accept a FileCollectorBase
The FileCollectorBase is the common interface shared by different
implementations. In lldb, we implement our own lazy variant that allows
us to do the heavy lifting out-of-process instead of inside the signal
handler.
2020-10-28 20:14:46 -07:00
Ben Barham
eff5fc9225 [Parse] Remove unused declaration and diagnostic message 2020-10-29 09:18:39 +10:00
Artem Chikin
0305f20f32 [Clang Importer] Do not rely on being able to always import Foundation on-demand
When importing Clang types.
This is not an option with Explicit Module Builds. If the module being built does not (directly or transitively) depend on `Foundation`, then attempting to load it will produce an error because Implicit module loading is no longer allowed..

This change addresses a small number of cases where ClangImporter relies on being able to load `Foundation` on-demand:
- When importing a single Decl from a clang module, we check whether it has certain conformances by checking all extensions of the NominalTypeDecl of the Decl in question, to see if any of the extensions contain the conformance we are looking for, but we only check extensions whose parent module is either the original module of the NominalTypeDecl or the overlay module of the NominalTypeDecl or Foundation. It seems that we do not need to actually import `Foundation` here, just checking the module Identifier should be sufficient.
- In `maybeImportNSErrorOutParameter`, change the behavior to have an exit condition based on whether `Foundation` can be imported, before attempting to load it.
- When checking whether or not we are allowed to bridge an Objective-C type, it also looks sufficient the query whether or not `Foundation` *can* be imported, without loading it.
2020-10-28 14:47:17 -07:00
Nate Chandler
c502e97a25 [Async CC] Auth'd parent context pointer. 2020-10-28 12:48:54 -07:00
Andrew Trick
5be168a382 Merge pull request #34430 from atrick/check-nested-semantics
Add NestedSemanticFunctionCheck warning diagnostic
2020-10-28 08:32:22 -07:00
Pavel Yaskevich
9776e88f26 Merge pull request #34461 from upbooo/fix/typo
Fix typos in comments and docs
2020-10-28 00:26:46 -07:00
Pavel Yaskevich
811fc0659f Merge pull request #34467 from xedin/protocol-conformance-error-as-note
[Diagnostics] Split "only concrete types conform to protocols" into a separate note
2020-10-27 17:54:11 -07:00
Pavel Yaskevich
9384813b49 [Diagnostics] Split "only concrete types conform to protocols" into a separate note 2020-10-27 14:52:23 -07:00
Joe Groff
577f83a260 SIL: Type lowering for imported ObjC async decls.
When lowering the type for `@objc` entry points of async declarations, restore
the original ObjC signature with the completion handler argument in the lowered
SIL type.
2020-10-27 09:00:45 -07:00
Toan Nguyen
4b005c4a83 Fix typos in comments 2020-10-27 19:38:16 +07:00
Anthony Latsis
4ce7a2d060 CodeCompletion: Annotate archetypes, generic parameters and dependent members 2020-10-27 14:39:52 +03:00
Andrew Trick
3128eae3f0 Add NestedSemanticFunctionCheck diagnostic
to check for improperly nested '@_semantic' functions.

Add a missing @_semantics("array.init") in ArraySlice found by the
diagnostic.

Distinguish between array.init and array.init.empty.

Categorize the types of semantic functions by how they affect the
inliner and pass pipeline, and centralize this logic in
PerformanceInlinerUtils. The ultimate goal is to prevent inlining of
"Fundamental" @_semantics calls and @_effects calls until the late
pipeline where we can safely discard semantics. However, that requires
significant pipeline changes.

In the meantime, this change prevents the situation from getting worse
and makes the intention clear. However, it has no significant effect
on the pass pipeline and inliner.
2020-10-26 17:02:33 -07:00
Varun Gandhi
d32a371df5 Merge pull request #34410 from varungandhi-apple/vg-revert-import-filtering-refactor
Revert "[NFC] Clarify semantics of getImportedModules."
2020-10-26 13:36:32 -07:00
Alejandro Alonso
84e5fd2137 Merge pull request #28833 from Azoy/void-is-equatable
[SE-0283] Implement Equatable, Comparable, and Hashable conformance for Tuples
2020-10-26 13:53:29 -04:00
Varun Gandhi
1f479896f4 Revert "[NFC] Clarify semantics of getImportedModules."
This reverts commit 4b5d885114.
2020-10-23 10:01:35 -07:00
Erik Eckstein
1224cfa61b update and unify the "please file a bug report" message
The new message is:
"Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace."

1. In crash logs we used to print a message which points to the llvm bug tracking page. Now it points to the swift.org bug tracking guidelines.
2. Use the same message in all compiler diagnostics which ask the user to file a bug report.

rdar://problem/70488534
2020-10-23 11:57:22 +02:00
Robert Widmann
33771cf155 Merge pull request #34387 from CodaFi/a-giraffe-on-a-beach
Add Compilation "Wave" Assertion in +Asserts Builds
2020-10-22 15:34:36 -07:00
Azoy
7a6ea99eab [Runtime] Clean up the assembly around Tuple builtin conformances
forgot + 1
2020-10-22 18:28:37 -04:00
Azoy
f21a306ae5 [AST] Introduce BuiltinProtocolConformance 2020-10-22 18:24:27 -04:00
Slava Pestov
5f5372a3fc Sema: Don't check SPI violations in diagnoseInlinableDeclRefAccess()
There's no need to check for that here, because we also run
diagnoseDeclRefExportability() on declarations referenced
from inlinable code.

This changes some diagnostics; we now produce the same diagnostic
for references to SPI types in declaration signatures and for
references to non-type SPI declarations in inlinable function bodies.

Also note that the old inlinable reference diagnostic no longer has
to handle the 'public' and 'open' access levels, which previously
happened for '@_spi'; so I changed those entries in the %select to
%error.
2020-10-22 01:11:46 -04:00
Slava Pestov
b3dadc8973 AST: Use VarDecl::isInitExposedToClients() from DeclContext::getFragileFunctionKind()
getFragileFunctionKind() would report that all initializers in
non-resilient public types were inlinable, including static
properties.

This was later patched by VarDecl::isInitExposedToClients(),
which was checked in diagnoseInlinableDeclRefAccess().
However, the latter function only looked at the innermost
DeclContexts, not all parent contexts, so it would incorrectly
diagnose code with a nested DeclContext inside of a static
property initializer.

Fix this by changing getFragileFunctionKind() to call
isInitExposedToClients() and simplifying
diagnoseInlinableDeclRefAccess().

This commit also introduces a new isLayoutExposedToClients()
method, which is similar to isInitExposedToClients(), except
it also returns 'true' if the property does not have an
initializer (and in fact the latter is implemented in terms
of the former).
2020-10-22 01:11:39 -04:00
Zoe Carver
f0f2246793 [cxx-interop] Support C++ function templates in Swift. (#33053)
This patch adds rudimentary support for C++ template functions in swift.
2020-10-21 20:42:25 -07:00
Robert Widmann
c3881d9651 [NFC] Pull the Computation of Fingerprints Into the Common Base Class 2020-10-21 19:08:04 -07:00
Robert Widmann
af5fa5e31d Remove isPrivateToEnclosingFile Accessor
I removed the implementation in #34151
2020-10-21 19:07:04 -07:00
swift-ci
cb900a6b69 Merge pull request #34057 from varungandhi-apple/vg-track-isDerivable-update-mangling 2020-10-21 18:18:43 -07:00
Varun Gandhi
987d055b8c [Mangler] Handle mangling for Clang types not derivable from Swift types. 2020-10-21 15:57:57 -07:00
Slava Pestov
be73343f35 Merge pull request #34372 from slavapestov/more-export-context-refactoring
Generalize ExportContext and use it for deprecation and unavailability
2020-10-21 18:00:04 -04:00
Doug Gregor
3b6fd4ece8 Merge pull request #34374 from DougGregor/se-0289-result-builders-rename
[SE-0289] Rename "function builders" to "result builders"
2020-10-21 09:08:46 -07:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
Slava Pestov
85d24953de Sema: Teach ExportContext to compute whether we're inside an unavailable declaration 2020-10-20 23:39:11 -04:00
Doug Gregor
6a40a3a8aa [SE-0289] Add support for @resultBuilder.
"Function builders" are being renamed to "result builders". Add the
corresponding `@resultBuilder` attribute, with `@_functionBuilder` as
an alias for it, Update test cases to use @resultBuilder.
2020-10-20 13:24:51 -07:00
Kavon Farvardin
34d22105b8 implemented parsing and typechecking for @actorIndependent(unsafe)
[broken] first impl of @actorIndependent in the type checker.

[broken] fixed mistake in my parsing code wrt invalid source range

[broken] found another spot where ActorIndependent needs custom handling

[broken] incomplete set of @actorIndependent(unsafe) tests

updates to ActorIndependentUnsafe

[fixed] add FIXME plus simple handling of IndependentUnsafe context

finished @actorIndependent(unsafe) regression tests

added wip serialization / deserialization test

focus test to just one actor class

round-trip serialize/deserialize test for @actorIndependent

serialize -> deserialize -> serialize -> compare to original

most of doug's comments

addressed robert's comments

fix printing bug; add module printing to regression test

[nfc] update comment for ActorIsolation::IndependentUnsafe
2020-10-19 15:20:24 -07:00
Kavon Farvardin
849e9d660f fix diagnostic messages that said '@actorIsolated' for @actorIndependent 2020-10-19 15:20:00 -07:00
Slava Pestov
027563733a AST: Disallow @available attributes on generic parameters
This was a no-op and it doesn't make sense in the current model.
2020-10-16 00:34:56 -04:00
Arnold Schwaighofer
c880be6c90 Merge branch 'main' into rename_usableFromInline_flags 2020-10-15 06:48:13 -07:00
Doug Gregor
aa3e5904f8 Merge pull request #34305 from DougGregor/concurrency-actor-isolation-serialization
[Concurrency] Proper serialization/interface printing for actor-isolation attributes
2020-10-14 22:03:31 -07:00
Robert Widmann
476890cac5 Merge pull request #34312 from CodaFi/just-keep-passing-the-open-windows
Silence a Raft of Warnings from the Windows Build
2020-10-14 17:19:13 -07:00