Commit Graph

28382 Commits

Author SHA1 Message Date
Slava Pestov
1ff1b9479a AST: Pick off some usages of GenericTypeParamType::getDecl() 2024-09-04 15:13:46 -07:00
Alejandro Alonso
a434126554 Disallow referencing a value generic outside of certain contexts 2024-09-04 15:13:45 -07:00
Alejandro Alonso
f4f60f4344 Remove Value requirement Add GenericTypeParamKind 2024-09-04 15:13:43 -07:00
Alejandro Alonso
0df42e9841 Lower UDRE to TypeValue if it references a value generic 2024-09-04 15:13:29 -07:00
Alejandro Alonso
3e9c4633ca Add some new diagnostics and tests 2024-09-04 15:13:27 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Pavel Yaskevich
6c1fc03c87 [TypeChecker] Limit sendability downgrade to preconcurrency requirements only 2024-09-04 14:54:41 -07:00
Pavel Yaskevich
9a3d1b7eb4 [TypeChecker] Warn if witness mismatches only on sendability until Swift 6 mode
This expands the downgrade for Objective-C requirements to all requirements
until strict concurrency checking is enabled (either via a flag in Swift 5
language mode or by switching to Swift 6 language mode).

Resolves: rdar://134503878
2024-09-04 14:38:06 -07:00
Slava Pestov
851a829063 Sema: Consolidate logic for opening existentials in OpenedExistentials.cpp 2024-09-04 14:57:38 -04:00
Slava Pestov
a3c0e225a7 Merge pull request #76238 from slavapestov/existential-signature-rework-part-3
Allow type variables to appear inside opened existential archetypes
2024-09-04 14:53:18 -04:00
Pavel Yaskevich
f9e08bc6ec Merge pull request #76174 from xedin/remodel-constraint-generation-for-assignment
[ConstraintSystem] Introduce `LValueObject` constraint to replace direct l-value assignments
2024-09-04 09:27:59 -07:00
Doug Gregor
601a5c3c0c Merge pull request #76187 from DougGregor/extract-inlinable-text-swift-syntax
Implement extractInlinableText with swift-syntax
2024-09-04 07:53:40 -07:00
Slava Pestov
5a43d2403e Sema: Simplify opened existential types in solution 2024-09-04 10:42:19 -04:00
Slava Pestov
c47f352df7 AST: Use new form of getOpenedExistentialSignature() in GenericEnvironment::forOpenedExistential() 2024-09-04 10:42:18 -04:00
Alex Hoppen
791c1fddc8 Merge pull request #76237 from swiftlang/revert-60057-mpokhylets/isolated-deinit
Revert "Isolated synchronous deinit"
2024-09-03 22:17:09 -07: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
Alex Hoppen
c5aa49ba64 Revert "Isolated synchronous deinit" 2024-09-03 18:11:26 -07:00
Slava Pestov
e3ff6f0697 AST: Fiddle with GenericEnvironment::forOpenedExistential() again 2024-09-03 17:31:26 -04:00
Slava Pestov
8299655629 Sema: Use new form of getOpenedExistentialSignature() in typeEraseOpenedExistentialReference() 2024-09-03 17:31:26 -04:00
Allan Shortlidge
3f626f50fe Merge pull request #76203 from tshortli/availability-context-cleanup
AST: Clean up `AvailabilityContext` and uses
2024-09-03 09:42:25 -07:00
Konrad `ktoso` Malawski
c86e4a8738 Merge pull request #60057 from nickolas-pohilets/mpokhylets/isolated-deinit
Co-authored-by: Konrad `ktoso` Malawski <ktoso@apple.com>
2024-09-04 01:16:56 +09: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
39d77b81b3 Sema: Rework shouldOpenExistentialCallArgument() 2024-09-02 21:42:04 -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
2ebef08f7e AST: Generalize findGenericParameterReferences() 2024-09-02 21:42:04 -04:00
Allan Shortlidge
89ea92d550 AST: Introduce ASTContext::getTargetPlatformStringForDiagnostics().
NFC.
2024-09-02 18:24:31 -07:00
Allan Shortlidge
8ab7f54cd4 AST/Sema: Favor AvailabilityContext over VersionTuple/VersionRange.
For the purposes of availability calculations, direct use of
`llvm::VersionTuple` and `VersionRange` is discouraged, since these fundamental
version representations are divorced from their context. For example, comparing
an iOS platform version to a visionOS platform version is invalid since the
versioning systems of the two platforms differ. Although visionOS inherits
avialability from iOS, an iOS version must be converted to a visionOS version
prior to comparison. In the future, `AvailabilityContext` can be enriched to
carry the information necessary to verify that its algebraic operations are
being performed on compatible values.

