Commit Graph

1263 Commits

Author SHA1 Message Date
Timofey Solonin
3f366947e4 Improve indentation in debugging output 2022-11-17 23:25:31 +08:00
Allan Shortlidge
429f19a4b6 Revert "[ConstraintSystem] Extend availability check to cover unavailable extensions."
This reverts commit 6de6de2e3a.
2022-11-01 17:00:33 -07:00
Robert Widmann
0fc80dc498 Refactor Macro Context Lookup Into a Request 2022-10-27 11:11:12 -07:00
Robert Widmann
394d0645d9 Tidy Up The C AST Bridging File A Bit 2022-10-27 11:11:12 -07:00
Robert Widmann
822fd47b8a Add Utilities to Retrieve the (Opened) Type of a Macro Reference 2022-10-27 11:11:11 -07:00
Doug Gregor
4932c021f4 Avoid concurrency-related adjustments during witness matching
We were only applying this logic for some declaration types, not all,
which is silly. Fixes https://github.com/apple/swift/issues/61602 /
rdar://101243966.
2022-10-26 21:43:25 -07:00
Slava Pestov
731d903a43 Sema: Add ConstraintKind::ShapeOf 2022-10-25 12:55:04 -04:00
Slava Pestov
f3fcc44d17 Sema: Handle PackElement locator in repairFailures() 2022-10-21 22:17:38 -04:00
Slava Pestov
afbf844b83 Sema: Implement support for projecting member types from PackType in simplifyType() 2022-10-21 22:17:38 -04:00
Slava Pestov
55210f6cae Sema: Introduce TVO_CanBindToPack type variable flag 2022-10-16 21:37:25 -04:00
Holly Borla
67fb143f0e [AST] Remove ReifyPackExpr. 2022-10-10 16:25:26 -07:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Hamish Knight
bca941b152 [AST] NFC: Rename IfExpr -> TernaryExpr
This matches what we call it in SwiftSyntax, and
is just generally clearer.
2022-09-28 10:33:31 +01:00
Allan Shortlidge
6de6de2e3a [ConstraintSystem] Extend availability check to cover unavailable extensions.
Instead of checking for unavailability attributes directly in the solver, use `AvailableAttr::isUnavailable` which checks the enclosing extension too, if necessary.

Resolves rdar://92364955
2022-09-21 18:26:57 -07:00
Luciano Almeida
be25419bc3 [Sema] Accept IgnoreCollectionElementContextualMismatch in conflict generic diagnostics 2022-09-20 21:24:16 -03:00
Hamish Knight
4716f61fba [AST] Introduce explicit actions for ASTWalker
Replace the use of bool and pointer returns for
`walkToXXXPre`/`walkToXXXPost`, and instead use
explicit actions such as `Action::Continue(E)`,
`Action::SkipChildren(E)`, and `Action::Stop()`.
There are also conditional variants, e.g
`Action::SkipChildrenIf`, `Action::VisitChildrenIf`,
and `Action::StopIf`.

There is still more work that can be done here, in
particular:

- SourceEntityWalker still needs to be migrated.
- Some uses of `return false` in pre-visitation
methods can likely now be replaced by
`Action::Stop`.
- We still use bool and pointer returns internally
within the ASTWalker traversal, which could likely
be improved.

