Commit Graph

2892 Commits

Author SHA1 Message Date
Slava Pestov 3adb1dd1d0 Sema: Remove OpenParameterPackElements 2022-10-27 17:00:22 -04:00
Slava Pestov 46e782200a Sema: More complex PackExpansionType matching 2022-10-27 13:46:58 -04:00
Slava Pestov 12d21e42aa Sema: Handle PackExpansionType inside PackType when splitting up ConformsTo/SubclassOf constraints 2022-10-27 13:46:58 -04:00
Slava Pestov 9e5371d11a Sema: Fix long line 2022-10-27 13:46:58 -04:00
Doug Gregor ed935297fa Merge pull request #61321 from DougGregor/open-existential-for-optional-param 2022-10-26 20:54:22 -07:00
Holly Borla e2a41d126a Merge pull request #61737 from hborla/generic-environment-helpers
[GenericEnvironment] Add helper methods for mapping pack types to opened element types and vice versa.
2022-10-26 16:16:12 -07:00
Holly Borla d09ea98ba6 [GenericEnvironment] Add helper methods to map pack interface types to
element archetypes, and element interface types to pack archetypes.
2022-10-26 00:04:56 -07:00
Holly Borla 1ab9f8f7c6 [AST] Add helper methods to GenericTypeParamType for converting a given type
parameter to and from a pack type parameter.
2022-10-26 00:04:56 -07:00
Slava Pestov bb045423b3 Sema: Add diagnostics for ShapeOf constraint 2022-10-25 13:20:38 -04:00
Slava Pestov 731d903a43 Sema: Add ConstraintKind::ShapeOf 2022-10-25 12:55:04 -04:00
Holly Borla 25eb9efc60 Merge pull request #61678 from hborla/pack-expansion-expression-checking
[Sema] Implement basic type checking for pack expansion expressions.
2022-10-25 08:07:59 -07:00
Holly Borla 032c511754 [ConstraintSystem] Add a PackElementOf constraint to delay mapping opened
element pattern types to pattern archetypes until after type variables are
resolved.
2022-10-24 19:46:44 -07:00
Pavel Yaskevich 927b846a8f Merge pull request #61672 from xedin/rdar-101412179
[CSSimplify] Diagnose contextual mismatch between fully resolved depe…
2022-10-24 19:36:51 -07:00
Holly Borla 5584752b3e [ConstraintSystem] Implement value parameter pack forwarding. 2022-10-22 13:41:48 -07:00
Slava Pestov c34f8d3a0b Sema: Check AnyObject requirements of variadic generic functions 2022-10-22 01:17:13 -04:00
Slava Pestov f3fcc44d17 Sema: Handle PackElement locator in repairFailures() 2022-10-21 22:17:38 -04:00
Slava Pestov cbce4a52ca Sema: Support PackExpansionTypes in matchPackTypes() 2022-10-21 22:17:38 -04:00
Slava Pestov 7d0de80bfc Sema: Check requirements when calling a variadic generic function 2022-10-21 22:17:38 -04:00
Slava Pestov 46d5fa68f9 Sema: Introduce ConstraintKind::SubclassOf 2022-10-21 22:17:38 -04:00
Slava Pestov c41341d98c Sema: Fix matchCallArguments() to allow empty pack type bindings
Thanks to @hborla for suggesting this fix.
2022-10-21 22:17:08 -04:00
Slava Pestov 68514b10b5 AST: Introduce ElementArchetypeType 2022-10-21 21:55:35 -04:00
Pavel Yaskevich a796c45e4c [CSSimplify] Diagnose contextual mismatch between fully resolved dependent member types
If a constraint has fully resolved but incorrect (not simplifiable)
dependent member types, let's diagnose that as a contextual mismatch
instead of failing (which sometimes leads to a fallback diagnostic).