NFC.
2024-09-02 18:24:31 -07:00
Allan Shortlidge
01215b0e3d AST: Remove UnavailabilityReason.
`UnavailabilityReason` does not live up to its name because it only models
potential unavailability due to an unmet OS version requirement. It does not
model unavailability caused by explicit annotation, language mode requirements,
obsoletion, etc. `AvailabilityContext` already models an OS version
requirement, so use it instead.

NFC.
2024-09-02 16:47:14 -07:00
Allan Shortlidge
8052e3f9dc AST: Remove 'OS' from AvailabilityContext member names.
An `AvailabilityContext` represents an abstract version range in which
something is available. In the future, these version ranges may not necessarily
always correspond to operating system version ranges.

NFC.
2024-09-02 16:47:14 -07:00
Slava Pestov
56cefdc83f AST: Clean up findGenericParameterReferences() 2024-09-02 16:12:31 -04:00
Mykola Pokhylets
05b78ff0d8 Merge branch 'main' into mpokhylets/isolated-deinit 2024-09-02 20:21:09 +02: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
bd313deae5 Merge pull request #76136 from xedin/rdar-131321053
[ConstraintSystem] InferSendableFromCaptures: Mark unapplied operator references as `@Sendable`
2024-09-02 08:29:56 -07:00
Konrad `ktoso` Malawski
c55ad6fa88 Merge branch 'main' into mpokhylets/isolated-deinit 2024-09-02 23:16:17 +09: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
Holly Borla
27fd53f981 Merge pull request #76198 from hborla/isolation-macro-mismatch
[Concurrency] Don't crash if a `#isolation` default argument has a type mismatch.
2024-09-01 08:59:34 -07:00
Holly Borla
6f5a64c0ca [Concurrency] Don't crash if a #isolation default argument has a type
mismatch.

The actor isolation checker was setting the actor value for
`#isolation` when type checking the expression failed. Later on, the
isolation checker would crash when querying the type of the actor, e.g.
to check if it's a distributed actor. Instead, keep the actor value as
null if there's a type mismatch.
2024-08-31 21:46:32 -07:00
Allan Shortlidge
daa0c002d2 Merge pull request #76188 from tshortli/retroactive-does-not-apply-same-package-diagnostics
Sema: Fix `@retroactive` does not apply diags for same-package conformance
2024-08-31 10:07:16 -07:00
Hamish Knight
9bd0d9b7e4 [Sema] Walk separately-checked closures normally in MiscDiagnostics
We no longer need to make any special affordances
for separately-checked closures, walk them normally.
2024-08-31 12:47:46 +01:00
Hamish Knight
cbeb4bfbc8 [Sema] Walk patterns for syntactic diagnostics
Use `SyntacticElementTarget::walk`, ensuring we
walk to any ExprPatterns.
2024-08-31 12:47:46 +01:00
Allan Shortlidge
2d4b21102c Sema: Fix @retroactive does not apply diags for same package conformance.
SE-0364 was amended to allow same-package conformances to be considered
non-retroactive. The logic for that ammendment was implemented in Swift 6.0,
but the diagnostics were not updated.

Resolves rdar://133423931.
2024-08-30 21:26:44 -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
Doug Gregor
a73711ef4b Implement extractInlinableText with swift-syntax
Replace the existing C++ implementation of extractInlinableText with
a new implementation based on swift-syntax. It uses SwiftIfConfig to
remove inactive regions (with a special mode), and a new compiler-only
entrypoint in the library to remove comments and `#sourceLocation`.
2024-08-30 16:43:41 -07:00
Pavel Yaskevich
427e7bc196 [CSSimplify] Adjust impact assessment of l-value mismatch based on member settability
Increases the default score of the `treat r-value as l-value`
and decrease the impact if the immediate member is settable
because that means that the problem is somewhere in the "base".
2024-08-30 15:39:25 -07:00
Pavel Yaskevich
10082c6011 [CSBindings] Re-implement closure de-prioritization in assignment context
Re-implements https://github.com/swiftlang/swift/pull/76115 in
a simpler fashion now that we don't have to eagerly binding destination
type on l-value.
2024-08-30 15:39:24 -07:00
Pavel Yaskevich
d8750a83f8 [CSSimplify] Allow l-value object simplication if l-value type is a placeholder
Placeholders propagate but we still can allow contextual inference,
to facilitate that the solver should consider `l-value object` constraint
to be solved and allow placeholders on "object" type.
2024-08-30 15:39:18 -07:00
Pavel Yaskevich
be0bf46657 [CSGen] Set correct ref kinds on synthesized makeIterator and next for for-in loops 2024-08-30 15:26:54 -07:00