Commit Graph

1357 Commits

Author SHA1 Message Date
Robert Widmann
535150c7c6 Move preCheckExpression to ConstraintSystem 2019-11-10 13:48:03 -08:00
Robert Widmann
7bad9aacc3 Drop the TypeChecker out of ConstraintSystem 2019-11-10 13:26:47 -08:00
Robert Widmann
e7ef8abd3a Migrate getTypeOfExpressionWithoutApplying 2019-11-10 13:15:55 -08:00
Robert Widmann
1123b1f897 Move constraint satisfiability utilities 2019-11-10 13:12:50 -08:00
Robert Widmann
d21424b58b Make typeCheckExpression a utility 2019-11-10 12:40:09 -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
Hamish Knight
f519505c8b Remove some more TypeChecker uses (#28132)
Remove some more TypeChecker uses
2019-11-07 17:56:45 -08:00
Robert Widmann
41ab235797 [CS] Remove some TypeChecker uses 2019-11-07 12:41:37 -08:00
Pavel Yaskevich
c3acce4d69 [CSDiag] Remove obsolete ArgumentMatcher from FailureDiagnosis
All of the argument diagnostics have been ported to the new diagnostic
framework, so now is the time to remove `ArgumentMatcher` and the only
place where it was used - `diagnoseSingleCandidateFailures`.
2019-11-07 11:17:01 -08:00
Robert Widmann
3cf7b5451e Remove references to TypeChecker in the constraint system 2019-11-06 15:08:59 -08:00
Robert Widmann
c4a0585ba5 Make getObjectLiteralConstructorName a utility 2019-11-06 15:08:59 -08:00
Pavel Yaskevich
6d02fb7815 Merge pull request #28057 from xedin/assign-diags
[Diagnostics] Port the rest of assignment diagnostics to the new framework
2019-11-06 00:11:08 -08:00
Robert Widmann
e804d6ed9a Make TypeChecker::getDefaultType a utility 2019-11-05 20:31:15 -08:00
Pavel Yaskevich
56f4215f7f [CSDiag] NFC: Remove obsolete handling of type mismatches in unresolved members refs 2019-11-05 12:46:15 -08:00
Pavel Yaskevich
7cc603390a [CSDiag] Remove obsolete FailureDiagnosis::visit{Assign, InOut}Expr 2019-11-05 12:46:15 -08:00
Pavel Yaskevich
7cd7cd43e6 [Diagnostics] Port self assignment diagnostic to the new framework 2019-11-05 12:38:13 -08:00
Holly Borla
561e527848 [ConstraintSystem] Extend the ExplicitlySpecifyGenericArguments fix to cover
all cases of missing generic parameters.

In `ComponentStep::take` when there are no bindings or disjunctions, use hole
propagation to default remaining free type variables that aren't for generic
parameters and continue solving. Rather than using a defaultable constraint for
holes, assign a fixed type directly when we have no bindings to try.
2019-11-05 09:15:13 -08:00
Luciano Almeida
095bb5bac7 [CSDiag] Removing invalid_optional_chain diagnostic from CSDiag 2019-11-04 01:13:51 -03:00
Luciano Almeida
43a3ca46c9 Removing invalid force unwrap from CSDiag 2019-11-03 23:21:14 -03:00
Pavel Yaskevich
ddb7bbc25b [CSDiag] NFC: Remove obsolete trailing closure diagnostics 2019-11-01 10:36:20 -07:00
Robert Widmann
5a7040e2a4 Remove PossiblyInvalidDecls 2019-10-30 15:09:14 -07:00
Robert Widmann
41d099bc91 Remove the argument to setInvalid() 2019-10-30 15:09:14 -07:00
Robert Widmann
89b81a28da Fixup calls to TypeChecker::lookupXXX 2019-10-30 12:55:42 -07:00
Robert Widmann
118f68b1be Make getProtocol and getLiteralProtocol static utilities 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
Anthony Latsis
d64d45d3d6 @lvalue exposure fixes & prevention 2019-10-22 04:30:40 +03: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
04637adce3 [CSDiag] Remove diagnoseTypeRequirementFailure and
diagnoseUnresolvedDotExprTypeRequirementFailure.
2019-10-18 15:42:20 -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
Pavel Yaskevich
c47a40c779 [CSDiag] NFC: Remove visitKeyPathExpr which is now obsolete 2019-10-17 13:52:40 -07:00
Pavel Yaskevich
989b573f8e [CSDiag] NFC: Remove extraneous argument diagnostics which are now obsolete 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
22813d96cf [ConstraintSystem] Extend MatchCallArgumentListener::extraArguments to return all extraneous arguments 2019-10-16 10:19:25 -07:00
Robert Widmann
742f6b2102 Drastically Simplify VarDecl Validation
This is an amalgam of simplifications to the way VarDecls are checked
and assigned interface types.

First, remove TypeCheckPattern's ability to assign the interface and
contextual types for a given var decl.  Instead, replace it with the
notion of a "naming pattern".  This is the pattern that semantically
binds a given VarDecl into scope, and whose type will be used to compute
the interface type. Note that not all VarDecls have a naming pattern
because they may not be canonical.

Second, remove VarDecl's separate contextual type member, and force the
contextual type to be computed the way it always was: by mapping the
interface type into the parent decl context.

Third, introduce a catch-all diagnostic to properly handle the change in
the way that circularity checking occurs.  This is also motivated by
TypeCheckPattern not being principled about which parts of the AST it
chooses to invalidate, especially the parent pattern and naming patterns
for a given VarDecl.  Once VarDecls are invalidated along with their
parent patterns, a large amount of this diagnostic churn can disappear.
Unfortunately, if this isn't here, we will fail to catch a number of
obviously circular cases and fail to emit a diagnostic.
2019-10-14 12:06:50 -07:00
Pavel Yaskevich
10b1baebb2 Merge pull request #27362 from xedin/port-missing-args
[Diagnostics] Port missing argument(s) diagnostics
2019-09-25 21:08:54 -07:00
Pavel Yaskevich
48520f7732 [CSDiag] Remove obsolete logic to related to missing argument failures 2019-09-25 10:45:54 -07:00
Robert Widmann
3e48f71b27 Merge pull request #27314 from CodaFi/an-interface-to-the-interface
Requestify getInterfaceType() in Name Only
2019-09-23 22:35:24 -07:00
Robert Widmann
f053f9c480 Port getInterfaceType() patterns in libSema 2019-09-23 16:49:29 -07:00
Pavel Yaskevich
b15ef15a60 [ConstraintSystem] Change missingArgument callback to produce an index of synthesized argument
In diagnostic mode allow argument matcher to synthesize new
arguments, which makes it much easier to diagnose problems
related to missing arguments.
2019-09-23 12:59:27 -07:00
Pavel Yaskevich
96598d8ebf Merge pull request #26207 from owenv/new-vararg-conversion-diag
[Diagnostics] Improve diagnostic when attempting to pass an Array to a variadic argument
2019-09-23 12:57:44 -07:00
Robert Widmann
b135928125 Drop CheckingWithValidSignature from the validation state machine
Now that the generic signature is computable on demand, this predicate is doubly useless.  All of the callers intended to ask "hasInterfaceType" anyways.
2019-09-20 22:22:49 -07:00
Owen Voorhees
6c5185f2e3 Improve diagnostic when attempting to pass an Array to a variadic argument
- Give a more specific diagnostic which indicates the parameter is variadic
- If the argument is an Array literal, offer to drop the brackets
2019-09-20 17:30:23 -07:00
Pavel Yaskevich
5c01a1185d Merge pull request #27215 from xedin/remove-fn-dep-from-missing-args
[Diagnostics] A couple of clean-ups for `AddMissingArguments`
2019-09-17 15:01:21 -07:00
Hamish Knight
58459e7439 [CS] Allow simplification of key path subscript arg locators (#27194)
[CS] Allow simplification of key path subscript arg locators
2019-09-17 14:28:59 +01:00
Pavel Yaskevich
c968c14a24 [Diagnostics] Cover single explicit tuple argument -> N parameters via missing arguments fix
Expand tuple into N arguments to cover expect parameters.

This covers cases like this:

```swift
func foo(_: (Int, Int) -> Void) {}
foo { (bar: (Int, Int)) in } // used a single tuple type `(Int, Int)`
                             // instead of two distinct arguments
```
2019-09-17 00:27:17 -07:00
Pavel Yaskevich
2f325fa1d8 [Diagnostics] Don't store contextual type in missing argument fix/diagnostic
Instead of storing contextual function type in the fix/diagnostic,
let's fetch it from context (solution and/or locator) because it's
only used when it is a trailing closure missing some arguments anyway.
2019-09-16 16:50:31 -07:00
Hamish Knight
4af9744fe3 [CS] NFC: Move simplifyLocator out of CSDiag
We eventually want to get rid of CSDiag, but
`simplifyLocator` is definitely something we want
to keep around.
2019-09-15 21:39:32 +01:00