Commit Graph

11880 Commits

Author SHA1 Message Date
Holly Borla
66e85721cb Merge pull request #30807 from hborla/property-wrapper-refactoring
[Property Wrappers] Refactor property wrappers so the synthesized backing init is only type checked once
2020-04-14 10:48:22 -07:00
swift-ci
9a0efcac2a Merge pull request #30548 from AnthonyLatsis/sr-7855 2020-04-13 13:20:27 -07:00
Slava Pestov
ab45d517d5 Merge pull request #29931 from theblixguy/fix/SR-12178
[Typechecker] Fix _modify for wrapped properties with observers
2020-04-12 22:11:10 -04:00
Slava Pestov
1af01edbf0 Merge pull request #30965 from slavapestov/enable-dynamic-replacement-vs-library-evolution
Enable dynamic replacement with library evolution
2020-04-11 01:39:09 -04:00
eeckstein
628bf7beae Merge pull request #30957 from eeckstein/fix-large-string-arrays
Several compile time fixes related to large string arrays.
2020-04-11 06:55:00 +02:00
Slava Pestov
365f0c7af5 Merge pull request #30861 from slavapestov/outdated-fixme
IRGen: Type reconstruction supports opaque result types now
2020-04-10 23:32:43 -04:00
Slava Pestov
23cac673ca IRGen: Enable dynamic replacement with library evolution
It looks like the only thing that fails is the linkage computation
for the dynamic replacement key of class methods. Even though
methods have hidden linkage to prevent them from being directly
referenced from outside a resilient module, we need to ensure
the dynamic replacement key is visible.

Fixes <rdar://problem/58457716>.
2020-04-10 22:53:36 -04:00
Xi Ge
bae31467a3 Merge pull request #30962 from nkcsgexi/44777994
AST: making `export: true` in @_specialized attribute a no-operation
2020-04-10 18:39:22 -07:00
Xi Ge
435d13496e AST: making export: true in @_specialized attribute a no-operation
The client code doesn't actually call into these specialized functions even
though they have public linkage. This could lead to TBD verification failure
shown in rdar://44777994.

