Commit Graph

155 Commits

Author SHA1 Message Date
Hamish Knight
76da268b4b [CS] Debug: Print ASTNode for contextual type
If we don't have an associated TypeRepr for a
contextual type in the constraint system, dump the
ASTNode that it's for instead.

Before:

```
Contextual Type: $T2
```

After:

```
Contextual Type: $T2 at DeclRef@/Users/hamish/src/swift-test-arena/swift-test-arena/main.swift:1493:21
```
2023-01-26 17:21:49 +00:00
Luciano Almeida
e513d23c0b [Sema] Improving global actor function mismatch diagnostic 2023-01-13 20:47:23 -03:00
Holly Borla
6e28f996ce [ConstraintSystem] Create opened pack element generic environments lazily
in the constraint system.
2023-01-07 09:50:14 -08:00
Doug Gregor
806b5a8777 [Macros] Diagnose errors where a macro is used without the '#'. 2023-01-02 21:22:04 -08:00
Holly Borla
dc941de45e [ConstraintLocator] Add a locator path element that stores an opened pack element
generic signature.
2022-12-14 20:45:51 -08:00
Holly Borla
16b9654d4b [ConstraintSystem] Use specific locators when matching pack types. 2022-11-16 09:24:21 -08:00
Holly Borla
72d87b5ca5 [ConstraintSystem] Add a locator path element for the pattern of a pack expansion. 2022-11-16 09:06:58 -08:00
Holly Borla
5218a0d77a [ConstraintSystem] Add a locator path element for pack shapes, and use it for
type variables representing pack shapes.
2022-11-15 21:33:17 -08:00
Holly Borla
38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Slava Pestov
5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04: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
Pavel Yaskevich
dee6a31ac9 [ConstraintLocator] Generalize pattern decl locator to support "named" and "any" 2022-08-03 15:50:33 -07:00
Alex Hoppen
a7e0358038 [Sema] Print pattern name for ConstraintLocators 2022-07-20 09:46:14 +02:00
Alex Hoppen
eba95bacbd [CS] Delay type resolution of variables for variables in named pattern 2022-07-20 09:46:14 +02:00
Alex Hoppen
6416640794 [Sema] Support dumping of ConstraintLocatorBuilder 2022-07-11 11:45:06 +02:00
Pavel Yaskevich
6a65810d30 [Constraint] NFC: Rename ClosureBodyElement to SyntacticElement
`SyntacticElement` represents a statement, pattern, declaration,
condition, or expression and could originate from i.e. a closure,
a function or a result builder body.
2022-04-26 09:55:04 -07:00
Pavel Yaskevich
9d5ee7a081 [ConstraintLocator] Add a new element - pattern binding element
The new element points to an index of a particular pattern in a
pattern binding declaration.
2022-03-07 10:51:40 -08:00
Robert Widmann
b3f70c960e Implement Pack Locators 2021-12-16 01:16:45 -08:00
Hamish Knight
f26f136569 [CS] Tweak dynamic member constraint generation
In order to fit with the new IUO model where
functions with IUO results have the disjunction
formed when matching result types, we need to
update this logic to form applicable fn
constraints for the implicit `x[dynamicMember:]`
subscript call.

