Commit Graph

12650 Commits

Author SHA1 Message Date
Sam Lazarus
c498f38e5f Sema: Changed name of isInsideCall to isCallArgument and formatted changes 2019-05-08 23:44:29 -04:00
Sam Lazarus
edd8f70330 Sema: Change the diagnostic to choices made by the constraint system 2019-05-08 23:37:51 -04:00
Pavel Yaskevich
860cddfd34 [ConstraintSystem] Allow arguments to be passed by value to @autoclosure parameters
Instead of always requiring a call to be made to pass argument
to `@autoclosure` parameter, it should be allowed to pass argument
by value to `@autoclosure` parameter which can return a function
type.

```swift
func foo<T>(_ fn: @autoclosure () -> T) {}
func bar(_ fn: @autoclosure @escaping () -> Int) { foo(fn) }
```
2019-05-08 19:41:35 -07:00
Alexis Laferrière
3dd54c24d1 Remove explicit calls to computeRequirementSignature
We can rely on lazy calls to getRequirementSignature instead.
2019-05-08 14:28:35 -07:00
Alexis Laferrière
6c929273db Intro a request to compute the requirement signature of a ProtocolDecl
Replaces the explicit call to computeRequirementSignature from
validateDecl with a lazy getRequirementSignature. A side effect is that
the generic params of a ProtocolDecl are no longer computed from
validateDecl and must be computed lazily too.
2019-05-08 14:28:35 -07:00
Sam Lazarus
ad38117427 Sema: Add a diagnostic for attemting .init call on mutable value 2019-05-08 15:42:14 -04:00
Rintaro Ishizaki
6956089b0b [CodeCompletion] Complete Swift only module name after 'import'
rdar://problem/39392446
2019-05-08 10:11:52 -07:00
Slava Pestov
7d96de54e8 Merge pull request #24601 from slavapestov/remove-old-inout-expr-check
Remove MiscDiagnostics diagnosis of invalid InOutExprs
2019-05-08 08:11:44 -04:00
Slava Pestov
b103fed866 Sema: Remove old diagnostics for misplaced InOutExpr 2019-05-07 23:10:49 -04:00
Slava Pestov
5e4afc2503 Sema: Remove some dead code from matchTypes() 2019-05-07 23:10:48 -04:00
Slava Pestov
fd2dd9f8a4 Sema: Fix OperatorArgumentConversion with LHS of InOutType
We don't require or allow '&' for the mutable parameters in
operator calls, since we want to write 'x += 10' and not
'&x += 10'.

The constraint sovler accepted '&x += 10' though, and we had
a separate pass in MiscDiagnostics for rejecting it.

Instead, let's just reject this in the solver.

The main difficulty is that we must now be prepared to fail
certain OperatorArgumentConversion and ApplicableFunction
constraints even when both the LHS and RHS types are equal.
2019-05-07 23:10:48 -04:00
Slava Pestov
b6985acc23 Sema: More flexible InvalidUseOfAddressOf 2019-05-07 23:10:48 -04:00
Slava Pestov
1dedba1f12 Sema: Pass argument match kind down to matchCallArguments() 2019-05-07 23:10:48 -04:00
Pavel Yaskevich
cb3252e055 [ConstraintSystem] Extend use of missing explicit call fix
Now covers following new areas (alongside simple assignments):

- Contextual type coercions:
  - In assignment e.g. `let _: X = foo`
  - In return type positions e.g. `func foo() -> A { return bar }`

- Argument-to-parameter applications (including @autoclosure)
2019-05-07 16:41:19 -07:00
Pavel Yaskevich
49710ab7cd Merge pull request #24587 from xedin/diag-extraneous-return-via-fixes
[ConstraintSystem] Detect and diagnose extraneous returns from void f…
2019-05-07 16:39:23 -07:00
swift-ci
ed90f333de Merge pull request #24588 from DougGregor/pattern-type-check-crash 2019-05-07 15:01:31 -07:00
Doug Gregor
90d9721473 [Type checker] Fix a crash-on-invalid in pattern type checking.
Fixes rdar://problem/49731284.
2019-05-07 13:58:30 -07:00
Pavel Yaskevich
4f63c4af71 [ConstraintSystem] Detect and diagnose extraneous returns from void functions
Diagnose an attempt return something from a function which
doesn't have a return type specified e.g.