Resolves: rdar://101412179
2022-10-21 22:28:31 +01:00
Slava Pestov 4e70f4fb19 Sema: Simplify matching logic for PackExpansionType 2022-10-17 23:23:09 -04:00
Slava Pestov 7e9995b1bc Sema: Use ParamPackMatcher in matchFunctionTypes() 2022-10-16 21:37:25 -04:00
Slava Pestov 9d16b821a8 AST: Move Sema's TuplePackMatcher to AST
I'm also going to use it in TypeMatcher, for the Requirement Machine's
same-type requirement desugaring.
2022-10-16 21:37:25 -04:00
Slava Pestov bbaee236c2 Sema: Preliminary support for matching tuple types containing pack expansion types 2022-10-16 21:37:24 -04:00
Holly Borla c4b946195e [AST] Replace the "type sequence" terminology with "parameter pack". 2022-10-10 16:28:13 -07:00
Holly Borla 9bb837a241 [AST] Rename SequenceArchetype to PackArchetype. 2022-10-10 16:25:26 -07:00
Holly Borla 67fb143f0e [AST] Remove ReifyPackExpr. 2022-10-10 16:25:26 -07:00
Dylan Perry a29686f349 Issue-60730: Addressing the situation where we were saying that (any … (#61191)
* Issue-60730: Addressing the situation where we were saying that (any P)? does not conform to P, instead we should offer the Force Optional error messaging

* Issue-60730: Removing assigned of AllowArgumentMismatch fix that would get thrown away if we fall into ForceOptional fix

* Issue-60730: Removing file that was accidentally changed

* Issue-60730: Updating to use simplifyConformsToConstraint - and to clean up code per comments

* Issue-60730: Updating to pass protocoDecl instead of type2 to simplifyConformsToConstraint

* Issue-60730: Updating to pass protocoDecl instead of type2 to simplifyConformsToConstraint

* Issue-60730: Updating to not pass 1 to recordFix, where that is the default value

* Issue-60730: Adding in test to validate that the fix works as expected

* Issue-60730: Cleaning up test based on PR Comments

* Issue-60730: Correcting typo in test

* Issue-60730: Adding additional test cases for layers of optionals and for non-conforming argument

* Issue-60730: Updating test to include fixme(diagnostics) for multilpe layers of force unwrap
2022-10-10 08:56:19 -03:00
Holly Borla 38a2c8218b [Requirement] Rename RequirementKind::SameCount to SameShape. 2022-10-06 20:48:40 -07:00
Anthony Latsis 2843e0c871 Gardening: Migrate compiler sources to GitHub issues 2022-09-29 23:58:55 +03:00
Doug Gregor 761b0aa98c Allow existential opening for parameters of optional type. 2022-09-27 13:08:36 -07:00
Pavel Yaskevich 1a47a95617 [CSSimplify] ValueWitness: open existential base before checking conformance 2022-09-14 15:47:12 -07:00
Pavel Yaskevich c610e2bd9c [CSSimplify] Member ref decays into value witness for next in for-in
Reference to `$geneator.next` in for-in loop context needs to be
treated as a reference to a witness of `IteratorProtocol#next`
requirement, otherwise it could lead to problems with retroactive
conformances.
2022-09-14 11:35:27 -07:00
Pavel Yaskevich c798a7fb72 [CSSimplify] Member ref decays into value witness for makeIterator in for-in
Reference to `makeIterator` in for-in loop context needs to be
treated as a reference to a witness of `Sequence#makeIterator`
requirement, otherwise it could lead to problems with retroactive
conformances.
2022-09-14 11:35:27 -07:00
Pavel Yaskevich e39a81f351 [CSSimplify] Adjust value witness constraint to record witness declaration 2022-09-14 11:35:27 -07:00
Pavel Yaskevich 164fa9c45d Revert "[ConstraintSystem] NFC: Remove obsolete ValueWitness constraint"
This reverts commit ef0523fe29.
2022-09-14 11:35:27 -07:00
Slava Pestov 67d3ede5c7 Sema: Teach the solver to find members of tuples 2022-09-10 00:26:42 -04:00
Slava Pestov c1b8690401 AST: Introduce special Builtin.TheTupleType singleton 2022-09-10 00:26:42 -04:00
Slava Pestov 79ed990728 AST: Replace TupleTypeRepr's ellipsis with PackExpansionTypeRepr 2022-09-07 12:35:54 -04:00
Pavel Yaskevich b2233ee4c6 Merge pull request #60883 from xedin/rdar-99352676
[ConstraintSystem] Teach `init` ref validation about implicit conversions
2022-08-31 17:57:42 -07:00
Pavel Yaskevich 4571c26f10 [ConstraintSystem] Teach init ref validation about implicit conversions
Implicit conversion used to erase path for contextual type conversions
but it does so no longer, this means that invalid initializer reference
check needs to know about existence of implicit conversions that are
not reflected in the AST until solution is applied.

Resolves: rdar://99352676
2022-08-31 12:21:16 -07:00
Pavel Yaskevich e5d26627db [CSSimplify] Replace locatorEndsWith with isLastElement accessor 2022-08-31 12:12:16 -07:00
Pavel Yaskevich 9399451edf [ConstraintSystem] Fix result builder discovery in leading-dot syntax calls
Leading-dot syntax allows implicitly unwrapping result type to form
a base type of the call, `getOpenedResultBuilderTypeFor` needs to
account for that.

Resolves: https://github.com/apple/swift/issues/60586
2022-08-31 11:00:54 -07:00
Slava Pestov 5c32f2136e AST: Introduce RequirementKind::SameCount 2022-08-23 11:12:00 -04:00
Slava Pestov 7a16b0275b AST: Allow one-element tuple types to be constructed
These will never appear in the source language, but can arise
after substitution when the original type is a tuple type with
a pack expansion type.

Two examples:
- original type: (Int, T...), substitution T := {}
- original type: (T...), substitution T := {Int}

We need to model these correctly to maintain invariants.

Callers that previously used to rely on TupleType::get()
returning a ParenType now explicitly check for the one-element
case instead.
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 4d039686fd [CSSimplify] Failure to bind type variable to invalid dependent member makes it a hole
If the failure is not reflected in constraint system it would let
the solver to form a _valid_ solution as if the constraint between
the type variable and the unresolved dependent member type never
existed.

Resolves: https://github.com/apple/swift/issues/60649
2022-08-19 11:39:40 -07: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