This patch also warns users' codebase when `export: true` is specified.
2020-04-10 16:52:22 -07:00
Artem Chikin
e3ce6f7b7e Merge pull request #30939 from artemcm/ImplOnlyPropertyWrappers
[Sema] Diagnose use of implementation-only property wrappers
2020-04-10 15:12:41 -07:00
Rintaro Ishizaki
579e662362 Merge pull request #30954 from rintaro/ide-completion-prettystacktrace
[CodeCompletion] Add pretty stacktrace for completion operation
2020-04-10 13:14:54 -07:00
Hamish Knight
a61223a255 [CS] Visit all fixed bindings for constraint re-activation (#30886)
[CS] Visit all fixed bindings for constraint re-activation
2020-04-10 12:27:47 -07:00
Slava Pestov
41ccedc999 AST: Fix opaque type mangling used by type reconstruction
Make sure we mangle opaque types using the same settings as the
debugger mangling (with OptimizeProtocolNames = false) to ensure
that we can reconstruct those names again.
2020-04-10 15:05:54 -04:00
Artem Chikin
efdfceeb9b [Sema] Diagnose use of implementation-only property wrappers
We already ban all structs from declaring storage that comes from implementation-only imports. Until now we missed property wrappers, they were just dropped in deserialization.

Resolves rdar://problem/59403617
2020-04-10 11:19:42 -07:00
Erik Eckstein
6da902ef8b Add an option to completely disable SIL verification.
This is useful to disable SIL verification in an assert build of the compiler.
2020-04-10 20:10:24 +02:00
Hamish Knight
d69a42d656 [CS] Preserve compatibility for collection coercions
Previously we could allow some invalid coercions to
sneak past Sema. In most cases these would either
cause crashes later down the pipeline or
miscompiles. However, for coercions between
collections, we emitted somewhat reasonable code
that performed a force cast.

This commit aims to preserve compatibility with
those collection coercions that previously
compiled, and emits a warning telling the user to
use either 'as?' or 'as!' instead.
2020-04-10 10:16:07 -07:00
Rintaro Ishizaki
de6a402116 [CodeCompletion] Add pretty stacktrace for completion operation 2020-04-10 09:28:40 -07:00
Dan Zheng
b4fa7e0027 [AutoDiff] Support direct init reference differentiation.
Support `@differentiable` function conversion for `init` references, in
addition to `func` references and literal closures. Minor usability improvement.

Resolves SR-12562.
2020-04-10 01:26:34 -07:00
Suyash Srijan
84f8e41dee [Typechecker] Add an hasObservers() convenience method and simplify some code 2020-04-10 00:26:52 +01:00
Holly Borla
65105f3a26 [Property Wrappers] Introduce a new Expr node for the property wrapper
wrapped value placeholder in an init(wrappedValue:) call that was previously
injected as an OpaqueValueExpr. This commit also restores the old design of
OpaqueValueExpr.
2020-04-09 16:00:57 -07:00
Robert Widmann
0f15af520b Merge pull request #30795 from davidungar/typo-fix
[NFC] Fix a typo in a comment
2020-04-09 15:31:11 -07:00
Dan Zheng
20dedfb40f [Gardening] Remove unnecessary forward declaration. 2020-04-09 01:10:47 -07:00
Dan Zheng
165af547f3 Fix SynthesizedFileUnit serialization and TBDGen issues.
Make `SynthesizedFileUnit` attached to a `SourceFile`. This seemed like the
least ad-hoc approach to avoid doing unnecessary work for other `FileUnit`s.

TBDGen: when visiting a `SourceFile`, also visit its `SynthesizedFileUnit` if
it exists.

Serialization: do not treat `SynthesizedFileUnit` declarations as xrefs when
serializing the companion `SourceFile`.

Resolves TF-1239: AutoDiff test failures.
2020-04-08 21:19:56 -07:00
Suyash Srijan
724f8c23db [Typechecker] Implement SE-0268 Refine didSet Semantics (#26632) 2020-04-09 01:23:15 +01:00
Brent Royal-Gordon
4de19e1c3c Merge pull request #30819 from brentdax/a-less-ambitious-crossover-event
Ignore transitive ObjC imports when cross-importing
2020-04-08 11:40:35 -07:00
Dan Zheng
2eb460de4d [AutoDiff upstream] Add forward-mode differentiation. (#30878)
JVP functions are forward-mode derivative functions. They take original
arguments and return original results and a differential function. Differential
functions take derivatives wrt arguments and return derivatives wrt results.

`JVPEmitter` is a cloner that emits JVP and differential functions at the same
time. In JVP functions, function applications are replaced with JVP function
applications. In differential functions, function applications are replaced
with differential function applications.

In JVP functions, each basic block takes a differential struct containing callee
differentials. These structs are consumed by differential functions.
2020-04-08 11:29:21 -07:00
Pavel Yaskevich
51267754fc Merge pull request #30867 from xedin/rdar-59874355
[TypeChecker] Diagnose key paths with contextual type but no leading dot
2020-04-08 10:05:35 -07:00
Dan Zheng
f27f1cde66 Merge pull request #30863 from dan-zheng/synthesized-file-unit
[AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.
2020-04-07 23:48:09 -07:00
Artem Chikin
0d1013245e Merge pull request #30782 from artemcm/Rcross-import
Add -Rcross-import option
2020-04-07 19:04:47 -07:00
Dan Zheng
f7a9eed4de [AutoDiff] Add generated implicit declarations to SynthesizedFileUnit.
Add implicit declarations generated by the differentiation transform to a
`SynthesizedFileUnit` instead of an ad-hoc pre-existing `SourceFile`.

Resolves TF-1232: type reconstruction for AutoDiff-generated declarations.

Previously, type reconstruction failed because retroactively adding declarations
to a `SourceFile` did not update name lookup caches.
2020-04-07 18:29:34 -07:00
Dan Zheng
c834696bfa Add SynthesizedFileUnit.
`SynthesizedFileUnit` is a container for synthesized declarations. Currently, it
only supports module-level declarations.

It is used by the SIL differentiation transform, which generates implicit struct
and enum declarations.
2020-04-07 18:29:26 -07:00
marcrasi
eefe9a083c Merge pull request #30851 from apple/derivative-attr-serialization
[AutoDiff] SR-12526: cross-module @derivative deserialization
2020-04-07 17:23:47 -07:00
Suyash Srijan
8f44a0bd66 [TypeChecker] Diagnose key paths with contextual type but no leading dot
If a Swift key path has root type inferred but does not have a leading dot,
then diagnose it, because it's not valid.

For example:

```swift
struct Foo {
  let property: [Int] = []
  let kp: KeyPath<Foo, Int> = \property.count // error
}
```

Resolves SR-12290
Resolves rdar://problem/59874355
2020-04-07 16:59:23 -07:00
Pavel Yaskevich
3accb65a5c [AST] Track whether key path expression has a leading dot
This is going to be useful to detect whether contextual root
is really expected during key path resolution in Sema.
2020-04-07 16:16:34 -07:00
Marc Rasi
7abf8ae305 actually set the lazy resolver 2020-04-07 15:05:27 -07:00
Andrew Trick
8da6b72757 Make -emit-verbose-sil print conformances for existential insts.
It is a correctness bug that textual SIL cannot parse these, but at
least we can somewhat debug the issue now.
2020-04-07 13:53:27 -07:00
Ravi Kandhadai
4264b39b23 Merge pull request #26969 from ravikandhadai/oslog-user-model
[Sema Diagnostics] Add Miscellaneous Sema diagnostics to enforce that the new os log APIs and atomics are passed constants for certain arguments
2020-04-07 13:23:10 -07:00
Dan Zheng
f9ef75ff34 Remove SourceFile::addVisibleDecl.
`SourceFile::addVisibleDecl` is an unnecessary API.
It was upstreamed in https://github.com/apple/swift/pull/30821.
2020-04-07 13:19:55 -07:00
Dan Zheng
5d8d8dab2d Merge pull request #30852 from dan-zheng/autodiff-cleanup
[AutoDiff] NFC: gardening.
2020-04-07 13:13:58 -07:00
Doug Gregor
78880ffc1a Merge pull request #27776 from owenv/catch_revamp_take_4
[SE-0276] Support multiple patterns in catch clauses
2020-04-07 12:31:33 -07:00
Dan Zheng
77d0d99f81 [AutoDiff] NFC: move isDifferentiableProgrammingEnabled.
Move `isDifferentiableProgrammingEnabled` to AutoDiff.h so it's more accessible.
2020-04-07 11:01:00 -07:00
Dan Zheng
04686a091f [AutoDiff] NFC: add ASTMangler entry points for AutoDiff-generated decls.
Add `ASTMangler::mangleAutoDiffGeneratedDeclaration`.
2020-04-07 11:00:46 -07:00
Marc Rasi
78ac5eb0a3 add PointerUnion for parsed vs deserialized derivative attr 2020-04-07 10:25:30 -07:00
Rintaro Ishizaki
773a464e83 [CodeCompletion] Add an option to emit annotated description 2020-04-07 00:46:14 -07:00
Ravi Kandhadai
b57a1d7c0e [Sema] Add miscellaneous sema diagnostics to check that the new os log
APIs and atomic operations are passed compile-time constants for
certain arguments.
2020-04-06 18:41:13 -07:00
Marc Rasi
be9d35cece Merge branch 'master' into derivative-attr-serialization 2020-04-06 16:58:08 -07:00
Pavel Yaskevich
cbf3cab966 Merge pull request #30746 from ismetanin/fix-it-for-removing-escaping-from-optional-closure-parameter
Add new error diagnostic for escaping optional closures
2020-04-06 12:03:42 -07:00
Dan Zheng
83f6714334 [AutoDiff] Start fixing SR-12526.
Start fixing SR-12526: `@derivative` attribute cross-module deserialization
crash. Remove original `AbstractFunctionDecl *` from `DerivativeAttr` and store
`DeclID` instead, mimicking `DynamicReplacementAttr`.
2020-04-06 06:37:23 -07:00
Dan Zheng
1775e8ae16 [AutoDiff upstream] Add VJPEmitter.
`VJPEmitter` is a cloner that emits VJP functions. It implements reverse-mode
automatic differentiation, along with `PullbackEmitter`.

`VJPEmitter` clones an original function, replacing function applications with
VJP function applications. In VJP functions, each basic block takes a pullback
struct (containing callee pullbacks) and produces a predecessor enum: these data
structures are consumed by pullback functions.
2020-04-05 20:35:35 -07:00
Dan Zheng
8081482b57 [AutoDiff upstream] Add common SIL differentiation utilities. 2020-04-05 20:35:35 -07:00