```swift
func foo() { return 42 }
```
2019-05-07 13:43:14 -07:00
Azoy
9789b2504f add typealias to known types
formatting

underscore
2019-05-07 15:13:28 -05:00
Azoy
33ed2076f6 Cache _MaxBuiltinFloatType
period
2019-05-07 14:54:48 -05:00
Ben Langmuir
a861e760e7 Merge pull request #24520 from benlangmuir/cc-crash-keypath
[code-completion] Avoid invalid member substitution for keypath dynamic lookup
2019-05-06 15:28:50 -07:00
Pavel Yaskevich
6cd476be47 Merge pull request #24522 from xedin/diag-extraneous-addr-of
[ConstraintSystem] Detect and fix extraneous use of `&`
2019-05-06 13:56:04 -07:00
Pavel Yaskevich
3af163a94c [ConstraintSystem] Detect and fix extraneous use of &
Diagnose extraneous use of address of (`&`) which could only be
associated with arguments to `inout` parameters e.g.

```swift
struct S {}

var a: S = ...
var b: S = ...

a = &b
```
2019-05-06 11:18:47 -07:00
Brent Royal-Gordon
7311886219 Merge pull request #24334 from brentdax/wherefore-art-thou-api
[TypeChecker] Rephrase platforms in availability diagnostics
2019-05-06 11:00:03 -07:00
Sam Lazarus
4fac0b31c8 Merge pull request #24450 from sl/sl/sr-10202
Add useful diagnostic when trying to write through key path on private(set) var
2019-05-06 13:09:22 -04:00
Ben Langmuir
8f38e4b765 [code-completion] Avoid invalid member substitution for keypath dynamic lookup
When performing keypath dynamic member lookup, avoid substituting the
base type in override detection and completion, as the base type of the
lookup is not the base type of the member. For now, we just avoid the
substitution entirely to fix potential crashes; in a future commit we
will change to using the subscript return type and substituting with the
base type of the subscript instead of the base type of the lookup.

rdar://50449788
2019-05-06 10:02:39 -07:00
Ben Langmuir
34da079aa6 Pass DynamicLookupInfo through VisibleDeclConsumers NFC
This commit adds a new type DynamicLookupInfo that provides information
about how a dynamic member lookup found a particular Decl. This is
needed to correctly handle KeyPath dynamic member lookups, but for now
just plumb it through everywhere.
2019-05-06 10:02:39 -07:00
Sam Lazarus
501cd91d10 Sema: Add additional assertion before providing keypath application diagnostic 2019-05-06 11:57:11 -04:00
swift-ci
b16ee94d1a Merge pull request #24512 from DougGregor/property-delegates-serialization 2019-05-05 23:17:43 -07:00
Doug Gregor
eb3f28825c [Property delegates] Fix textual interfaces for properties with delegates
Don’t synthesize a missing setter for a property that has an attached
delegate and is in a .swiftinterface file.
2019-05-05 22:12:00 -07:00
Doug Gregor
7092be6a28 [Property delegates] (De-)serialize property delegates attached to properties
Serialize the relationship between a property that has an attached delegate
and its backing variable, so deserialization can reestablish that link.

Fixes rdar://problem/50447022.
2019-05-05 21:44:54 -07:00
Pavel Yaskevich
43526d031c Merge pull request #24431 from xedin/diag-noescape-param-assignment
[ConstraintSystem] Improve @escaping parameter diagnostics
2019-05-04 20:09:31 -07:00
Sam Lazarus
ed3eaef179 Sema / Test: Revert the error for assignment through read-only key path
This updates the error message so that in the case where we can find a
Decl, it gives the error "cannot assign through subscript: 'name' is a
read-only key path", and in the case where there's no associated Decl, gives the
error message "cannot assign through subscript: key path is read-only".

