Commit Graph

1366 Commits

Author SHA1 Message Date
Pavel Yaskevich
495f14a698 [ConstraintSystem] Use new trailing closure fix in matchCallArguments 2019-11-01 01:20:13 -07:00
Pavel Yaskevich
82c2456295 Merge pull request #27976 from xedin/extraneous-call
[Diagnostics] Introduce extraneous call fix
2019-10-31 11:57:03 -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
Robert Widmann
4996858c4d Re-implement isInvalid for ValueDecls 2019-10-30 15:09:14 -07:00
Robert Widmann
929332e12a Make isAvailabilitySafeForConformance a utility 2019-10-30 12:55:42 -07:00
Robert Widmann
972e755e9b Give ConstraintSystem's outlet to the ASTContext
Make it less tempting to ask for the type checker embedded into
ConstraintSystem by using the accessor to the ASTContext.
2019-10-30 12:55:42 -07:00
Robert Widmann
da2b063af9 Make calls to lookupMember actually look static 2019-10-30 12:55:42 -07:00
Robert Widmann
b849e51768 Use operator bool to claw back some readability 2019-10-29 16:56:21 -07:00
Robert Widmann
3e1a61f425 [NFC] Fold The Tri-State In Optional<ProtocolConformanceRef>
ProtocolConformanceRef already has an invalid state.  Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it.  Mechanically
translate all of the callers and callsites to use this new
representation.
2019-10-29 16:55:56 -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
5d1eeacbe4 Resolving conflicts 2019-10-23 07:25:55 -03:00
Pavel Yaskevich
d5b232c26e Merge pull request #27834 from xedin/for-in-diag
[TypeChecker] Produce a tailored diagnostic for `for-in` sequence fai…
2019-10-23 00:32:35 -07:00
Pavel Yaskevich
fb6ce64628 Merge pull request #27842 from xedin/if-ternary-diags
[Diagnostics] Improve if/ternary condition expression diagnostics
2019-10-23 00:32:06 -07:00
Pavel Yaskevich
74a7f3d8d0 [TypeChecker] Produce a tailored diagnostic for for-in sequence failures
`for-in` "sequence" expression is required to conform to `Sequence`.
2019-10-22 16:57:28 -07:00
Pavel Yaskevich
c4fee1d0c9 [ConstraintSystem] Use new condition element in constraint generation/diagnostics 2019-10-22 15:01:49 -07:00
Hamish Knight
be23ecc878 These functions don't need a TypeChecker 2019-10-22 09:23:33 -07:00
Luciano Almeida
cac0d07d78 Attempting UnnecessaryCoercion for ExplicityTypeCoercion on CSSimplify 2019-10-21 23:05:06 -03:00
Robert Widmann
a537e04a12 Break Another Overload Resolution Cycle
Resolve a cycle caused by overload resolution considering recursive
static candidates where before it would silently reject them.  In
a world before the InterfaceTypeRequest, the overload resolution
machinery would attempt to validate the declaration and would recieve
a bad answer.  This caused circular candidates to be ignored as a side
effect.  This behavior was partially restored by the fixes in #27725 and #27668
but that isn't enough for recursive static variables.  Even if it were,
the constraint fix kind doesn't make sense.

Luckily, the right answer is to just reject recursive static VarDecl
candidates entirely.

