Commit Graph

9116 Commits

Author SHA1 Message Date
Harlan Haskins
972502d024 Remove subclasses of SyntaxData and move validation logic into Syntax subclasses. 2017-06-22 21:52:59 -07:00
Slava Pestov
dd80cd0a79 Sema: Remove redundant 'isStatic()' checks 2017-06-22 15:09:34 -07:00
Pavel Yaskevich
71c2c1e44a Merge pull request #10484 from xedin/rdar-32726044
[ConstraintSolver] Use a flag to prevent solver from removing possible solutions
2017-06-22 14:41:55 -07:00
Huon Wilson
18078c104e Merge pull request #10476 from huonw/cleanups
Small clean-ups
2017-06-22 14:30:46 -07:00
Huon Wilson
77781b8754 [NFC] Use std::tuple instead of hand-written lexicographical comparison. 2017-06-22 12:48:55 -07:00
Mark Lacey
508d776c28 Adjust the expression type checker timeout to 10 minutes.
The old threshold was sometimes being reached on an ASAN bot.

Also fix a spot where I missed passing in the override value from the
command-line.

rdar://problem/32925008
2017-06-22 10:17:27 -07:00
Pavel Yaskevich
6231f85be9 [ConstraintSolver] Use a flag to prevent solver from removing possible solutions
In some situations e.g. while trying to shrink domains of the type
variables before attempting search, use a flag to tell constraint
system to retain all of the viable solutions otherwise solver could
loose some of the information required to produce complete solution.

Resolves: rdar://problem/32726044
2017-06-22 00:11:32 -07:00
Mark Lacey
fb593f5404 Merge pull request #10475 from rudkx/time-out-solver
Update determination of "too complex" expression to take time into account.
2017-06-21 20:51:27 -07:00
Mark Lacey
e51e3e4bd4 Update determination of "too complex" expression to take time into account.
By default, end expression type checking after the elapsed process time
is more than 60 seconds for the current expression. This threshold can
be overridden by using -solver-expression-time-threshold=<seconds>.

Resolves rdar://problem/32859654
2017-06-21 16:26:34 -07:00
Slava Pestov
da80c42a76 Sema: Don't infer 'dynamic' for static methods and properties
Otherwise, can crash in the AST verifier.

Fixes <rdar://problem/32862136>.
2017-06-21 16:23:05 -07:00
Mark Lacey
05e79e6b02 Refactor how the expression type checker timer is set up.
Preparation for adding the ability for the expression type checker to be
halted after a period of time.
2017-06-21 14:18:25 -07:00
Robert Widmann
da35f11486 Merge pull request #10453 from CodaFi/high-and-DRY
Unify CallArgParam and AnyFunctionType::Param
2017-06-21 14:11:26 -07:00
Pavel Yaskevich
676a48ff4f [QoI] Adapt new diagnostics to reverted portion of SE-0110 and new function input decomposition 2017-06-21 12:29:29 -07:00
Robert Widmann
0795c9946c Unify CallArgParam and AnyFunctionType::Param 2017-06-21 11:31:51 -07:00
Pavel Yaskevich
2fd247a833 [QoI] Improve contextual mismatch diagnostics in calls with trailing closures
Resolves: rdar://problem/28012273
2017-06-21 11:27:35 -07:00
Pavel Yaskevich
2c7c74390d [QoI] Ignore incorrect parameter types when trying to diagnose trailing closures
Resolves: rdar://problem/28004686
2017-06-21 11:27:12 -07:00
Pavel Yaskevich
a5960d8993 [Diagnostics] NFC: Refactor closure result type validation into a function 2017-06-21 11:27:12 -07:00
Pavel Yaskevich
3a77295835 [QoI] Use information known about call parameters via failed constraint
This makes it a lot easier to diagnose contextual mismatch related
to arguments used by the call without relying on the type of the
function expression which is not always available.
2017-06-21 11:27:12 -07:00
Pavel Yaskevich
c46e3e83e8 [QoI] Improve diagnostics for single argument calls with trailing closures
Calls involving single trailing closure arguments require special
handling because we don't have as much contextual information
about function/argument types as in with regular calls, which means
that diagnosing such situations only by `visitApplyExpr`
yields subpar results.

