Pavel Yaskevich
c9c20afe27
[Diagnostics] Port name shadowing diagnostics
...
Diagnose an attempt to reference a top-level name shadowed by
a local member e.g.
```swift
extension Sequence {
func test() -> Int {
return max(1, 2)
}
}
```
Here `min` refers to a global function `min<T>(_: T, _: T)` in `Swift`
module and can only be accessed by adding `Swift.` to it, because `Sequence`
has a member named `min` which accepts a single argument.
2020-01-29 09:14:24 -08:00
Pavel Yaskevich
7351bfc86f
[CSFix] Add a fix to add a missing qualifier to shadowed top-level name references
2020-01-29 09:14:24 -08:00
Pavel Yaskevich
b2083db45d
[ConstraintSystem] Add a fix to allow conversion between non-class type and AnyObject
2020-01-29 00:06:57 -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
Luciano Almeida
716e11f575
[Constraint System] Recording SpecifyObjectLiteralTypeImport fix when attempting literal result type variable binding and handle object literal in MissingArgumentsFailure
2020-01-21 20:39:44 -03:00
Luciano Almeida
68e09d64fd
[CSFix] Creating object literal module import fix
2020-01-21 11:54:26 -03:00
Holly Borla
94bbb8f76e
[ConstraintSystem] Finish porting unresolved member reference failures.
...
This covers member failures where the error is at the declaration, so
the result of member lookup is "already diagnosed".
2020-01-05 11:33:02 -08:00
Pavel Yaskevich
8bcc192591
[Diagnostics] Diagnose inability to infer (complex) closure return type
2019-12-19 12:16:30 -08:00
Pavel Yaskevich
5ba2e59c63
Merge pull request #28752 from xedin/simplify-potential-binding
...
[ConstraintSystem] Record originator constraint for each type variable binding
2019-12-13 11:50:02 -08:00
Pavel Yaskevich
f259286bd7
[CSFix] Convert missing explicit @escaping fix to be a contextual mismatch
...
Sometimes diagnostic needs both sides of the conversion e.g.
when there is an attempt to bind generic argument to non-escaping type.
2019-12-12 12:42:08 -08:00
Holly Borla
3d1ab4da67
Merge pull request #28712 from hborla/function-parameter-mismatch-diagnostics
...
[ConstraintSystem] Port function parameter type mismatch diagnostics.
2019-12-11 14:33:07 -08:00
Holly Borla
51c7c8c8f1
[ConstraintSystem] Port function parameter type mismatch diagnostics.
2019-12-11 10:45:52 -08:00
Brent Royal-Gordon
addbe3e5ed
[NFC] Thread DeclNameRef through most of the compiler
...
This huge commit contains as many of the mechanical changes as possible.
2019-12-11 00:55:18 -08:00
Holly Borla
50abedd45c
[Diagnostics] Keep track of the indices of the tuple elements whose
...
types do not match in AllowTupleTypeMismatch/TupleContextualFailure.
2019-12-09 11:04:34 -08:00
Holly Borla
1e013a02cf
[ConstraintSystem] Move FailureDiagnostic::getFunctionArgApplyInfo
...
into `ConstraintSystem`.
2019-12-06 15:43:39 -08:00
Holly Borla
f9a1ab28f4
[ConstraintSystem] Port tuple type mismatches to the new framework
2019-12-06 13:12:57 -08:00
Pavel Yaskevich
3c5290c78c
[Diagnostics] Diagnose inability to infer contextual base type for member ref
2019-12-03 12:07:16 -08:00
Pavel Yaskevich
ac1ab1dfb0
[CSFix] Fix inability to infer contextual base type for member ref
2019-12-03 12:07:16 -08:00
Pavel Yaskevich
15c58d19d5
[ConstraintSystem] Detect passing array to variadic argument in function conversions
...
Initially this problem was only detected and diagnosed for calls.
So let's extend it to function conversions as well e.g.:
```swift
func foo<T>(_: [T]) {}
func bar<T>(_ f: (T...) -> ()) {}
bar { foo($0) }
```
2019-12-03 12:07:15 -08:00
Pavel Yaskevich
bdeaced0f2
[CSFix] Convert force optional unwrap fix into a contextual one
2019-11-19 15:15:29 -08:00
Holly Borla
a9a0bba31b
[Diagnostics] Don't apply the single parameter tuple splat fix if the
...
parameter type is a generic parameter.
2019-11-18 16:19:33 -08:00
Holly Borla
ea1a46c84d
[ConstraintFix] Rather than creating a coalesced fix right before
...
diagnosing failures in applySolutionFixes, coalesce fixes and
diagnose failures in one method on ConstraintFix.
This eliminates the need for the `DefaultGenericArgument` fix (which
was renamed from `ExplicitlySpecifyGenericArguments`) to have an
array of missing parameters, which was only used when the fixes were
coalesced. Instead, the coalesced arguments are used to create the
`MissingGenericArgumentsFailure` diagnostic directly.
2019-11-13 14:15:40 -08:00
Robert Widmann
63896c1fc5
Make more high-level type checking endpoints utility
2019-11-10 13:03:46 -08:00
Doug Gregor
bc926f7eb7
[Constraint system] Drop the root expression from FailureDiagnostic.
...
We're not using it for anything, now.
2019-11-08 22:38:49 -08:00
Robert Widmann
7b9d28d7ba
Make diagnoseSelfAssignment a utility
2019-11-06 15:08:59 -08:00
Pavel Yaskevich
30440d8235
[Diagnostics] Properly diagnose assignment mismatch in ambiguity cases
2019-11-05 12:38:13 -08:00
Pavel Yaskevich
7cd7cd43e6
[Diagnostics] Port self assignment diagnostic to the new framework
2019-11-05 12:38:13 -08:00
Holly Borla
e840d52258
[Diagnostics] Allow fixes with the same locator to be coalesced before
...
application rather than throwing away subsequent fixes.
The "primary fix" decides whether or not to coalesce fixes that have
the same locator.
2019-11-05 09:15:13 -08:00
Hamish Knight
65dda6d945
Address other review feedback
2019-11-03 08:42:26 -08:00
Hamish Knight
7077a68b83
[Sema] Diagnose unsound pointer conversions
...
Diagnose ephemeral conversions that are passed to @_nonEphemeral
parameters. Currently, this defaults to a warning with a frontend flag
to upgrade to an error. Hopefully this will become an error by default
in a future language version.
2019-11-03 08:42:25 -08:00
Pavel Yaskevich
6bb659c5a3
[Diagnostics] Add a diagnostic for incorrect use of trailing closures
2019-10-31 20:58:01 -07:00
Pavel Yaskevich
d87d22d336
[ConstraintSystem] Intoduce a fix for incorrect use of trailing closures
2019-10-31 20:57:09 -07:00
Pavel Yaskevich
1315207a22
[Diagnostics] Introduce extraneous call fix
...
Detect and diagnose attempts to call variables and/or properties
which don't have a function type, so can't really support
invocation.
2019-10-30 16:53:42 -07:00
Pavel Yaskevich
58329e0c27
Revert "[Diagnostics][Qol] SR-11295 Emit diagnostics for same type coercion. "
2019-10-25 01:05:07 -07:00
Luciano Almeida
a92e62f51f
Fixing formatting issues
2019-10-23 23:54:48 -03:00
Luciano Almeida
4385dd854f
Creating UnnecessaryCoercion warning fix
2019-10-21 23:03:12 -03:00
Pavel Yaskevich
8d05192204
Merge pull request #27728 from xedin/port-extraneous-args
...
[Diagnostics] Diagnose extraneous argument(s) via fixes
2019-10-18 10:42:56 -07:00
Pavel Yaskevich
2a0080c6e0
[Diagnostics] Add a workaround for inability to diagnose name shadowing
...
Let's cover at least the most common cases - min/max. Fixing the
problem requires refactoring of `resolveDeclRefExpr`.
2019-10-16 10:19:26 -07:00
Pavel Yaskevich
04850655dc
[CSFix] Make sure single parameter tuple splat is detected correctly
...
In situations like:
```swift
func foo<T>(x: T) {}
foo(a; 0, x: 42)
```
Let's not try to fix call to `foo` as a tuple splat because match is
in a middle of the argument list, it should be considered a regular
extraneous argument instead.
2019-10-16 10:19:26 -07:00
Pavel Yaskevich
c97603f5d4
[CSDiagnostics] Diagnose extraneous arguments
2019-10-16 10:19:25 -07:00
Pavel Yaskevich
e97164dfce
[CSFix] Record all available information about extraneous arguments
...
Most importantly - index, label, and type, which are useful for
diagnostics.
2019-10-16 10:19:25 -07:00
Pavel Yaskevich
e33a3402cb
[ConstraintSystem] Make contextual function type available for matchCallArguments
...
Helps diagnostics to avoid digging this type out from locator.
2019-10-16 10:19:25 -07:00
Pavel Yaskevich
f1ed46ee82
[CSFix] Add a fix to remove extraneous arguments
...
If there are more arguments than parameters, let's fix this by
ignoring (if possible) or removing extraneous arguments. Ignored
arguments could default to `Any` if they don't get any other
contextual type.
2019-10-16 10:19:25 -07:00
Luciano Almeida
f554dd3f51
CoerceToCheckedCast::attempt logic
2019-10-15 19:12:34 -03:00
Luciano Almeida
30ffe13cba
Merge branch 'master' of https://github.com/apple/swift into force-downcast-fix-explicit-coercion
2019-10-13 11:09:37 -03:00
Luciano Almeida
171d6ec87d
Adjusting tests under test/Constraints/bridging-nsnumber-and-nsvalue.swift.gyb
2019-10-13 00:42:22 -03:00
Luciano Almeida
d896968d2c
clang-format
2019-10-12 22:39:12 -03:00
Luciano Almeida
697b407589
Fixing test on test/Generics/conditional_conformances.swift
2019-10-12 18:20:23 -03:00
Luciano Almeida
05cea3a7b7
Fix issue with dictionary_downcast tests
2019-10-12 16:49:36 -03:00
Luciano Almeida
f39ff88113
Initial implementation of moving the checks
2019-10-12 15:22:16 -03:00