Commit Graph

1570 Commits

Author SHA1 Message Date
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
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Doug Gregor
39f4e38027 Diagnose inout uses of 'lets' in constructors in the type checker.
Stored `let` properties of a struct, class, or actor permit
'inout' modification within the constructor body after they have been
initialized. Tentatively remove this rule, only allowing such `let`
properties to be initialized (assigned to) and not treated as `inout`.

Fixes rdar://127258363.
2024-05-14 15:59:50 -07:00
Anthony Latsis
d18a7fd073 Sema: Require CS to certify conversions associated w/ existential member accesses 2024-04-18 22:54:19 +03:00
Anthony Latsis
52d613e2c2 Sema: Fix existential member access type erasure around metatypes
The only case a singleton metatype transforms into an existential metatype is
when the instance type transforms into an existential from a non-existential.
2024-04-18 22:52:52 +03:00
Pavel Yaskevich
a7f9a689fc [ConstraintSystem] Move @Sendable inference for partially applied members to adjustFunctionTypeForConcurrency 2024-03-22 09:02:32 -07:00
Pavel Yaskevich
48e9684758 [ConstraintSystem] Move @Sendable inference for global functions to adjustFunctionTypeForConcurrency 2024-03-21 15:34:57 -07:00
Pavel Yaskevich
eb9755367c [ConstraintSystem] NFC: Switch adjustFunctionTypeForConcurrency to use FunctionType
This method is always called after the type is opened by the solver
which means that we never end up with `GenericFunctionType`.
2024-03-20 13:16:18 -07:00
Pavel Yaskevich
56d207ab1a Merge pull request #72277 from xedin/improvements-to-protocol-witness-matching
[Sema/ClangImporter] Improvements to witness matching
2024-03-19 09:36:32 -07:00
Pavel Yaskevich
38a6d88042 [ConstraintSystem] ConstraintLocator: Implement printing of decl anchors 2024-03-18 10:43:41 -07:00
Kavon Farvardin
149c052ec5 use new noncopyable types infrastructure
The infrastructure underpinning the new feature NoncopyableGenerics is
mature enough to be used.
2024-03-14 23:10:44 -07:00
Holly Borla
0a627bc44c Merge pull request #72324 from hborla/extract-function-isolation-expr
[Concurrency] Add a `.isolation` member on dynamically isolated function values.
2024-03-14 06:56:43 -07:00
Holly Borla
d9aa8697ab [Concurrency] Teach the constraint system about .isolation on dynamically
isolated function values.
2024-03-13 22:23:31 -07:00
Erik Eckstein
3c76464c1c rename withConcurrent -> withSendable
That was missed when "concurrent" was renamed to "sendable"
2024-03-13 09:58:31 +01:00
Pavel Yaskevich
279e147ae2 Merge pull request #71701 from li3zhen1/my-branch
[CSDiagnostics] Add diagnostics for holes in generic parameter packs
2024-03-06 11:58:19 -08:00
Hamish Knight
8b42107a4e [CS] Rename SyntacticElementTarget::forEachStmt -> forEachPreamble
This more closely matches what we're actually
type-checking, since we do not currently include
the body.
2024-03-04 11:56:24 +00:00
Zhen Li
e513a7a8e2 Merge branch 'apple:main' into my-branch 2024-02-27 21:56:03 -05:00
li3zhen1
00b0491676 [CSDiagnostics] Update UnableToInferGenericPackElementType to accept overloads and update test cases 2024-02-27 20:35:06 -05:00
Pavel Yaskevich
f13904bddd Merge pull request #71889 from xedin/static-members-are-always-sendable
[ConstraintSystem] Skip sendability check for static members
2024-02-27 09:37:16 -08:00
Pavel Yaskevich
7c0bb41573 [ConstraintSystem] Skip sendability check for static members
Such members only capture base metatatypes which are themselves
always sendable.
2024-02-26 11:52:38 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Pavel Yaskevich
4548b2a861 Merge pull request #71817 from xedin/rdar-122598934
[ConstraintSystem] Account for situations when witness for associated…
2024-02-23 09:20:26 -08:00