Commit Graph

15871 Commits

Author SHA1 Message Date
Pavel Yaskevich
d7b12a6de7 [TypeChecker] Treat tuples specially while validating checked casts
Based on the checked cast behavior don't warn about unrelated
casts between tuples unless their sizes or labels differ.

Resolves: rdar://problem/56436235
2019-12-20 14:02:32 -08:00
Pavel Yaskevich
3994a1dced [TypeChecker] NFC: Extract array/set element cast checking into a closure 2019-12-20 13:52:38 -08:00
swift_jenkins
51b1e043db Merge remote-tracking branch 'origin/master' into master-next 2019-12-20 11:39:15 -08:00
Suyash Srijan
3cda934329 [Typechecker] Fix duplicate diagnostics when using attributes (#28888)
* [Typechecker] resolveAttributedType() should invalidate the type repr after emitting a diagnostic, to prevent duplicate diagnostics later

* [Test] Update '@noescape' attribute diagnostics

* [Typechecker] Add a special diagnose method to TypeResolver that accepts a TypeRepr and invalidates it

* [Typechecker] Rename the special 'diagnose' method to 'diagnoseInvalid' for clarity
2019-12-20 19:26:50 +00:00
swift_jenkins
2ebc382226 Merge remote-tracking branch 'origin/master' into master-next 2019-12-20 08:39:15 -08:00
Slava Pestov
a99f24f777 Merge pull request #28895 from slavapestov/prep-for-sr-75
Preparations for building curry thunks in Sema
2019-12-20 11:31:43 -05:00
swift_jenkins
511931489c Merge remote-tracking branch 'origin/master' into master-next 2019-12-20 07:19:11 -08:00
Slava Pestov
0514248f9d Merge pull request #28596 from slavapestov/fun-with-guard-let
Fix various problems with top-level 'guard' statements and captures
2019-12-20 10:07:16 -05:00
Kita, Maksim
ea6a2dc094 SR-11889: Fixed code review issues
1. Updated Located field names with Pascal Case
2. Updated Located constuctor
3. Formatted lines with more than 80 symbols
2019-12-20 17:18:59 +03:00
Kita, Maksim
c1444dea18 SR-11889: Fixed code review issues 2019-12-20 17:18:59 +03:00
Kita, Maksim
b7cb3b67bf SR-11889: Using Located<T> instead of std::pair<SourceLoc, T> 2019-12-20 17:18:58 +03:00
swift_jenkins
e43ad13eff Merge remote-tracking branch 'origin/master' into master-next 2019-12-20 00:39:20 -08:00
Dan Zheng
2692abbe2e [AutoDiff] Fix build error.
Fix build error introduced in https://github.com/apple/swift/pull/28892.

Caused by not re-running CI after https://github.com/apple/swift/pull/28879
was merged.
2019-12-19 22:26:21 -08:00
swift_jenkins
48b0614278 Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 21:19:03 -08:00
Dan Zheng
14ee6c5d1c [AutoDiff] Enable @derivative attribute qualified declaration names. (#28892)
Enable qualified declaration names in `@derivative` attribute, just like
`@transpose` attribute.

`DerivativeAttr` now stores a base type `TypeRepr *`, which is non-null for
parsed attributes that reference a qualified original declaration.

Add `TypeResolutionFlags::AllowModule` flag to enable module lookup via
`TypeChecker::lookupMember` given a `ModuleType`.

Add tests for type-qualified and module-qualified declaration names.

Resolves TF-1058.
2019-12-19 21:06:20 -08:00
Slava Pestov
af07642c8f Sema: Remove TypeCheckExprFlags::SkipMultiStmtClosures
Fold this into TypeCheckExprFlags::SubExpressionDiagnostics, which
is itself going away soon, hopefully!
2019-12-19 23:51:53 -05:00
Slava Pestov
bdbe062aa2 Sema: Tweak SanitizeExpr handling of AutoClosureExprs
Curry thunks create AutoClosureExprs with parameters, and we can't just
fold those away.

Also, remove an older AutoClosureExpr cleanup that seems to be
redundant.
2019-12-19 23:51:53 -05:00
Slava Pestov
e4626263c3 AST: More consistent definition of a 'local capture'
This commit adds a new ValueDecl::isLocalCapture() predicate and
uses it in the right places. The predicate is true if the
declaration is in local context, *or* if its at the top level of
the main source file and follows a 'guard' statement.

Fixes <rdar://problem/23051362> / <https://bugs.swift.org/browse/SR-3528>.
2019-12-19 23:47:24 -05:00
Slava Pestov
1904960829 Sema: Fix a couple of problems with capture analysis and TopLevelCodeDecls
A TopLevelCodeDecl is a local context and any declarations inside
of one must be treated as captures. Furthermore, all the
TopLevelCodeDecl children of a source file are peers, and can
see each other's bindings, so don't perform an exact match on the
DeclContext.

Part of <rdar://problem/23051362> / <https://bugs.swift.org/browse/SR-3528>.
2019-12-19 23:46:01 -05:00
swift_jenkins
4e95351abb Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 20:21:28 -08:00
swift-ci
e47543c44c Merge pull request #28879 from marcrasi/less-mutating-typechecking 2019-12-19 20:02:09 -08:00
swift_jenkins
ee6d48b220 Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 18:40:53 -08:00
Frederick Kellison-Linn
71697c37ca Allow implicit self in escaping closures when self usage is unlikely to cause cycle (#23934)
* WIP implementation

* Cleanup implementation

* Install backedge rather than storing array reference

* Add diagnostics

* Add missing parameter to ResultFinderForTypeContext constructor

* Fix tests for correct fix-it language

* Change to solution without backedge, change lookup behavior

* Improve diagnostics for weak captures and captures under different names

* Remove ghosts of implementations past

* Address review comments

* Reorder member variable initialization

* Fix typos

* Exclude value types from explicit self requirements

* Add tests

* Add implementation for AST lookup

* Add tests

* Begin addressing review comments

* Re-enable AST scope lookup

* Add fixme

* Pull fix-its into a separate function

* Remove capturedSelfContext tracking from type property initializers

* Add const specifiers to arguments

* Address review comments

* Fix string literals

* Refactor implicit self diagnostics

* Add comment

* Remove trailing whitespace

* Add tests for capture list across multiple lines

* Add additional test

* Fix typo

* Remove use of ?: to fix linux build

* Remove second use of ?:

* Rework logic for finding nested self contexts
2019-12-20 02:38:41 +00:00
Marc Rasi
637314aeef [AutoDiff] factor derivative typechecking helper out of AttributeChecker 2019-12-19 17:23:38 -08:00
swift_jenkins
5c9b0a8831 Merge remote-tracking branch 'origin/master' into master-next 2019-12-19 14:19:31 -08:00
Pavel Yaskevich
b03b356bfa Merge pull request #28880 from xedin/port-multi-stmt-closure-diags
[Diagnostics] Diagnose inability to infer (complex) closure return type
2019-12-19 14:17:34 -08:00
swift-ci
ec0a2cae9d Merge pull request #28278 from marcrasi/ast-nondiff 2019-12-19 14:06:48 -08:00
Pavel Yaskevich
a7bb827b6d [CSDiag] NFC: Remove obsolete diagnoseAmbiguousMultiStatementClosure 2019-12-19 12:17:23 -08:00
Pavel Yaskevich
8bcc192591 [Diagnostics] Diagnose inability to infer (complex) closure return type 2019-12-19 12:16:30 -08:00
Marc Rasi
72194c547b Merge branch 'master' into ast-nondiff 2019-12-18 17:25:09 -08:00
swift_jenkins
5c9d885365 Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 16:40:21 -08:00
Hamish Knight
2b426713de [CS] Use custom locator element for callAsFunction (#28854)
[CS] Use custom locator element for callAsFunction
2019-12-18 16:36:32 -08:00
swift_jenkins
4bc182b09e Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 16:00:35 -08:00
swift-ci
ddcb1d56cd Merge pull request #28853 from dan-zheng/derivative-attr-type-checking 2019-12-18 15:58:35 -08:00
swift_jenkins
d2eeaee823 Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 15:19:49 -08:00
swift-ci
2acd425104 Merge pull request #28857 from DougGregor/property-wrappers-unavailable-wrappedvalue 2019-12-18 15:02:26 -08:00
Doug Gregor
b7532f9190 [Property wrappers] Diagnose unavailable wrappedValue
Fixes rdar://problem/53678041 and rdar://problem/57676337; the former was
because we diagnosed unavailable wrappedValue at the null source location
originall, then started suppressing that diagnostic altogether. Produce a
proper diagnostic now.
2019-12-18 13:21:07 -08:00
swift_jenkins
5a29d539e1 Merge remote-tracking branch 'origin/master' into master-next 2019-12-18 12:00:11 -08:00
Argyrios Kyrtzidis
a9c9f260d0 Merge pull request #27545 from apple/transposing-attr
[AutoDiff upstream] Add `@transpose` attribute.
2019-12-18 11:52:14 -08:00
Dan Zheng
1d66571bc7 [AutoDiff upstream] @derivative attribute type-checking fixes.
Upstream `@derivative` attribute type-checking fixes regarding derivative
generic signatures with all concrete generic parameters.

Cherry-picked from:
- https://github.com/apple/swift/pull/28762
- https://github.com/apple/swift/pull/28772
2019-12-18 19:45:38 +00:00
Hamish Knight
40d11716f7 [CS] Use custom locator element for callAsFunction
Introduce a `ImplicitCallAsFunction` locator path
element to represent an implicit member reference
to `callAsFunction`. Then adjust CSApply a little
to check whether it's finishing an apply for a
callable type, and if so build the implicit member
access.
2019-12-18 11:43:45 -08:00
Hamish Knight
ee5ce77c7f [CS] Push callee resolution into finishApply
Instead of passing the resolved callee, pass the
callee locator. This avoids every caller having
to resolve the callee themselves.
2019-12-18 11:43:44 -08:00
swift_jenkins
a812971ee5 Merge remote-tracking branch 'origin/master' into master-next 2019-12-17 15:00:16 -08:00
Xi Ge
9b599961d5 Merge pull request #28691 from nkcsgexi/tbdgen-ld-hide
TBDGen/IRGen: generate $ld$hide$os symbols for decls marked with @_originallyDefinedIn
2019-12-17 14:41:04 -08:00
Dan Zheng
cd1400d675 Merge branch 'master' of github.com:apple/swift into upstream-transpose-attr 2019-12-17 12:44:29 -08:00
swift_jenkins
306e34c228 Merge remote-tracking branch 'origin/master' into master-next 2019-12-17 12:40:33 -08:00
Suyash Srijan
54d67d9dd8 Merge pull request #28822 from theblixguy/fix/SR-11939
[Typechecker] Fix a crash related to use of invalid @autoclosure param
2019-12-17 20:30:38 +00:00
swift_jenkins
9d0c7c8609 Merge remote-tracking branch 'origin/master' into master-next 2019-12-17 00:40:06 -08:00
swift-ci
46bc50dcb7 Merge pull request #28827 from DougGregor/type-checker-cast-nserror 2019-12-17 00:27:42 -08:00
Doug Gregor
942aecafa5 [Type check] Consider dynamic casts to NSError and NSObject. 2019-12-16 22:45:08 -08:00