But I'm leaving those as future work for now as
this patch is already large enough.
2022-09-13 10:35:29 +01:00
Slava Pestov
67d3ede5c7 Sema: Teach the solver to find members of tuples 2022-09-10 00:26:42 -04:00
Pavel Yaskevich
7f08d408ef Merge pull request #60443 from amritpan/improve-solver-step-printing
[ConstraintSystem] Improve solver step printing in the type inference algorithm debug output
2022-09-02 15:53:23 -07:00
Amritpan Kaur
b44c948bcc [ConstraintSystem] Print new type var assigned to generic in overload.
If overload choice has generic param, print type var assigned to generic param.
2022-09-01 20:25:13 -07:00
swift-ci
a66951aa3d Merge pull request #60521 from kavon/preconcurrency-var-access
Add missing function conversion for member access to preconcurrency vardecl.
2022-08-30 00:58:49 -07:00
Pavel Yaskevich
506ccccf74 Merge pull request #60837 from xedin/rdar-99282932
[ConstraintSystem] Teach partial application check about implicit con…
2022-08-30 00:22:27 -07:00
Kavon Farvardin
e70fbbc738 [ConstraintSystem] correct the @preconcurrency adjustment of var references
We intended to introduce AST conversions that strip concurrency
attributes off of types associated with `@preconcurrency` decls.
But for VarDecl references, we stripped it too early, leading to
things like a MemberVarDecl that doesn't have `@Sendable` in its
result type, but the VarDecl it refers to does have it.

That caused crashes in SIL where types didn't match up. This patch
fixes things by delaying the stripping until the right point.

resolves rdar://98018067
2022-08-29 20:58:25 -07:00
Pavel Yaskevich
842aa60b5b [ConstraintSystem] Teach partial application check about implicit conversions
Implicit conversion used to erase path for contextual type conversions
but it does so no longer, this means that invalid partial application
check needs to know about existence of implicit conversions that are
not reflected in the AST until solution is applied.

Resolves: rdar://99282932
2022-08-29 16:56:16 -07:00
Luciano Almeida
109737551e [Sema] Handle non-function type parameters for closure arguments in ambiguity diagnositc 2022-08-27 20:42:19 -03:00
Pavel Yaskevich
932c6b40c5 [ConstraintSystem] Don't use special locator for value-to-value conversions related to contextual type
Previously locator for value-to-value conversion would just drop
all the contextual information if the conversion occurred while
converting expression to a contextual type. This is incorrect for
i.e. `return` statements and other targets because because they
are solved separately and using the same locator would result in
a clash when solutions are merged.
2022-08-25 14:33:03 -07:00
Slava Pestov
5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04:00
Slava Pestov
e8dc19a70b Sema: Stop calling getAllConformances() on protocols 2022-08-23 00:03:37 -04:00
Pavel Yaskevich
3fd9037ee9 [ConstraintSystem] Don't produce argument info object for extraneous arguments
An extraneous argument doesn't have a corresponding parameter so the
information object for such an argument is not safe to produce.

Resolves: https://github.com/apple/swift/issues/60436
Resolves: rdar://98304482
2022-08-16 16:22:02 -07:00
Slava Pestov
bf755cc3b7 Merge pull request #60505 from slavapestov/misc-variadic-crap
AST: Minor generics changes
2022-08-11 05:12:06 -04:00
Slava Pestov
87871d7347 AST: Rename getOpenedArchetypeSignature() to getOpenedExistentialSignature() 2022-08-10 23:44:36 -04:00
Amritpan Kaur
fd41a39294 [ConstraintSystem] Refactor solver state depth to its own function for easier indent editing in future. 2022-08-10 13:29:02 -07:00
Pavel Yaskevich
42135e27c4 Merge pull request #60387 from amritpan/improve-solution-printing
[ConstraintSystem] Improve solution printing in the type inference algorithm debug output
2022-08-10 09:03:29 -07:00
Slava Pestov
11eb11833f Sema: Fix deep equality matching for parameterized protocol types
Fixes rdar://problem/98356057.
2022-08-09 23:45:39 -04:00
Amritpan Kaur
2786f24b67 [TypeCheckConstraints.cpp] Remove printing of any empty constraint choice headings and fix minor spacing issues. 2022-08-09 14:09:39 -07:00
Slava Pestov
03f2225d96 Merge pull request #60463 from slavapestov/reduced-types
AST: Rename 'canonical wrt. generic signature' to 'reduced'
2022-08-09 16:12:58 -04:00
Slava Pestov
9d96ed940f AST: Rename 'canonical wrt. generic signature' to 'reduced'
We had two notions of canonical types, one is the structural property
where it doesn't contain sugared types, the other one where it does
not contain reducible type parameters with respect to a generic
signature.