Resolves: SR-4836.
2017-06-21 11:26:38 -07:00
Joe Groff
fc18cb88e5 Merge pull request #10427 from jckarter/tuple-shuffle-vararg-type
Sema: Ensure the array type for variadic tuple shuffles is always set.
2017-06-21 12:22:00 -04:00
Doug Gregor
72a1176d7b Merge pull request #10441 from DougGregor/paren-type-equality
[Type checker] Check type equality even for argument tuples in Swift 4.
2017-06-21 06:09:47 -07:00
Slava Pestov
fdd0259f7f Sema: Lift obsolete restriction on protocol extensions via typealias 2017-06-21 00:44:33 -07:00
Doug Gregor
a570a5a15e [Type checker] Check type equality even for argument tuples in Swift 4.
Replace a where Type-pointer-equality check with what it intended,
i.e., match up ParenTypes at the top level and perform a deeper
equality comparison of the underlying types.

Fixes SR-5166 / rdar://problem/32666189.
2017-06-20 23:49:47 -07:00
John McCall
3e75350192 Merge pull request #10391 from rjmccall/noescape-param-exclusivity
Implement the restriction on calls to non-escaping function parameter…
2017-06-20 21:29:00 -04:00
Joe Groff
8548693c9a Sema: Ensure the array type for variadic tuple shuffles is always set.
We neglected to set it on one path (a scalar-to-tuple conversion path currently only taken by subscript applications). Change TupleShuffleExpr's constructor to take it as an argument so this mistake is harder to make in the future. Fixes SR-5264 | rdar://problem/32860988.
2017-06-20 16:38:52 -07:00
John McCall
c131ea4d18 Implement the restriction on calls to non-escaping function parameters from the SE-0176 revision. 2017-06-20 17:29:20 -04:00
Xi Ge
bc73e4310e Sema: missing switch case fixits should print payload names explicitly instead of printing underscores. rdar://32121806 (#10409) 2017-06-20 14:13:37 -07:00
Mark Lacey
0ba4a312af Roll back a portion of SE-0110
As described in:
  https://lists.swift.org/pipermail/swift-evolution-announce/2017-June/000386.html

Specifically allow an N-ary argument function to be passed as an
argument in a place where a function of a single N-tuple is expected.

