Commit Graph

1513 Commits

Author SHA1 Message Date
Brent Royal-Gordon
addbe3e5ed [NFC] Thread DeclNameRef through most of the compiler
This huge commit contains as many of the mechanical changes as possible.
2019-12-11 00:55:18 -08:00
Brent Royal-Gordon
63ec1cf5af Introduce a separate #filePath, remove -pound-file
This makes the path behavior more first-class. The feature is now hidden behind an experimental flag, -enable-experimental-concise-pound-file.
2019-12-04 16:35:13 -08:00
Pavel Yaskevich
5cacd1bb36 [ConstraintSystem] Fix situations when contextual base type can't be inferred
It might be either impossible to infer the base because there is
no contextual information e.g. `_ = .foo` or there is something
else wrong in the expression which disconnects member reference
from its context.
2019-12-03 12:07:16 -08:00
Hamish Knight
19e199e567 Use DefaultArgumentExpr for caller-side defaults (#28279)
Use DefaultArgumentExpr for caller-side defaults
2019-12-02 13:57:17 -08:00
Hamish Knight
7edbd9327e [CS] Remove an unused variable 2019-11-27 17:13:50 -08:00
Pavel Yaskevich
e3a4b4ffc9 [ConstraintSystem] Fix ConstraintGenerator to change phase to "constraint generation" and back 2019-11-21 00:08:58 -08:00
Hamish Knight
7e788b8ab9 [AST] Remove CallerDefaultArgumentExpr
Now that we use DefaultArgumentExpr for both kinds
of default arguments, this is no longer needed.
2019-11-20 15:07:33 -08:00
Slava Pestov
ef05accd31 Sema: Remove even more vestigial TypeChecker usages 2019-11-19 17:40:00 -05:00
Doug Gregor
2d915f60ab [Constraint solver] Remove expression from the constructor.
Rather than setting up the constraint solver with a single expression
(that gets recorded for parents/depths), record each expression that
goes through constraint generation.
2019-11-14 15:41:38 -08:00
Robert Widmann
f4d333d066 Sink a bunch of semantic options into TypeCheckerOptions
Sink
- DebugConstraintSolver
- DebugConstraintSolverAttempt
- DebugConstraintSolverOnLines
- DebugGenericSignatures
- DebugForbidTypecheckPrefix
- SolverMemoryThreshold
- SolverBindingThreshold
- SolverShrinkUnsolvedThreshold
- SolverDisableShrink
- EnableOperatorDesignatedTypes
- DisableConstraintSolverPerformanceHacks
- SolverEnableOperatorDesignatedTypes
2019-11-12 22:39:49 -08:00
Robert Widmann
8ff60abf6f Remove unused TypeCheckers 2019-11-12 11:33:13 -08:00
Robert Widmann
efb6117bd8 [NFC] Remove Diagnostic State From TypeChecker
Push this map into ConstraintSystem and have the search and retrieval chain up the linked list of base constraint systems.
2019-11-10 22:05:32 -08:00
Robert Widmann
ecb7b8c749 Make convertToType a utility 2019-11-10 13:39:34 -08:00
Robert Widmann
7bad9aacc3 Drop the TypeChecker out of ConstraintSystem 2019-11-10 13:26:47 -08:00
Robert Widmann
1123b1f897 Move constraint satisfiability utilities 2019-11-10 13:12:50 -08:00
Robert Widmann
63896c1fc5 Make more high-level type checking endpoints utility 2019-11-10 13:03:46 -08:00
Hamish Knight
18088b04f0 [AST] Consolidate Obj-C types on ASTContext
This commit moves the getNSObjectType and
getObjCSelectorType methods from TypeChecker
onto ASTContext. In addition, it moves the
FOR_KNOWN_FOUNDATION_TYPES macro into a separate
file to define each of the Obj-C type decls
we want to have access to.
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
8fc054ae5e Remove references to TypeChecker from CSGen 2019-11-06 15:08:59 -08:00
Robert Widmann
c4a0585ba5 Make getObjectLiteralConstructorName a utility 2019-11-06 15:08:59 -08:00
Robert Widmann
51b17470e3 Move the diagnosing entrypoints for intrinsics 2019-11-06 15:08:59 -08:00
Robert Widmann
d9b03a56a9 Merge pull request #28104 from CodaFi/broken-declspec
[NFC] Drop More Type Checkers
2019-11-06 07:31:49 -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
e15eb472e1 Inline TypeChecker::getExceptionType 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
332189e96f Remove TypeCheckers from Pattern resolution 2019-11-05 20:31:15 -08:00
Robert Widmann
c09d4173bb Remove some unused pointers 2019-11-05 20:30:11 -08:00
Robert Widmann
2b08d1b834 [NFC] ASTContext::getLazyResolver -> ASTContext::getLegacyGlobalTypeChecker 2019-11-05 14:44:41 -08:00
Pavel Yaskevich
bba785a7ac [ConstraintSystem] Detect and diagnose standalone nil literals early 2019-11-05 12:38:13 -08:00
Holly Borla
b1638ce1ab [CSGen] Add a tailored diagnostic for conditional casting from a nil literal,
and diagnose in CSGen.
2019-11-04 20:49:36 -08: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
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
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
c4fee1d0c9 [ConstraintSystem] Use new condition element in constraint generation/diagnostics 2019-10-22 15:01:49 -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
Slava Pestov
2e558f8c89 Merge pull request #27594 from slavapestov/circular-validation-cleanups-6
Circular validation cleanups, part 6
2019-10-12 00:59:21 -04:00
swift-ci
7d437ec4a8 Merge pull request #27629 from DougGregor/builder-refactoring-prelude 2019-10-11 15:35:11 -07:00
Robert Widmann
060cbb293f [NFC] Downgrade The TypeLoc in VarDecl to a TypeRepr
TypeCheckPattern used to splat the interface type into this, and
different parts of the compiler would check one or the other.   There is
now one source of truth: The interface type.  The type repr is now just
a signal that the user has written an explicit type annotation on
a parameter.  For variables, we will eventually be able to just grab
this information from the parent pattern.
2019-10-11 11:15:51 -07:00
Doug Gregor
eb61ae7971 [Type checker] Factor out ConstraintSystem::addJoinConstraint().
Use it for ternary expressions; it'll gain other clients soon.
2019-10-11 10:07:21 -07:00
Slava Pestov
f543d248d6 Sema: Always create a type checker instance 2019-10-10 19:54:48 -04:00
Slava Pestov
3dbdc09a4e Sema: Move ParamDecl interface type computation to validateDecl()
This eliminates typeCheckParameterList() altogether.
2019-10-10 15:28:14 -04:00
Slava Pestov
fac36f95b0 Sema: Always use interface types in typeCheckParameterList() 2019-10-08 01:37:09 -04: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
Robert Widmann
f053f9c480 Port getInterfaceType() patterns in libSema 2019-09-23 16:49:29 -07:00
Robert Widmann
30f4df3b00 Make validateType a utility method
Move around some code so that TypeChecker::validateType is now a utility
method of the type checker.  This cleans up at least one request that no
longer needs to grab the type checker from the AST context.
2019-09-13 15:16:14 -07:00
Doug Gregor
c109f9058f [Type checker] Minor crash avoidance tweaks. 2019-09-11 21:05:43 -07:00
Hamish Knight
a962f02024 [CS] Associate arg labels for key path subscripts
Change `associateArgumentLabels` to take a locator
argument to enable the recording of argument
labels for individual key path components. Then
move the association of argument labels for
subscripts to `addSubscriptConstraints`, and plumb
through the argument labels for key path subscript
components.

This then allows us to correctly ignore choices
with mismatching argument labels while solving in
certain cases.

Resolves SR-11438.
2019-09-10 12:06:34 +01:00