Commit Graph

18 Commits

Author SHA1 Message Date
Luciano Almeida
fab4b876ee [tests] Adjusting key path tests to diagnostic of key path refering to init methods 2020-03-28 16:33:32 -03:00
Hamish Knight
b62c9b6b01 [CS] Use getParameterType for KeyPath as function
Previously we were using `getPlainType` to match
the parameter type against the key path's base
type. This gave us the external parameter type,
which would be the element type for a variadic
parameter.  However the code we generate expects
the internal parameter type, which is provided by
`getParameterType`.

Resolves rdar://problem/59445486.
2020-03-11 17:21:28 -07:00
Pavel Yaskevich
47c7b9b910 [Diagnostics] Upon keypath result contextual mismatch try to match object types
If there was a mismatch between last component type and contextual
key path result type, let's try to re-match the types with all optionals
stripped off. In cases where the problem is optionality difference
e.g. `[Int] vs. [Int]?` that propagates contextual information to
the last component which facilitates better diagnostics.

Resolves: rdar://problem/57843297
2019-12-13 00:50:54 -08:00
Holly Borla
e63f259f4f [ConstraintSystem] Bind holes to UnresolvedType instead of Any. 2019-11-05 09:15:13 -08:00
Brent Royal-Gordon
932128eab6 Fix SE-0249 source compatibility break
In some situations where both the KeyPath and closure solutions for an expression with a keypath literal were valid, the type checker could not choose between them and Swift would emit an “ambiguous use” error. This change increase the typechecking score of the closure solution so that the typechecker will favor the KeyPath solution, preserving source compatibility for existing APIs.

Fixes rdar://problem/56131416.
2019-10-09 17:17:41 -07:00
Doug Gregor
562ed4d999 [Constraint solver] Tie together all of the type variables in a key path.
This is a workaround for rdar://problem/54322807 that should limit the
expansion in the number of constraint scopes visited.
2019-08-20 11:11:07 -07:00
Greg Titus
cf047295d7 Coerce key path index expr to handle upcast correctly. 2019-08-18 18:44:34 -07:00
gregomni
469e06ae2c Update to HEAD, fix Param type changes, merging. 2019-08-06 07:52:56 -07:00
gregomni
bf3a786227 Add tests with no contextual type info. 2019-08-06 07:52:56 -07:00
gregomni
a2cd53d802 Handle simplification of optional-chaining key path literals, distinguish function type and keypath BGT type without explicit disjunctions. 2019-08-06 07:52:56 -07:00
Brent Royal-Gordon
ffe1684a8e Add typechecking tests 2019-08-06 07:52:56 -07:00
Sam Lazarus
64b1186cb7 Sema: Change closure passed to matchDeepTypeArguments to return if it recorded anything 2019-06-14 12:35:32 -04:00
Sam Lazarus
cd0cc3c2c4 Test: Add a todo about a regression introduced by generic mismatch diagnostic 2019-06-14 12:35:32 -04:00
gregomni
821f63fe98 Make assignments and assignment failure diagnoses directly in the CS.
More specific diagnoses for assigning to read-only keypaths.
'computeAssignDestType' is dead code now.
ConstraintFix shouldRecordFix()
2018-08-24 20:39:03 -07:00
gregomni
d604047625 When root type of a keypath is unresolved by the constraint system, use the root interface type for diagnosis. 2018-07-31 17:15:12 -07:00
Mark Lacey
fea720f229 [MiscDiagnostics] Emit a deprecation warning for some writes through literal keypaths.
We incorrectly allowed some keypaths to be inferred as writable
keypaths in Swift 3/4 modes. This no longer happens when
-swift-version 5 is specified.

This warning is a limited attempt at providing some advanced notice of
code that will break, only in the cases where the keypath is a direct
argument to a keypath subscript write.

Fixes: rdar://problem/40068274
2018-06-25 23:03:06 -07:00
Mark Lacey
9687615d58 Fix RUN lines in a couple constraint solver tests. 2018-06-19 12:57:05 -07:00
Mark Lacey
83ebd71644 Allowing forming WritableKeyPath to read-only value in Swift 3/4.
We inadvertantly allowed this in the past, so continue to do so when
compiling in Swift 3/4 mode to avoid suddenly breaking existing code.

The diagnostic here is pretty bad, and I've opened issues for that as
well as providing some kind of deprecation warning for this so that
even under Swift 3/4 mode we alert users that this is unsupported.

rdar://problem/39802797
2018-05-08 14:26:02 -07:00