Commit Graph

1591 Commits

Author SHA1 Message Date
Slava Pestov
fcd6bc04fd Sema: Remove Solution::PackElementGenericEnvironments 2024-10-01 18:10:20 -04:00
Slava Pestov
0518b762d1 Sema: Record pack environments in the trail 2024-10-01 18:10:20 -04:00
Slava Pestov
f51bf3cf9d Sema: Record pack expansion environments in the trail 2024-10-01 18:10:20 -04:00
Slava Pestov
9afb1a960b Sema: Record opened pack expansion types in the trail 2024-10-01 18:10:20 -04:00
Slava Pestov
7d3350d0f2 Sema: Record opened existential types in the trail 2024-10-01 18:10:19 -04:00
Slava Pestov
f963f36a16 Sema: Record opened types in the trail 2024-10-01 18:10:19 -04:00
Slava Pestov
8b4a58fb02 Sema: Record applied disjunctions in the trail 2024-10-01 18:10:18 -04:00
Slava Pestov
8799596bed Sema: Record disjunction choices in the trail 2024-10-01 18:10:18 -04:00
Slava Pestov
49487b8893 Sema: Record fixed requirements in the trail 2024-10-01 18:10:17 -04:00
Slava Pestov
df692edc7c Sema: Record fixes in the trail 2024-10-01 12:34:41 -04:00
Slava Pestov
62a470e3d5 Sema: Record conversion restrictions in the trail 2024-10-01 12:34:41 -04:00
Slava Pestov
186589bd25 Sema: Remove SolverTrail::Change::introducedToInference() 2024-09-30 22:05:41 -04:00
Slava Pestov
148033930c Sema: Split off introduceToInference() into its own Change
Previously, retractFromInference() was the last step in
unbindTypeVariable(). This doesn't really make sense,
because bindTypeVariable() doesn't call introduceToInference();
its two callers do it later.

Start untangling this by splitting off introduceToInference()
into its own Change, but for now, record this change at the
incorrect place to maintain the same behavior as before.
2024-09-29 21:46:41 -04:00
Slava Pestov
8ee4eeee55 Sema: Migrate SavedTypeVariableBindings to SolverTrail 2024-09-26 23:15:27 -04:00
Slava Pestov
fca570ca91 Sema: Don't use ExistentialLayout for DeepEquality matching 2024-09-24 19:12:44 -04:00
Slava Pestov
afbd81a599 AST/Sema: Use ProtocolConformanceRef::getTypeWitness() 2024-09-19 14:18:33 -04:00
Slava Pestov
834574d1c0 Sema: Replace a couple of getTypeOfMember() calls 2024-09-19 12:54:27 -04:00
Slava Pestov
f35c90a6b7 Merge pull request #76445 from slavapestov/maptypeintocontext
Overhaul mapTypeIntoContext()
2024-09-14 08:45:20 -04:00
Slava Pestov
4923521227 AST: Re-implement GenericEnvironment::mapTypeIntoContext() using TypeTransform 2024-09-13 15:19:48 -04:00
Allan Shortlidge
c868378d96 ConstraintSystem: Use scoring to implement MemberImportVisibility.
Previously, the constraint solver would first attempt member lookup that
excluded members from transitively imported modules. If there were no viable
candidates, it would perform a second lookup that included the previously
excluded members, treating any candidates as unviable. This meant that if the
member reference did resolve to one of the unviable candidates the resulting
AST would be broken, which could cause unwanted knock-on diagnostics.

Now, members from transitively imported modules are always returned in the set
of viable candidates. However, scoring will always prioritize candidates from
directly imported modules over members from transitive imports. This solves the
ambiguities that `MemberImportVisibility` is designed to prevent. If the only
viable candidates are from transitively imported modules, though, then the
reference will be resolved successfully and diagnosed later in
`MiscDiagnostics.cpp`. The resulting AST will not contain any errors, which
ensures that necessary access levels can be computed correctly for the imports
suggested by `MemberImportVisibility` fix-its.