Additionally updates tests with the new error messages and formats all changes.
2019-05-04 14:03:06 -04:00
Pavel Yaskevich
164f25e86d Merge pull request #24493 from xedin/add-opaque-accessor-to-value-decl
[AST] NFC: Add `ValueDecl::getOpaqueResultTypeRepr` accessor
2019-05-03 23:12:56 -07:00
Joe Groff
16b6aa5457 Merge pull request #24494 from jckarter/opaque-local-return
Fixes for opaque return types on local functions.
2019-05-03 23:02:12 -07:00
Sam Lazarus
6a7c378cbf Sema: Move getting key-path argument logic to a closure 2019-05-03 22:16:56 -04:00
Sam Lazarus
2f94a2132e Sema: Change cast to use dyn_cast instead of dyn_cast_or_null 2019-05-03 22:16:56 -04:00
Sam Lazarus
1a1e77077a Test / Sema: Change the wording of assignment through read-only key path error 2019-05-03 22:16:56 -04:00
Sam Lazarus
1d22e987c8 Sema: Add a diagnostic for assigning using a subscript with a read-only keypath 2019-05-03 22:16:56 -04:00
Joe Groff
001c0dda76 Merge pull request #24485 from jckarter/opaque-type-signature-gsb
Sema: Use GSB to build the signature for opaque result type decls.
2019-05-03 17:59:43 -07:00
Joe Groff
22793b4567 Fixes for opaque return types on local functions.
- In Sema, don't traverse nested declarations while deducing the opaque return type. This would
  cause returns inside nested functions to clobber the return type of the outer function.
- In IRGen, walk the list of opaque return types we keep in the SourceFile already for type
  reconstruction, instead of trying to visit them ad-hoc as part of walking the AST, since
  IRGen doesn't normally walk the bodies of function decls directly.

Fixes rdar://problem/50459091
2019-05-03 16:53:21 -07:00
Pavel Yaskevich
83d6f027f5 [AST] NFC: Add ValueDecl::getOpaqueResultTypeRepr accessor
Follow-up cleanup to simplify code related to diagnosing of
opaque return type conformance mismatches.
2019-05-03 16:49:36 -07:00
Pavel Yaskevich
d0ae1d9798 Merge pull request #24483 from xedin/rdar-50438071
[ConstraintSystem] Tighten "missing call" fix conditions by checking …
2019-05-03 15:49:27 -07:00
Joe Groff
a58bc8a320 Sema: Use GSB to build the signature for opaque result type decls.
Our ad-hoc mechanism for building the signature did not always produce requirements in the order
expected by the rest of the system; using the GSB should ensure we build a valid generic signature.
Fixes rdar://problem/50309983.
2019-05-03 15:01:02 -07:00
Pavel Yaskevich
0275689cd3 [ConstraintSystem] Tighten "missing call" fix conditions by checking whether other side is an optional
If "convertTo" type is an optional let's look through it to see
whether it contains another function type which, if so, would
rule out possibility of missing explicit call.

Resolves: rdar://problem/50438071
2019-05-03 13:02:28 -07:00
Jordan Rose
517f5d6b6a [ClangImporter] Retire the term "adapter" in favor of "overlay" (#24427)
Way back in Swift 1 I was trying to draw a distinction between
"overlays", separate libraries that added Swift content to an existing
Objective-C framework, and "the Swift part of a mixed-source
framework", even though they're implemented in almost exactly the same
way. "Adapter module" was the term that covered both of those. In
practice, however, no one knew what "adapter" meant. Bring an end to
this confusion by just using "overlay" within the compiler even for
the mixed-source framework case.

No intended functionality change.
2019-05-03 11:11:58 -07:00
Joe Groff
898665dee5 Merge pull request #24463 from jckarter/opaque-type-sync
NFC opaque type cleanups
2019-05-03 08:22:40 -07:00
Joe Groff
6c779bb487 Merge pull request #24445 from jckarter/opaque-type-remote
Debugger support for opaque types.
2019-05-03 08:18:59 -07:00
Pavel Yaskevich
b6b5725969 Merge pull request #24454 from xedin/rdar-50376224
[ConstraintSystem] Detect and fix invalid refs in dynamic key path me…
2019-05-02 21:23:42 -07:00
Pavel Yaskevich
d275c8afbb [ConstraintSystem] Add a tailored diagnostic for conversion of non-escaping parameter to dependent member type 2019-05-02 21:21:58 -07:00