Commit Graph

651 Commits

Author SHA1 Message Date
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
Doug Gregor
9204d7cee4 [Constraint systme] Rename solve() -> solveImpl().
solve() is a bit too overloaded, so rename the version that does the
core "evaluate all of the steps to produce a set of solutions"
functionality to solveImpl().
2019-11-08 21:26:04 -08:00
Robert Widmann
e6dbfa393a Move Utilities back to TypeChecker 2019-11-06 15:20:46 -08:00
Robert Widmann
3cf7b5451e Remove references to TypeChecker in the constraint system 2019-11-06 15:08:59 -08:00
Robert Widmann
a840af35cd Move getSelfForInitDelegationInConstructor to ASTContext 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
Robert Widmann
fba3c1d0cb Make building and manipulating checked DeclRefs a utility 2019-11-05 20:30:40 -08:00
Robert Widmann
392df03466 [NFC] Drop unnecessary TypeCheckers from Sema 2019-11-05 20:30:40 -08:00
Pavel Yaskevich
30440d8235 [Diagnostics] Properly diagnose assignment mismatch in ambiguity cases 2019-11-05 12:38:13 -08:00
Holly Borla
33b9d4c446 [Diagnostics] Change FailureDiagnostic::resolveType to replace
holes with generic parameters directly when possible.
2019-11-05 09:17:53 -08:00
Holly Borla
4fd1377c81 [ConstraintSystem] With the new approach for holes, hole propagation happens
automatically.