Addresses rdar://56410015
2019-10-20 23:56:00 -07:00
Holly Borla
e5c99cace6 Merge pull request #27769 from hborla/anyobject-conformance-failure
[ConstraintSystem] Diagnose missing AnyObject conformance using the MissingConformance constraint fix.
2019-10-18 22:10:21 -04:00
Holly Borla
dca1373e46 [ConstraintSystem] Don't fail in matchTypes when two primary archetype types
are not equal when part of a type requirement. This allows the
SkipSameTypeRequirement constraint fix to be applied instead.
2019-10-18 17:34:03 -07: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
Holly Borla
ec864fcd9c [ConstraintFix] Don't pass along the RequirementKind to the MissingConformance
constraint fix. Instead, get the kind from the locator.
2019-10-18 09:03:06 -07:00
Pavel Yaskevich
14d9011c2b Merge pull request #27759 from xedin/port-keypath-diags
[Diagnostics] Port more key path related failures to new framework
2019-10-18 01:02:43 -07:00
Holly Borla
f998349815 [Diagnostics] Add a tailored note for when the Wrapped type of an
optional satisfies a failed requirement.
2019-10-17 19:59:07 -07:00
Pavel Yaskevich
0d07cd87ac [ConstraintSystem] Detect and diagnose contextual mismatches in key path components 2019-10-17 13:52:00 -07:00
Pavel Yaskevich
57c770238c [ConstraintSystem] Detect and diagnose missing member refs in key path
Key path components can reference an invalid or missing member
just like regular expressions, so we need to account for that
while trying to simplify key path constraint.
2019-10-17 12:55:08 -07:00
Pavel Yaskevich
d379e2387e Merge pull request #27473 from LucianoPAlmeida/force-downcast-fix-explicit-coercion
[ConstraintSystem] Diagnosing invalid explicit coercion via fix
2019-10-17 00:41:01 -07:00
Holly Borla
ef0ecc41e5 [ConstraintSystem] Diagnose missing AnyObject conformance using
the MissingConformance constraint fix.
2019-10-16 20:38:00 -07:00
Pavel Yaskevich
09a36ddf17 [ConstraintSystem] Adjust keypath subscript assert to account for dynamic member lookup
It's possible to find a suitable overload choice for
key path application through keypath dynamic member
lookup and assertion inside `addKeyPathApplicationRootConstraint`
should account for that.

Resolves: rdar://problem/56350060
2019-10-16 16:38:16 -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
8d3409bddf [ConstraintSystem] Allow argument matcher to continue in presence of missing/extra arguments
This makes it possible to find all of the problems related to a given
set of arguments and fix/score each overload candidate correctly.
2019-10-16 10:19:26 -07:00
Pavel Yaskevich
1022ac7678 [ConstraintSystem] Check whether extraneous arguments are related to tuple splat
Before recording a generic "extraneous arguments" fix, let's check
whether this is a tuple splat with a single parameter.
2019-10-16 10:19:26 -07:00
Pavel Yaskevich
1b7dc3209b [ConstraintSystem] Fix an attempt to construct Void type with arguments 2019-10-16 10:19:26 -07:00
Pavel Yaskevich
1b302b98d3 [ConstraintSystem] Record a fix for extraneous arguments after matcher is done 2019-10-16 10:19:26 -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
86bcecf5fc [CSSimplify] Introduce extraneous argument fixes 2019-10-16 10:19:25 -07:00
Pavel Yaskevich
22813d96cf [ConstraintSystem] Extend MatchCallArgumentListener::extraArguments to return all extraneous arguments 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
73dcc4b5e8 Merge branch 'master' of https://github.com/apple/swift into force-downcast-fix-explicit-coercion 2019-10-15 19:18:46 -03:00
Hamish Knight
fc020bb3f4 [CS] Add ConstraintSystem::addFixConstraint
This lets us add a constraint to the system with an associated fix.
Unlike `addUnsolvedConstraint`, this will attempt to immediately
simplify the constraint, producing an unsolved constraint if necessary.
2019-10-15 10:12:48 -07:00
Hamish Knight
9d21fbb445 [CS] Don't try inout-to-ptr for array to raw ptr
Array-to-pointer should only be used for such conversions. This isn't
currently an issue as we short-circuit disjunctions upon successfully
solving an array-to-pointer conversion. However this would become an
issue if only inout-to-pointer was viable.
2019-10-15 10:12:48 -07:00
Hamish Knight
2759ae29bb [AST] Add TypeBase::lookThroughSingleOptionalType 2019-10-15 10:12:48 -07:00
Robert Widmann
f15544de0b Strike VarDecls in Pattern Binding Initializers From Overloads
We would previously consider the VarDecls bound by a particular pattern
binding initializer context when performing overload resolution.  This
would lead to circular validation.  Validation was tacitly breaking the
cycle by returning an error type (but, crucially, not setting that
interface type).  Instead, pre-reject circular candidates.

This greatly improves the diagnostic we emit here in truly circular
cases since we can ride on `UR_InstanceMemberOnType` to yield

struct PatternBindingWithTwoVars2 { var x = y, y = 3 }
// cannot use instance member 'y' within property initializer; property initializers run before 'self' is available
2019-10-14 11:54:24 -07: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
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