Commit Graph

15871 Commits

Author SHA1 Message Date
Doug Gregor
465e5da0a3 [Constraint system] Set the contextual type for condition expressions.
Set the contextual type of conditional expressions (to Bool) with the
"condition" purpose so we get customized diagnostics for mistakes such
as

    if x.property = y { }

Prior to this, we'd get generic "() isn't convertible to Bool"
diagnostic. Now we get

    use of '=' in a boolean context, did you mean '=='?
2020-01-24 10:17:59 -08:00
Doug Gregor
27cd8d2afb [Constraint system] Save contextual types into each Solution
We’ll want to pull these back out for diagnostic purposes.
2020-01-24 10:17:59 -08:00
Doug Gregor
5669985665 Merge pull request #29419 from DougGregor/function-builder-if-available
[Function builders] Add support for "if #available".
2020-01-24 10:17:22 -08:00
Dan Zheng
8c17687e02 Merge pull request #29405 from dan-zheng/autodiff-upstream-sil-diff-param
[AutoDiff upstream] Add `@noDerivative` flag to `SILParameterInfo`.
2020-01-24 10:10:04 -08:00
swift-ci
5ef7482da1 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-24 09:43:51 -08:00
Pavel Yaskevich
0dcb78fe69 Merge pull request #29389 from xedin/rdar-50666427
[Diagnostics] Unsatisfied requirement `in reference` diagnostics expe…
2020-01-24 09:30:12 -08:00
Mike Ash
cd2b54f74e Merge branch 'master' into master-rebranch 2020-01-24 11:30:32 -05:00
Luciano Almeida
2c7cc7b829 [CSDiag] Remove obsolete FailureDiagnosis::visitIdentityExpr from CSDiag 2020-01-24 10:35:24 -03:00
Doug Gregor
23615ba55d [Function builders] Add support for "if #available".
Availability checks in if statements don't need any actual semantic
checking, so enable them within function builders.
2020-01-23 22:00:41 -08:00
Doug Gregor
7217cfa4a5 [Constraint system] Move statement condition constraint generation.
Move constraint generation for statement conditions onto the
constraint system; it doesn't really have any reason to be located
within the function builder transform.
2020-01-23 21:51:53 -08:00
Doug Gregor
2196eb3b16 Merge pull request #29409 from DougGregor/function-builder-multi-if
[Function builders] Support multiple Boolean conditions in 'if' statements
2020-01-23 21:38:05 -08:00
Doug Gregor
1576ab74f9 Merge pull request #29393 from DougGregor/decontextualize-contextuals
[Constraint solver] Request contextual type information per expression.
2020-01-23 21:31:29 -08:00
kelvin13
884584546a clang format 2020-01-23 22:53:23 -06:00
kelvin13
1715ebcf9d address more reviewed issues 2020-01-23 22:46:30 -06:00
Doug Gregor
6238923e15 [Function builders] Support multiple Boolean conditions in 'if' statements
Generalize support for function builders to allow 'if' statements that
include multiple Boolean conditions, e.g., "if a, b, c, { ... }".
2020-01-23 17:04:17 -08:00
Holly Borla
689a57b8a0 [CSDiag] Remove some dead code for diagnosing ambiguity from CSDiag. 2020-01-23 16:22:15 -08:00
Dan Zheng
ac48febfd4 Add @noDerivative flag to SILParameterInfo.
The `@noDerivative` attribute marks the non-differentiability parameters of a
`@differentiable` function type. All parameters except those marked with
`@noDerivative` are differentiability parameters.

For example, `@differentiable (Float, @noDerivative Float) -> Float` is only
differentiable with respect to its first parameter.

The `@noDerivative` attribute is represented as a
`SILParameterDifferentiability` bit on `SILParameterInfo`.

Add round-trip serialization tests.