Fixes: rdar://problem/32875953
2017-06-20 11:05:28 -07:00
swift-ci
e941f3bc60 Merge pull request #10392 from CodaFi/game-set-match-call-arguments 2017-06-19 23:37:23 -07:00
Robert Widmann
9fa8341540 Only decompose function types for info about default arguments
AnyFunctionType::Param carries around information about decomposed
parameters now.  Information about default arguments must be computed
separately with swift::computeDefaultMap.
2017-06-19 23:05:44 -07:00
Jordan Rose
77de3dc1f2 [AST] Bring 'mutating' and 'inout self' in sync. (#10375)
- A mutating method or accessor always has 'inout self'.
- A nonmutating method or accessor never has 'inout self'.
- Only instance members can be mutating.
- Addressors are still addressors even when on static members.

Came up after reviewing another patch that confused the two as
possibly distinct concepts.
2017-06-19 16:16:47 -07:00
Alex Hoppen
6f3b8ca60f Merge pull request #9978 from ahoppen/pdm-remove-implicit-conversion
Remove implicit conversion from DeclBaseName to Identifier
2017-06-17 16:02:51 +02:00
Alex Hoppen
5cda94b1c1 Merge pull request #9977 from ahoppen/pdm-remove-get-name
Remove getName method from ValueDecl
2017-06-17 12:07:21 +02:00
Slava Pestov
a6339be1cd Sema: Fix historical quirk with @escaping diagnostics
Saying "implicitly non-escaping because it was declared @autoclosure"
does not make sense. Since Swift 3, parameters of function type are
non-escaping by default, whether or not they are @autoclosure.

We would also inhibit the fixit for inserting @escaping if the
@autoclosure attribute was present. Again, a holdover from the
Swift 2 days, when @autoclosure implied @noescape and the special
@autoclosure(escaping) attribute was used to define an escaping
autoclosure.
2017-06-17 00:48:07 -07:00
Rintaro Ishizaki
5d478bdb3b [Parse] Allow #if to guard switch case clauses
Resolves:
https://bugs.swift.org/browse/SR-4196
https://bugs.swift.org/browse/SR-2
2017-06-17 10:03:03 +09:00
Slava Pestov
2f82acc65e Merge pull request #10344 from slavapestov/underscored-attributes-are-secret
Sema: Don't talk about @_versioned in diagnostics for default arguments
2017-06-16 18:00:37 -07:00
Slava Pestov
9b2b3b5969 Sema: Don't talk about @_versioned in diagnostics for default arguments
Fixes <rdar://problem/32445206> and
<https://bugs.swift.org/browse/SR-4648>.
2017-06-16 17:00:15 -07:00
swift-ci
e40f6c2bb0 Merge pull request #10338 from nkcsgexi/skip-attribute 2017-06-16 16:48:36 -07:00
Robert Widmann
05cfcbd0c5 Merge pull request #10336 from CodaFi/you-know-my-name-look-up-the-index
Remove a hack and directly coerce call arguments
2017-06-16 16:19:54 -07:00
Xi Ge
568c861adc [FixCode] Protocol stubs shouldn't print any @ attributes.
This also addresses @jrose-apple's code review comments.
2017-06-16 16:04:57 -07:00
Slava Pestov
732b215b88 Merge pull request #9413 from rintaro/ast-eliminate-ifconfigstmt
[AST] Eliminate IfConfigStmt
2017-06-16 15:39:47 -07:00
Robert Widmann
70147a5748 Remove a hack and directly coerce call arguments 2017-06-16 15:22:10 -07:00
swift-ci
e1c98a3d4b Merge pull request #10331 from DougGregor/gsb-no-warn-inferred-result-type 2017-06-16 14:25:14 -07:00
Itai Ferber
c277aa16b5 Merge pull request #10321 from itaiferber/weak-unowned-codable-conformance
Allow synthesis of Codable for weak/unowned vars
2017-06-16 14:19:52 -07:00
Itai Ferber
a818babf8c Merge pull request #10253 from itaiferber/diagnostic-collation
Collate Codable failure diagnostics
2017-06-16 14:19:39 -07:00
Doug Gregor
55b3accf7d Merge pull request #10319 from DougGregor/escalate-type-soundness-warning
Escalate the warning about the "== Self" type soundness hole to an error
2017-06-16 14:06:43 -07:00
Joe Groff
f28d86cc99 Merge pull request #10327 from jckarter/keypath-mutation-warnings
Sema: Track writes through WritableKeyPaths for mutation warnings.
2017-06-16 16:45:48 -04:00
Doug Gregor
a9260f2d9a [GSB] Don't warn about redundancies due to inference from result types.
When we infer a requirement from the result type of a function, don't
warn if that requirement was also stated explicitly. This has been a
point of confusion since we introduced the redundancy warnings,
because users don't consider to result type to be an "input" to the
function in the way the compiler does. So, while technically it is
"correct" to warn, it's unintuitive---so stop.

Fixes SR-5072 / rdar://problem/31357967.
2017-06-16 13:45:07 -07:00
Doug Gregor
8b80681394 Escalate the warning about the "== Self" type soundness hole to an error.
Swift 3 had a type soundness hole in protocol conformance checking
where the requirement contained an "== Self" constraint and the
witness was a member of a non-final class. We previously closed the
type soundness hole in PR #9830, but left it as a warning in Swift 3
compatibility mode.

Escalate that warning to an error. The optimizers break due to this
type soundness hole, and of course it can lead to other runtime
breakage because it violates the type system.

Fixes rdar://problem/28601761.
2017-06-16 13:23:25 -07:00
Joe Groff
f262ced6e6 Sema: Track writes through WritableKeyPaths for mutation warnings.
Previously we would erroneously flag a `var` as not being mutated if the only mutations were through WritableKeyPaths. Fixes SR-5214 | rdar://problem/32599483.
2017-06-16 12:44:52 -07:00