Commit Graph

1659 Commits

Author SHA1 Message Date
Robert Widmann
32e68468f4 Remove TypeChecker from parameter default checking 2019-11-10 13:34:43 -08:00
Robert Widmann
7bad9aacc3 Drop the TypeChecker out of ConstraintSystem 2019-11-10 13:26:47 -08:00
Robert Widmann
63896c1fc5 Make more high-level type checking endpoints utility 2019-11-10 13:03:46 -08:00
Robert Widmann
d21424b58b Make typeCheckExpression a utility 2019-11-10 12:40:09 -08:00
Robert Widmann
4bf902549f Merge pull request #28152 from hamishknight/decontextualize
Make TypeChecker's Context and Diags fields private
2019-11-09 15:00:47 -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
643ef80486 Remove external uses of TypeChecker's Context field 2019-11-08 10:59:20 -08:00
Robert Widmann
41ab235797 [CS] Remove some TypeChecker uses 2019-11-07 12:41:37 -08:00
Hamish Knight
fb55c032f8 diagnoseUnownedImmediateDeallocation doesn't need a TypeChecker 2019-11-07 12:41:37 -08:00
Hamish Knight
cb0c9adc46 Use getXXXType over getXXXDecl in a bunch of places 2019-11-07 08:26:08 -08:00
Robert Widmann
e6dbfa393a Move Utilities back to TypeChecker 2019-11-06 15:20:46 -08:00
Robert Widmann
e5599ef25d Make coerceParameterListToType a utility 2019-11-06 15:08:59 -08:00
Robert Widmann
36987e0491 Drop references to the type checker in CSApply 2019-11-06 15:08:59 -08:00
Robert Widmann
59db7832b0 Make coerceToRValue a utility 2019-11-06 15:08:59 -08:00
Doug Gregor
1cd5152f86 Move ConstraintSystem::setExprTypes() over to Solution
It belongs on Solutionn, which should contain all of the information
needed to perform the operation. Simplify the implementation slightly
while doing this, eliminating some dead code.
2019-11-06 08:50:53 -08:00
Doug Gregor
39af1d0c55 [Constraint solver] Drop Expr* from finalization.
We don't need to pass an expression into rewriter finalization; the update
of expression types can be handled per-expression.
2019-11-06 08:39:47 -08:00
Robert Widmann
6c6035eca2 Drop TypeCheckers out of TypeCheckStmt 2019-11-05 22:52:28 -08:00
Robert Widmann
e804d6ed9a Make TypeChecker::getDefaultType a utility 2019-11-05 20:31:15 -08:00
Robert Widmann
392df03466 [NFC] Drop unnecessary TypeCheckers from Sema 2019-11-05 20:30:40 -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
Robert Widmann
8a69f886ad Merge pull request #27955 from AnthonyLatsis/bracestmt_cleanup
NFC: Solidify and tidy up the BraceStmt interface
2019-10-31 13:48:40 -07:00
Robert Widmann
4996858c4d Re-implement isInvalid for ValueDecls 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
Hamish Knight
4fa8fb6c08 substituteInputSugarTypeForResult can be static 2019-10-30 07:56:32 -07:00
Anthony Latsis
6325915b4b NFC: Solidify and tidy up the BraceStmt interface 2019-10-30 16:43:59 +03:00
Robert Widmann
e7006a92b1 Clean up some trivially true condition clauses
ProtocolConformanceRef::isConcrete checks the invalid bit for us.
2019-10-29 16:56:22 -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
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
Hamish Knight
19fe19e972 Address review feedback 2019-10-23 13:22:03 -07:00
Slava Pestov
362488b867 Sema: Fix substitutions of generic caller-side default arguments
Using mapTypeIntoContext() is incorrect here, because we might not
be calling the default argument from the callee's context. Instead,
use the substitutions from the ConcreteDeclRef.