Resolves TF-872.
2020-01-23 15:29:14 -08:00
swift-ci
f324eb6a1e Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-23 15:04:45 -08:00
Saleem Abdulrasool
8b7a621e25 Merge pull request #29397 from compnerd/may-the-force-not-be-with-you
build: remove `FORCE_BUILD_OPTIMIZED`
2020-01-23 15:03:16 -08:00
swift-ci
b0d3f3a13c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-23 14:24:57 -08:00
Suyash Srijan
74cfee1485 [Typechecker] Extended ambiguous none warning to cases as well (#29356) 2020-01-23 22:04:08 +00:00
Doug Gregor
83cb35139a [Constraint solver] Allow contextual types for multiple expressions.
Generalize the representation of contextual types so we can store
contextual types for more than one expression. Allow these to be
added/rolled back in solver scopes. Nothing uses this functionality
yet.
2020-01-23 13:56:36 -08:00
Doug Gregor
5b195aed7e [Constraint solver] Pass for-each contextual type information down the solver.
Rather than setting contextual type information twice (once as a dummy,
once for real) when type-checking a for-each statement, pass down the
appropriate contextual type information from the outset.
2020-01-23 13:55:40 -08:00
Doug Gregor
1e3484c1bf [Constraint solver] Dig out the root expression as the "contextual node". 2020-01-23 13:20:31 -08:00
Saleem Abdulrasool
a8df8ef03c build: remove FORCE_BUILD_OPTIMIZED
This is used in two places.  Rather than plumbing the option through
everywhere, set the two locations to use compiler-specific optimization
flags.  Note that this improves the optimizations enabled for the debug
build with an optimized type-checker.

This also clears the way to have `add_swift_host_library` be entirely a
trivial wrapper over `add_library` enabling us to finally move towards
more standard CMake rules.
2020-01-23 13:17:25 -08:00
Doug Gregor
133439dcbb [Constraint solver] Request contextual type information per expression.
When requesting information about the contextual type of a constraint
system, do so using a given expression rather than treating it like
the global state that it is.
2020-01-23 11:46:17 -08:00
Holly Borla
74f65ba2ce [ConstraintSystem] Find solutions for code with invalid '_' using
holes.
2020-01-23 10:48:55 -08:00
Pavel Yaskevich
d412ea4d16 [Diagnostics] Unsatisfied requirement in reference diagnostics expect type context
Resolves: rdar://problem/50666427
2020-01-23 10:14:37 -08:00
swift-ci
e44e67223c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-23 00:10:27 -08:00
Doug Gregor
70300ada57 [Function builders] Perform syntactic use checks within function builders. 2020-01-22 22:22:36 -08:00
kelvin13
2701012434 fix some reviewed issues 2020-01-22 21:56:47 -06:00
kelvin13
fb4bd68653 Merge branch 'master' into comparable-enums 2020-01-22 18:38:31 -06:00
swift-ci
2cbb8f4de9 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 15:23:52 -08:00
Xi Ge
f254619f59 Merge pull request #29336 from nkcsgexi/diag-refactor-original-defined
Sema: refactor some code to diagnose multiple active platforms for @_originallyDefinedFrom. NFC
2020-01-22 15:13:23 -08:00
swift-ci
58d55b65dc Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 14:43:47 -08:00
Holly Borla
26f0924a24 Merge pull request #29360 from hborla/finish-member-failures
[ConstraintSystem] Finish porting member failure diagnostics
2020-01-22 14:26:19 -08:00
swift-ci
5224ef8b72 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 13:44:41 -08:00
Xi Ge
56110b8064 Sema: refactor some code to diagnose multiple active platforms for @_originallyDefinedFrom. NFC 2020-01-22 13:29:38 -08:00
Rintaro Ishizaki
0a7c3b9014 Merge pull request #29346 from rintaro/ide-completion-rdar58778439
[LookupVisibleDecls] Look through DynamicSelfType in meta type lookup
2020-01-22 13:24:24 -08:00
Holly Borla
0c00d45d53 [CSDiag] Remove CalleeCandidateInfo::diagnoseSimpleErrors, which is
dead code now.
2020-01-22 10:57:52 -08:00
Holly Borla
7fb27b3c74 [ConstraintSystem] Find solutions for code that contains circular member
references in the new diagnostic infrastructure.
2020-01-22 10:57:52 -08:00
Holly Borla
86cf6dc03e [ConstraintSystem] Finish porting member failure diagnostics.
Remove special cases for AnyObject member and dynamic member lookup
failures - these are now all handled in the new diagnostic
infrastructure.
2020-01-22 10:57:52 -08:00
Rintaro Ishizaki
43ad81c907 [LookupVisibleDecls] Look through DynamicSelfType in meta type lookup
We need to unwrap DynamicSelfType to get the visible decls on the meta
type.

rdar://problem/58778439
2020-01-22 09:45:00 -08:00
swift-ci
11550b4c0c Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 09:43:43 -08:00
Varun Gandhi
29cc1b6195 Revert "[AST] Store Clang type in SILFunctionType for @convention(c) functions."
This reverts commit 5f45820755.
2020-01-22 09:04:52 -08:00
swift-ci
8a5dda7c8a Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 01:22:46 -08:00
Pavel Yaskevich
4b46043494 Merge pull request #29304 from LucianoPAlmeida/port-object-literal-diagnostics
[Diagnostics] Port diagnostics from FailureDiagnosis::visitObjectLiteralExpr
2020-01-22 01:10:34 -08:00
Erik Eckstein
bbfaccda4b Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-22 08:25:23 +01:00
Devin Coughlin
e9df206b9d Merge pull request #29017 from devincoughlin/maccatalyst
Build system and availability support for macCatalyst
2020-01-21 22:52:48 -08:00
swift-ci
44ebe469a6 Merge remote-tracking branch 'origin/master' into master-rebranch 2020-01-21 21:02:46 -08:00