Resolves rdar://126637855.
2024-09-10 09:47:42 -07:00
Hamish Knight
ee0e408a8c [Sema] Remove separate closure type-checking logic
`participatesInInference` is now always true for
a non-empty body, remove it along with the separate
type-checking logic such that empty bodies are
type-checked together with the context.
2024-09-08 16:17:11 +01:00
Slava Pestov
851a829063 Sema: Consolidate logic for opening existentials in OpenedExistentials.cpp 2024-09-04 14:57:38 -04:00
Slava Pestov
3f317a10fc Merge pull request #76216 from slavapestov/existential-signature-rework-part-2
Convert more callers to use new form of ASTContext::getOpenedExistentialSignature()
2024-09-03 23:22:00 -04:00
Slava Pestov
8299655629 Sema: Use new form of getOpenedExistentialSignature() in typeEraseOpenedExistentialReference() 2024-09-03 17:31:26 -04:00
Slava Pestov
ba585fd6c0 Merge pull request #76206 from slavapestov/existential-signature-rework-part-1
AST: Add new implementation of getOpenedExistentialSignature()
2024-09-03 10:05:29 -04:00
Slava Pestov
09496261ca Sema: Use new form of getOpenedExistentialSignature() in ConstraintSystem::isMemberAvailableOnExistential() 2024-09-02 21:42:04 -04:00
Slava Pestov
cc6b3c1cba AST: Simplify ValueDecl::findExistentialSelfReferences() 2024-09-02 21:42:04 -04:00
Slava Pestov
56cefdc83f AST: Clean up findGenericParameterReferences() 2024-09-02 16:12:31 -04:00
Slava Pestov
a499bfc21b Sema: Use new form of getOpenedExistentialSignature() in doesMemberHaveUnfulfillableConstraintsWithExistentialBase() 2024-09-02 13:52:16 -04:00
Slava Pestov
c0f1fd413e Sema: Handle SameShape requirements in doesMemberHaveUnfulfillableConstraintsWithExistentialBase() 2024-09-02 13:25:16 -04:00
Pavel Yaskevich
daab4e1c9e [ConstraintSystem] InferSenableFromCaptures: Fix treatment of partially applied instance methods on non-Sendable base
In situations like:

```
class A {
  func test() {}
}
```

Fully uncurried function type should be @Sendable but inner method
cannot be because it captures a non-Sendable type `A` when applied.
2024-09-02 00:23:07 -07:00
Pavel Yaskevich
df27db1534 [ConstraintSystem] NFC: Remove obsolete isPartialApplication 2024-08-30 17:04:51 -07:00
Pavel Yaskevich
05b0adac5d [ConstraintSystem] Use getNumApplications + ValueDecl::getNumCurryLevels to detect partial applications
We used to detect partial applications based on member locators
and parent expressions, but using function reference kind +
check to see if self is applied is such simpler and hits both
uses of `isPartialApplication`.
2024-08-30 17:04:46 -07:00
Pavel Yaskevich
67ee63d875 [ConstraintSystem] InferSendableFromCaptures: Mark unapplied operator references as @Sendable
Both of these functions are single-apply instance members,
even though their names could be compound the application
is still a regular call with like `next(isolation: ...)`
vs. `next(isolation:)(...)` it would have to be for a "compound"
application.

Operator references don't have a base type and could be found via
unqualified lookup, `adjustFunctionTypeForConcurrency` should handle
them specifically.

Resolves: rdar://131321053
2024-08-30 15:24:26 -07:00
Pavel Yaskevich
88e2484b39 [ConstraintSystem] Fix isPartialApplication to handle unappled operator references 2024-08-28 12:47:57 -07:00
Slava Pestov
ff308e9510 AST: Remove TypeBase::openAnyExistentialType() 2024-08-20 12:15:27 -04:00
Slava Pestov
0c2f28fd3d AST: Remove GenericSignature parameter from OpenedArchetypeType::get() 2024-08-20 12:15:27 -04:00
Slava Pestov
d4d85572ce Sema: typeEraseOpenedArchetypesWithRoot() => typeEraseOpenedArchetypesFromEnvironment() 2024-08-19 16:55:10 -04:00
Slava Pestov
b601c294ac AST: Replace remaining uses of Type::transform() with transformRec() 2024-08-12 16:05:43 -04:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Greg Titus
d87e049cde Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify.
New separate fix for allow generic function specialization.
Improve parse heuristic for isGenericTypeDisambiguatingToken.
Degrade concrete type specialization fix to warning for macros.
2024-07-30 18:51:34 -07:00
Doug Gregor
817e1c18b0 Extend type checker hack for @_unsafeInheritExecutor functions to methods
With the re-introduction of `@_unsafeInheritExecutor` for `TaskLocal.withValue`,
we need to extend the type checker trick with `_unsafeInheritExecutor_`-prefixed
functions to work with methods. Do so to make `TaskLocal.withValue` actually
work this way.
2024-07-09 21:39:42 -07:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Slava Pestov
8feb3bd819 Sema: Remove ModuleDecl parameter from substMemberTypeWithBase() 2024-07-06 12:05:46 -04:00
Slava Pestov
fae01d9776 AST: Remove ModuleDecl parameter from more places 2024-07-06 12:05:46 -04:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00
Hamish Knight
a9d3df06b3 Merge pull request #74352 from hamishknight/complete-disjunction
[Completion] Skip `tryOptimizeGenericDisjunction` if there's a completion child
2024-06-14 09:25:19 +01:00
Doug Gregor
95e12ca584 Don't apply @Sendable to enum cases in pattern matching 2024-06-13 11:56:18 -07:00
Doug Gregor
c65264738b Treat references to enum cases with associated values as @Sendable functions
When `InferSendableFromCaptures`, make sure to treat references to enum
cases that have associated values as `@Sendable` functions.
2024-06-12 14:58:56 -07:00
Hamish Knight
09a1f0b0c1 [CS] NFC: Factor out includingParentApply 2024-06-12 19:38:09 +01:00