This commit also renames `ConstraintSystem::recordHole/isHole` to
`recordPotentialHole` and `isPotentialHole` to make it clear that
we don't know for sure whether a type variable is a hole until it's
bound to unresolved.
2019-11-05 09:15:13 -08:00
Holly Borla
e63f259f4f [ConstraintSystem] Bind holes to UnresolvedType instead of Any. 2019-11-05 09:15:13 -08:00
Holly Borla
9093dfcd20 [ConstraintSystem] Move hole propagation to addTypeVariableConstraintsToWorkList
where we are already gathering constraints.
2019-11-05 09:15:13 -08:00
Holly Borla
3bc2269f4f [ConstraintSystem] Allow generic parameters and holes to default to
`Any` in `getPotentialBindings` rather than `ComponentStep::take`.
2019-11-05 09:15: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
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
Brent Royal-Gordon
17169fc1fe Merge pull request #27950 from brentdax/dumpster-fire
[NFC] Standardize dump() methods in frontend
2019-10-31 20:36:26 -07:00
Brent Royal-Gordon
ffbe53e290 [NFC] Eliminate const_casts in constraint system dumpers 2019-10-31 18:41:11 -07:00
Robert Widmann
0267384e11 Fixup SourceKit and Tests
Patch up all the places that are making a syntactic judgement about the
isInvalid() bit in a ValueDecl.  They may continue to use that query,
but most guard themselves on whether the interface type has been set.
2019-10-30 15:09:14 -07:00
Robert Widmann
efe877e6ee Remove unnecesary interface type resets
Now that setInvalid() is a semantic property, drop the explicit calls to
reset the interface type.  It is already ErrorType.
2019-10-30 15:09:14 -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
bcf03aa019 Make getDeclTypeCheckingSemantics a utility 2019-10-30 12:55:10 -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
48fdd58a42 Merge branch 'master' of https://github.com/apple/swift into SR-11295-warning-unecessary-casts 2019-10-24 00:58:03 -03:00
Luciano Almeida
3dc82a6271 Handling ExplicityCoercion in simplifyLocator 2019-10-24 00:27:53 -03:00
Hamish Knight
c95ef110d5 [CS] Make resolveLocatorToDecl simpler and more robust (#27836)
[CS] Make resolveLocatorToDecl simpler and more robust
2019-10-23 15:11:23 -07:00
Pavel Yaskevich
5a12e956f1 [ConstraintSystem] Add a new "condition" locator path element
"Condition" path element is used to represent a condition expression
associated with `if` expression or ternary operator `? :`.

Locator has been changed in the way that it's now anchored from `if`
itself which simplifies down to condition expression it needed.
2019-10-22 15:00:37 -07:00
Hamish Knight
e4e5b5e94a Allow getCalleeLocator to not look through applies
Some clients may only want a callee locator for an
immediate decl reference such as `x.foo`, but not
for `x.foo()`.
2019-10-22 11:54:04 -07:00
Robert Widmann
84a07b99ae [NFC] VarDecls in Pattern Binding Initializers Have No Overload Type
Extend #27668 by declining to validate the type of variables
bound by a pattern binding initializer when computing an effective
overload type while rooted at that initializer.
2019-10-16 10:24:37 -07:00
Robert Widmann
0082ba5abc Remove VarDecl::markInvalid
Inline the interface type reset into its callers and make sure they're
also setting the invalid bit - which this was not doing before.
Unfortunately, this is not enough to be able to simplify any part of var
decl validation.
2019-10-14 12:46:39 -07:00
Pavel Yaskevich
773ac24bc9 [ConstraintSystem] Detect and diagnose type mismatch failures of inout parameters
Currently absence of `subtyping` is the only problem detected and diagnosed specifically
for `inout` parameters, but there could be type mismatches in `inout` positions as well
 and we can use `argument-to-parameter mismatch fix to detect and diagnose them.
2019-10-10 17:06:13 -07:00
Hamish Knight
ec45b24b63 Use hasAppliedSelf in getFunctionArgApplyInfo
`callee->hasCurriedSelf()` isn't the correct check
here when we have an argument mismatch for the
self parameter in a curried application.
2019-10-03 15:26:31 -07:00
Robert Widmann
75670c1727 Merge pull request #27436 from CodaFi/signed-sealed-delivered
[NFC] Adopt TypeBase-isms for GenericSignature
2019-09-30 15:50:42 -07:00
Robert Widmann
5a8d0744c3 [NFC] Adopt TypeBase-isms for GenericSignature
Structurally prevent a number of common anti-patterns involving generic
signatures by separating the interface into GenericSignature and the
implementation into GenericSignatureBase.  In particular, this allows
the comparison operators to be deleted which forces callers to
canonicalize the signature or ask to compare pointers explicitly.
2019-09-30 14:04:36 -07:00
Hamish Knight
b6b492d76a [CS] Rename LocatorPathElt::Requirement
Rename to LocatorPathElt::ProtocolRequirement in
order to help avoid confusion with
LocatorPathElt::AnyRequirement.
2019-09-29 14:19:57 -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
Slava Pestov
b1ffa19c7b AST: Refine recursive property checks on type alias types 2019-09-24 17:39:53 -04:00
Robert Widmann
f053f9c480 Port getInterfaceType() patterns in libSema 2019-09-23 16:49:29 -07:00
Pavel Yaskevich
ee8c78eef5 [Diagnostics] Tailored diagnostic when single tuple used instead of N distinct arguments
Diagnose cases when instead of multiple distinct arguments
call got a single tuple argument with expected arity/types:

```swift
func foo(_: Int, _: Int) {}
foo((0, 1)) // expected 2 arguments, got 1 tuple with 2 elements
```
2019-09-23 13:00:37 -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
Robert Widmann
321d9b76e7 Remove a dead cycle check 2019-09-20 20:38:38 -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
Robert Widmann
e0a41b19cb Break some cycles
Computing the generic signature changes the way that cycles appear in the compiler.  For now, break these cycles.  We should investigate each place where hasComputedGenericSignature() is used in service of breaking cycles.  See rdar://55263708
2019-09-16 12:50:24 -07:00
Hamish Knight
176969ddde [CS] Allow simplification of key path subscript arg locators
This allows a few fixes to properly emit
diagnostics for key path subscript argument
contextual failures.

Resolves SR-11476.
2019-09-15 21:39:32 +01:00
Hamish Knight
26dab57edd [CS] NFC: Inline recomputeSummaryFlags 2019-09-15 21:39:32 +01:00