Rename the second one to a 'reduced type'.
2022-08-09 12:46:31 -04:00
Pavel Yaskevich
b39302a585 Merge pull request #60203 from xedin/rdar-96997534
[CSGen] Allow `_` pattern to be a hole
2022-08-08 10:14:18 -07:00
Pavel Yaskevich
f9ab9ac775 [ConstraintSystem] NFC: Fix a warning by switching from dumpContext to printContext 2022-08-05 09:52:16 -07:00
Pavel Yaskevich
5ee5a22cf1 [TypeChecker] NFC: Add a dedicated method to get outermost attached wrapper
The outermost wrapper is the one at index `0` in the wrapper list
but it's easy for humans to make a reverse assumption since outermost
is the back of the list. Let's add a dedicated method to reduce error
probability of the property wrapper APIs.
2022-08-04 17:30:02 -07:00
Pavel Yaskevich
dee6a31ac9 [ConstraintLocator] Generalize pattern decl locator to support "named" and "any" 2022-08-03 15:50:33 -07:00
Pavel Yaskevich
3e65a7cab0 Merge pull request #60065 from xedin/result-builder-ast-transform-under-flag
[TypeChecker] Implement result builder transform via AST modification under a flag
2022-08-02 16:22:01 -07:00
Pavel Yaskevich
0044c8f596 [ConstraintSystem] Add support for functionRef to SolutionApplicationTargetsKey::dump 2022-08-02 11:59:03 -07:00
Pavel Yaskevich
a6421fc94e [CSClosure] Declarations prefixed with $ can act as inferrable placeholders
If the type for such declaration could be completely inferred it
would be used during solution application. This is used to infer
types for result builder components.
2022-08-02 11:41:40 -07:00
Hamish Knight
1bf954c61f [CS] Better diagnose inout argument in tuple construction
Previously we relied on `TupleTypeElt::getType`
returning an `InOutType` to fail the tuple type
matching logic. Instead, add logic to reject any
inout arguments up-front with a more specific
diagnostic.

Also, while we're here, strip the `_const`
parameter flag, as it's not something that needs
to be considered for tuple construction.
2022-08-02 13:56:30 +01:00
Pavel Yaskevich
0457a72fdf Merge pull request #60222 from xedin/rdar-97396399
[ConstraintSystem] Retrieve contextual type from a solution for ambiguities
2022-07-28 09:28:09 -07:00
Hamish Knight
5418e8d934 [AST] Remove ArgumentList::composeTupleOrParenType
Remove a redundant bit of diagnostic logic now
that we better diagnose cases where an uncallable
variable is in an overload set for a mismatched
apply. Tweak another bit of diagnostic logic to
only apply to a single arg/param case, as that
seems to be what it's meant for.
2022-07-26 12:51:54 +01:00
Hamish Knight
09744f83fd [CS] Remove dead logic
This code seems to be ancient and dates back to
when `boundType` may have been a function type.
Nowadays it should always be a type variable.
2022-07-25 22:03:56 +01:00
Hamish Knight
13fe88cc57 [AST] Rename isCallableNominalType -> isCallAsFunctionType
Make it explicit that we're checking for
`callAsFunction` instead of `dynamicallyCall`.
2022-07-25 22:03:55 +01:00
Pavel Yaskevich
c300edb6ee [ConstraintSystem] Pass decl to diagnostic instead of trying to validate loc
`DiagnosticEngine` does the checking for declaration, so all we
need to do for ambiguity diagnostic is to use an overload declaration.
2022-07-25 11:05:44 -07:00
Pavel Yaskevich
399d3490d4 [ConstraintSystem] Add a tailored ambiguity diagnostic for non-conforming result type 2022-07-25 10:45:45 -07:00