This is done using a new ImplicitDynamicMemberSubscript
locator path element to allow easy identification of
what the right callee and argument list should be.
2021-10-12 14:14:32 +01:00
Hamish Knight
a1abcee108 [CS] Introduce ConstructorMemberType locator elt
Use this new element to represent the overload type
for a constructor call, and have it store a bit
indicating whether the call is for a short-form
`X(...)` or self-delegating `self.init(...)` call.
2021-10-12 09:51:44 +01:00
Pavel Yaskevich
84ca85dc01 [ConstraintLocator] Add a new element to track closure body elements 2021-10-08 10:08:01 -07:00
willtunnels
319b3e64aa Add support for opaque result types in structural positions (#38392)
* [TypeResolver][TypeChecker] Add support for structural opaque result types

* [TypeResolver][TypeChecker] Clean up changes that add structural opaque result types
2021-08-03 23:45:02 -04:00
Holly Borla
939a861fe1 [ConstraintSystem] Add a constraint locator path element for tuple types,
which will provide context for tuple element mismatch diagnostics.
2021-06-23 19:18:11 -07:00
Pavel Yaskevich
b7a7024e0a [ConstraintLocator] Add information about expected value type to key path locator
Record a "value" type associated with this location to be able to
reference during inference.
2021-05-28 17:51:58 -07:00
Strieker
4e2b67cbae [NFC] Resolved merge conflict in CSSimplify.cpp after making changes to improve error handling for composed wrapped value mismatches 2021-04-22 11:49:21 -07:00
Strieker
3891dc7fdc [ConstraintSystem] Added necessary logic so that a constraint locator can recognize a composed property wrapper’s wrapped value type. 2021-04-22 11:31:41 -07:00
Pavel Yaskevich
f00c578761 Merge pull request #34401 from xedin/implicit-cgfloat-conversion
[DNM][TypeChecker] Implement Double <-> CGFloat implicit conversion
2021-03-31 10:20:28 -07:00
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00
Doug Gregor
d6fc1fd60f Implement conversions for global-actor-qualified functions.
One can convert from a function value without a global actor to a
similar function type that does have a global actor, but one cannot
remove or change a global actor on a function type.
2021-03-17 00:51:26 -07:00
Pavel Yaskevich
389fd29e6c [ConstraintSystem] Add a path element to represent an implicit conversion 2021-03-17 00:18:06 -07:00
Pavel Yaskevich
fb89d11931 [ConstraintLocator] NFC: Adjust name of isForKeyPathComponent to clarify its meaning
New name is `isInKeyPathComponent` since it's implemeneted as a
check for presence of `KeyPathComponent` element in the locator
that covers every sub-element contained in a key path component
as well.
2021-03-12 09:58:54 -08:00
Pavel Yaskevich
a8ad32d55b [ConstraintLocator] Add a new locator accessor to check whether it belongs to key path component result 2021-03-12 09:27:18 -08:00
Frederick Kellison-Linn
e4ea1678dc Rename HoleType to PlaceholderType
HoleType basically served the same purpose as PlaceholderType. This commit unifies the two.
2021-02-16 22:59:19 -05:00
Doug Gregor
ba8819eb58 [Concurrent] Introduce concurrent function types.
Introduce `@concurrent` attribute on function types, including:
* Parsing as a type attribute
* (De-/re-/)mangling for concurrent function types
* Implicit conversion from @concurrent to non-@concurrent
- (De-)serialization for concurrent function types
- AST printing and dumping support
2021-01-27 14:22:32 -08:00
Pavel Yaskevich
114364873d [ConstraintSystem] Adjust ConformanceRequirement locator to carry ProtocolConformance 2021-01-08 11:34:26 -08:00
Pavel Yaskevich
dbfeb5eea1 [ConstraintLocator] Add a new locator path element - ConformanceRequirement
Records protocol requirement associated with a particular type in
the constraint system, also useful to track parent conformance
for conditional requirements.
2021-01-06 10:13:55 -08:00
Pavel Yaskevich
1683fb91b6 [ConstraintSystem] Remove RValueAdjustment locator element
It was used for unresolved member and `.dynamicType` references
as well as a couple of other places, but now unresolved member
references no longer need that due to new implicit "chain result"
AST node and other places could use more precise locators
e.g. new `.dynamicType` locator or `sequence element` for `for in`
loops.
2020-10-26 00:40:45 -07:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
Pavel Yaskevich
461eafff54 [ConstraintSystem] NFC: Move ConstraintSystem.h to include/swift/Sema 2020-10-08 10:45:47 -07:00
Pavel Yaskevich
f2614dec4a [ConstraintSystem] NFC: Move ConstraintLocator.h to include/swift/Sema 2020-10-08 10:42:39 -07:00
Pavel Yaskevich
e254f1c3e2 [ConstraintSystem] Infer whether locator is related to return of a single-expression function
This information could be inferred from state recorded in a
constraint system, so to need to record that in the
constraint locator as well.
2020-10-01 11:49:30 -07:00
Frederick Kellison-Linn
1069fe280f Fixup diagnostics 2020-08-26 22:42:29 -04:00
Holly Borla
2cfb5fa326 [ConstraintLocator] Simplify ConstraintLocator::Profile.
Since each kind of path element stores only one type of data, the path
element kind and the raw storage value are sufficient for uniquing the
element.
2020-08-13 14:56:17 -07:00
Holly Borla
b1c513de34 [ConstraintLocator] Add a isFirstElement helper function 2020-07-28 15:02:47 -07:00
Holly Borla
9baca13088 [Function Builders] Teach diagnostics about function builder body
result types in order to properly diagnose requirement failures that
aren't anchored at an expression.
2020-07-27 18:28:27 -07:00
Pavel Yaskevich
3e9e253acb [ConstraintSystem] Add a new locator element - argument attribute
`ArgumentAttribute` points to a particular attribute associated
with one of the arguments e.g. `inout` or its type e.g. `@escaping`.

This is very useful when dealing with argument-to-parameter
failures because it allows to express in the locator kind
of a problem.
2020-05-18 13:08:19 -07:00
Pavel Yaskevich
740a2dd4ad [ConstraintSystem] NFC: Inline ConstraintLocator::directlyAt implementation into the header 2020-04-29 17:03:45 -07:00
Pavel Yaskevich
955f0f3dbb [ConstraintSystem] Switch ConstraintLocator to use ASTNode as an anchor type 2020-04-29 17:03:45 -07:00
Pavel Yaskevich
7bdf0164d4 [ConstraintSystem] Replace remaining uses of TypedNode::dyn_cast with getAsExpr 2020-04-23 01:13:13 -07:00