Commit Graph

16 Commits

Author SHA1 Message Date
Pavel Yaskevich
b9a0ca6afb [ConstraintSystem] Detect and diagnose conversion failures related to collection element types
Detect and diagnose a contextual mismatch between expected
collection element type and the one provided (e.g. source
of the assignment or argument to a call) e.g.:

```swift
let _: [Int] = ["hello"]

func foo(_: [Int]) {}
foo(["hello"])
```
2019-05-14 17:33:11 -07:00
Pavel Yaskevich
b429d5a28a [ConstraintSystem] Erase InOutExpr from member base
Diagnostics could introduce type-checked expressions into AST during
it's bottom up re-typechecking in attempt to find a problem.

To minimize number of AST permutations solver has to handle
let's just strip away implicit `InOutExpr` introduced by previous
successful type-checks, which is not really important anyway.

Resolves: rdar://problem/46459603
2018-12-10 23:23:22 -08:00
gregomni
cb73ffb278 Fix assert with incorrectly allowing optional injection into operator inout argument. 2018-07-22 15:14:50 -07:00
Pavel Yaskevich
aff4974433 [CSSolver] Prioritize bindings with fewer default types
With all else equal prioritize bindings with fewer defaultable types,
which always gets us closer to solution since defaultable bindings
mostly come from the collections and could be checked at the end.
This also makes sure that solver not as aggresive at assigning bindings
to trailing closures and allows solver to consider types which come
from inside the closure.

Resolves: rdar://problem/37290898
2018-02-10 17:38:52 -08:00
Pavel Yaskevich
0783890b03 [CSGen] Fix LinkedExprAnalyzer greedy operator linking
Let's not attempt to link arithmetic operators together in
presence of concrete and literal (int, float, string) types.

Resolves: rdar://problem/35740653
2017-11-29 22:13:45 -08:00
Arnold Schwaighofer
c544a2779d Revert "[CSGen] Fix LinkedExprAnalyzer greedy operator linking"
This reverts commit 29ea599f30.

SR-6505
2017-11-29 19:42:47 -08:00
Pavel Yaskevich
29ea599f30 [CSGen] Fix LinkedExprAnalyzer greedy operator linking
Let's not attempt to link arithmetic operators together in
presence of concrete and literal types.

Resolves: rdar://problem/35740653
2017-11-29 14:48:10 -08:00
Pavel Yaskevich
82cffe4cc0 [QoI] Add test-case for rdar://problem/28688585 2017-08-10 12:31:41 -07:00
Pavel Yaskevich
13e67ab1d7 [QoI] Add test-case for rdar://problem/33759839 2017-08-10 12:31:32 -07:00
Slava Pestov
71cf245701 Merge pull request #7023 from KingOfBrian/bugfix/SR-2115
Generate unused variable warnings in top level statements
2017-01-29 20:25:46 -08:00
Doug Gregor
545c43f500 [Type checker] Don't shrink() arithmetic expressions of literals.
Shrinking such expressions will immediately restrict the solution set
to the default literal types (Int or Double), causing later solutions
to fail. Fixes rdar://problem/30220565.
2017-01-27 14:48:12 -08:00
Brian King
edc193efa0 Fix warnings in top level statements 2017-01-24 22:53:21 -05:00
Jacob Bandes-Storch
25cb143b8e [CSGen] handle ForceValueExpr in LinkedExprAnalyzer
The default behavior was looking *through* the ForceValueExpr, so in this test case the LinkedExprAnalyzer thought it was dealing with Optional<Double> rather than Double. Resolves SR-1122.
2017-01-01 02:36:51 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
John McCall
c8c41b385c Implement SE-0077: precedence group declarations.
What I've implemented here deviates from the current proposal text
in the following ways:

- I had to introduce a FunctionArrowPrecedence to capture the parsing
  of -> in expression contexts.

- I found it convenient to continue to model the assignment property
  explicitly.

- The comparison and casting operators have historically been
  non-associative; I have chosen to preserve that, since I don't
  think this proposal intended to change it.

- This uses the precedence group names and higherThan/lowerThan
  as agreed in discussion.
2016-07-26 14:04:57 -07:00
Doug Gregor
80f0852504 [SE-0091] Allow 'static' operators to be declared within types and extensions thereof.
Allow 'static' (or, in classes, final 'class') operators to be
declared within types and extensions thereof. Within protocols,
require operators to be marked 'static'. Use a warning with a Fix-It
to stage this in, so we don't break the world's code.

Protocol conformance checking already seems to work, so add some tests
for that. Update a pile of tests and the standard library to include
the required 'static' keywords.

There is an amusing name-mangling change here. Global operators were
getting marked as 'static' (for silly reasons), so their mangled names
had the 'Z' modifier for static methods, even though this doesn't make
sense. Now, operators within types and extensions need to be 'static'
as written.
2016-07-18 23:18:57 -07:00