Fixes <rdar://problem/55739617>.
2019-10-22 16:38:45 -04:00
Hamish Knight
a5e375a770 Cache resolved concrete decl refs in ExprRewriter
This ensures we don't have to compute the substitutions
multiple times when, for example, rewriting an
apply of generic function.
2019-10-22 12:36:59 -07:00
Hamish Knight
9d80a82939 Make resolveLocatorToDecl simpler and more robust
Rather than attempting to pull out a concrete decl
ref from the rewritten function expr, retrieve the
callee from the solution using a callee locator
computed before the apply is rewritten, and then
pass this callee down through `finishApply` and
`coerceCallArguments`.

Resolves SR-11648.
2019-10-22 11:54:04 -07:00
Hamish Knight
e3df69a2b5 Add Solution::resolveConcreteDeclRef
This is a convenience member for computing the
contextual substitutions for a decl reference at
a given locator.
2019-10-22 11:54:03 -07:00
Hamish Knight
37c42f6203 [Sema] NFC: Remove an unnecessary parameter 2019-10-21 13:44:15 -07:00
Brent Royal-Gordon
ecf76c8fdf Merge pull request #27586 from brentdax/everything-evil
Fix keypath-as-function crasher
2019-10-15 17:54:13 -07:00
Brent Royal-Gordon
ca25640cc3 Merge branch 'master' into everything-evil 2019-10-14 13:24:03 -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
swift-ci
7d437ec4a8 Merge pull request #27629 from DougGregor/builder-refactoring-prelude 2019-10-11 15:35:11 -07:00
Doug Gregor
87b5df7333 [Constraint system] Abstract the record of an applied function builder.
std::pair and std::tuple are a bad, bad drug. NFC, but helps with
future refactoring.
2019-10-11 10:31:27 -07:00
Jordan Rose
171ff440fc Remove swift::reversed in favor of llvm::reverse (#27610)
The former predates the latter, but we don't need it anymore! The
latter has more features anyway.

No functionality change.
2019-10-10 17:16:09 -07:00
Slava Pestov
d8b61ff24b Sema: Peel off typeCheckParameterList()'s specifier computation into a request
Since getSpecifier() now kicks off a request instead of always
returning what was previously set, we can't pass a ParamSpecifier
to the ParamDecl constructor anymore. Instead, callers either
call setSpecifier() if the ParamDecl is synthesized, or they
rely on the request, which can compute the specifier in three
specific cases:

- Ordinary parsed parameters get their specifier from the TypeRepr.

- The 'self' parameter's specifier is based on the self access kind.

- Accessor parameters are either the 'newValue' parameter of a
  setter, or a cloned subscript parameter.

For closure parameters with inferred types, we still end up
calling setSpecifier() twice, once to set the initial defalut
value and a second time when applying the solution in the
case that we inferred an 'inout' specifier. In practice this
should not be a big problem because expression type checking
walks the AST in a pre-determined order anyway.
2019-10-10 15:00:07 -04:00
Brent Royal-Gordon
eca51d4d53 Fix keypath-as-function crasher
The autoclosures generated for the keypath-as-function feature were not added to the list of closures that needed captures computed. In top-level code, this caused a crash. Fixes rdar://problem/56055600.
2019-10-08 18:11:41 -07:00
Jordan Rose
5f2695808d Merge pull request #26830 from owenv/diag_child_notes_refactor
[Diagnostics][NFC] Optionally add notes as explicit children of an error/warning
2019-10-02 14:34:33 -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
Suyash Srijan
ad4d623818 Merge pull request #27382 from theblixguy/fix/SR-11522
[CSApply] Don't diagnose a 'static let none' as ambiguous none unless its an enum type
2019-09-28 11:14:52 +01:00
Suyash Srijan
2de4755564 [CSApply] Filtering 'none' results should filter out any other decl (such as typealiases, structs, etc) by default 2019-09-27 23:09:50 +01:00