Commit Graph

26323 Commits

Author SHA1 Message Date
Becca Royal-Gordon
2a53433ad7 Soften @impl warnings only for early adopters
Adopting @implementation turns all of the warnings into errors.
2024-03-27 14:29:57 -07:00
Becca Royal-Gordon
29b5a92335 Warn that @objcImpl extension is deprecated
…only when the ObjCImplementation experimental language feature is enabled. (`@implementation extension` is the preferred form.)
2024-03-27 14:29:57 -07:00
Becca Royal-Gordon
492d4ad49d Add experimental feature flags for @implementation
• ObjCImplementation controls @implementation on extensions
• CImplementation controls @implementation and @_objcImplementation on cdecl functions

Why the difference between them? Because `@_objcImplementation extension` has already been adopted pretty widely, while `@_objcImplementation @_cdecl` is very new.
2024-03-27 14:29:57 -07:00
Pavel Yaskevich
ede7df67fc Merge pull request #72558 from xedin/improve-diag-for-same-type-req-in-opaque
[CSDiagnostics] Add a diagnostic for same-type/supertype requirement failures in…
2024-03-27 09:58:25 -07:00
Meghana Gupta
44b2c4d405 Merge pull request #72569 from meg-gupta/fixlifetime
Updates on lifetime dependence
2024-03-27 09:53:25 -07:00
Meghana Gupta
11d5179587 Allow lifetime dependence inference on implicit initializers 2024-03-26 21:51:50 -07:00
Meghana Gupta
53905ae159 Dont query serialized source loc during lifetime dependence inference
It can cause circular reference errors
2024-03-26 20:41:21 -07:00
Holly Borla
61548230d7 [Concurrency] Don't allow erasing global actor isolation when the function
value crosses an isolation boundary.
2024-03-26 18:53:41 -07:00
Meghana Gupta
3aa5f94ba0 Remove bailout on builtins from lifetime dependence inference 2024-03-26 14:56:56 -07:00
Pavel Yaskevich
25ce6604cd [CSDiagnostics] Add a diagnostic for superclass requirement failure in opaque return type 2024-03-26 12:07:14 -07:00
Pavel Yaskevich
08e93825d2 [CSDiagnostics] Add a diagnostic for same-type requirement failure in opaque return type
Follow-up to https://github.com/apple/swift/pull/72493
2024-03-26 11:11:30 -07:00
Holly Borla
efb0e1e933 Merge pull request #72507 from hborla/dispatch-main-actor
[Concurrency] Apply `@MainActor` to main dispatch queue operations without considering `Sendable`.
2024-03-25 11:49:39 -07:00
Sima Nerush
f1bb9c845e Merge pull request #72473 from simanerush/nonisolated-property-struct-inference
[Concurrency] Infer `nonisolated` for a mutable storage of a value type accessed from within the module.
2024-03-25 09:36:36 -07:00
Doug Gregor
7f74e7ae37 Merge pull request #72551 from DougGregor/implements-on-asyncsequence-failure
[Associated type inference] Resolve `@_implements` on AsyncSequence.Failure
2024-03-25 02:00:19 -07:00
Doug Gregor
1cc15414e2 [Associated type inference] Resolve @_implements on AsyncSequence.Failure
A source-compatibility hack to not resolve AsyncSequence.Failure via
lookup accidentally disabled the `@_implements`-based lookup that
we use to avoid having to run inference again in Swift textual
interfaces. Tweak the logic here to narrow the source-compatibilty
hack.

Fixes rdar://125320522.
2024-03-24 23:01:25 -07:00
Sima Nerush
05859b442c [Features] Gate global-actor-isolated types usability changes behind an experimental feature flag. 2024-03-23 20:03:01 -07:00
Sima Nerush
043cc26661 [Concurrency] Infer nonisolated for a mutable storage of a value type accessed from within the module. 2024-03-23 20:01:45 -07:00
Meghana Gupta
b5ca933002 Update lifetime dependence syntax and inference as per changes in the pitch
Pitch - https://github.com/apple/swift-evolution/pull/2305

Changes highlights:

dependsOn(paramName) and dependsOn(scoped argName) syntax

dependsOn(paramName) -> copy lifetime dependence for all parameters/self except
                         when we have Escapable parameters/self, we assign scope
                         lifetime dependence.

Allow lifetime dependence on parameters without ownership modifier.

Always infer copy lifetime dependence except when we have
Escapable parameters/self, we infer scope lifetime dependence.

Allow lifetime dependence inference on parameters without ownership modifier.
2024-03-23 18:19:47 -07:00
Meghana Gupta
e3a11ffa5a NFC: Minor refactor 2024-03-23 09:48:09 -07:00
Konrad `ktoso` Malawski
6132386371 [Distributed] Complete handling of protocol calls and witnesses using adjusted mangling scheme (#72416) 2024-03-23 23:54:23 +09:00
Pavel Yaskevich
a7f9a689fc [ConstraintSystem] Move @Sendable inference for partially applied members to adjustFunctionTypeForConcurrency 2024-03-22 09:02:32 -07:00
Slava Pestov
336750effd Merge pull request #72495 from slavapestov/fix-protocol-superclass
AST: Remove ProtocolDecl::getSuperclass()
2024-03-22 07:40:46 -04:00
Holly Borla
7dc29a7f54 [Concurrency] Apply @MainActor to main dispatch queue operations without
considering `Sendable`.
2024-03-21 19:59:15 -07:00
Pavel Yaskevich
64a200ab07 [MiscDiagnostics] Make sure that diagnostics look through function conversions
None of the diagnostics in MiscDiagnostics make a distinction between
sendable or actor-isolated function references which means that we can
skip conversions while reaching for a declaration used in an application.
2024-03-21 15:35:03 -07:00
Pavel Yaskevich
48e9684758 [ConstraintSystem] Move @Sendable inference for global functions to adjustFunctionTypeForConcurrency 2024-03-21 15:34:57 -07:00
Slava Pestov
839063cab0 AST: Remove ProtocolDecl::getSuperclass()/setSuperclass() 2024-03-21 15:15:59 -04:00
Slava Pestov
614dd51f76 Sema: Remove unnecessary ProtocolDecl::getSuperclass() check
The condition that the conforming type satisfies the superclass bound
of the conformed protocol is already covered by the conformance constraint
itself.
2024-03-21 14:49:05 -04:00
Slava Pestov
f42330151a Sema: Fix @marker attribute checking 2024-03-21 14:49:05 -04: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
Allan Shortlidge
f3441c0b4a Merge pull request #72410 from tshortli/key-path-accessor-availability-diagnostics
Sema: Diagnose availability of storage accessors in key paths and writebacks
2024-03-19 23:28:38 -07:00
Meghana Gupta
992396bfd5 Merge pull request #72431 from meg-gupta/lifetimeinsil
Parse explicit lifetime dependence specifiers in SIL
2024-03-19 17:11:23 -07:00
Allan Shortlidge
c7f0c58615 Sema: Diagnose availability of accessors in chained assignments.
In the following example, the writeback via the property `b` should be
diagnosed since `b`'s setter is unavailable:

```
struct A {
  struct B {
    var x: Int = 0
  }

  private var _b: B = B()
  var b: B {
    get { _b }
    @available(*, unavailable) set {
      _b = newValue
    }
  }
}

var a = A()
a.b.x = 1
```

Resolves rdar://125019717
2024-03-19 17:10:44 -07:00
Allan Shortlidge
ad940abf4d Sema: Diagnose availability of storage accessors for key paths.
Fixes the missing diagnostic about the availability of the setter of `x` in the
following example:

```
struct S {
  var x: Int {
    get { 0 }
    @available(*, unavailable) set {}
  }
}

var s = S()
s[keyPath: \.x] = 1
```

Resolves rdar://124977727
2024-03-19 17:10:44 -07:00
Holly Borla
9b41669c8b Merge pull request #72437 from hborla/sendable-closures-under-minimal-checking
[Concurrency] Don't strip `@Sendable` when determining the actor isolation of a closure in a `@preconcurrency` context.
2024-03-19 17:07:42 -07:00
Holly Borla
6ff708e741 [Concurrency] Don't strip @Sendable when determining the actor isolation
of a closure in a `@preconcurrency` context.

Instead, downgrade any diagnostics about non-`Sendable` captures using the
`.limitBehaviorUntilSwiftVersion` mechanism like other preconcurrency errors
that are suppressed in minimal checking. Stripping `@Sendable` from closure
types actually changes the isolation of the closure, because non-`Sendable`
closures are isolated to the context they're formed in, which leads to bogus
dynamic assertion failures under `-enable-actor-data-race-checks`.
2024-03-19 14:07:03 -07:00
Meghana Gupta
5ad0a8b064 Parse explicit lifetime dependence specifiers in SIL 2024-03-19 13:34:50 -07:00
Angela Laar
6d2e87f8c7 Merge pull request #72367 from angela-laar/dot-isolation-member-for-optionals
[Sema] `.isolation` member missing for optional function values
2024-03-19 10:44:08 -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
Angela Laar
12ff5eeea7 test function isolation expression 2024-03-18 17:04:32 -07:00
Cal Stephens
3315cab336 Merge branch 'main' into cal--fix-70089 2024-03-18 16:44:09 -07:00
Allan Shortlidge
5a232391f5 Sema: Do not diagnose set accessor availability for InOutExprs inside of LoadExprs.
The recent deprecation of the set accessor for `CommandLine.arguments` exposed
a bug in availability checking:

```
 for arg in CommandLine.arguments[1...] {
                      ╰─ warning: setter for 'arguments' is deprecated: ...
```

The parser generates an `InOutExpr` in the AST for the subscript access in the
code above and the availabilty checker was unconditionally diagnosing set
accessors for `InOutExprs`, resulting in spurious availability warnings for
read-only accesses of properties. The fix is to check whether there is an
enclosing `LoadExpr` in the AST and only diagnose the getter accessor in that
case.

Resolves rdar://124566405
2024-03-18 16:18:08 -07:00
Pavel Yaskevich
5890de3823 [CSSimplify] NFC: Rework a comment about why match is imported to allow 2024-03-18 12:10:44 -07:00
Pavel Yaskevich
c06a1a8ee9 [Sema] WitnessMatching: Warn about sendability mismatches associated with ObjC requirements
Since importer ignored `swift_attr` that appeared in a type context
until recently we need to maintain status quo with concurrency stripping
from ObjC requirements in modes that don't have full concurrency
checking enabled.
2024-03-18 10:43:42 -07:00
Pavel Yaskevich
0f26da4288 [Sema] WitnessMatching: Anchor requirement-witness type matching on a witness locator 2024-03-18 10:43:42 -07:00
Pavel Yaskevich
38a6d88042 [ConstraintSystem] ConstraintLocator: Implement printing of decl anchors 2024-03-18 10:43:41 -07:00
Pavel Yaskevich
4d501efc0a [Sema] WitnessMatching: Anchor witness on the requirement declaration 2024-03-18 10:43:41 -07:00
Pavel Yaskevich
31e385f20e [Sema] WitnessMatching: Anchor ProtocolRequirement on the requrement declaration
Locators used to support only expressions which is no longer the case.
2024-03-18 10:43:41 -07:00
Pavel Yaskevich
559927da59 Merge pull request #71931 from xedin/relax-potential-incompleteness-of-generic-param-vars
[CSBindings] Mark generic parameter type vars as complete if they don…
2024-03-18 09:39:05 -07:00
Pavel Yaskevich
1fa0179e96 Merge pull request #72353 from xedin/rdar-124549952
[CSSimplify] Mark all type variables in member type as holes if base …
2024-03-18 09:25:28 -07:00
Holly Borla
ee197aea4a Merge pull request #72078 from simanerush/redundant-nonisolated-unsafe
[Concurrency] Diagnose a redundant `nonisolated(unsafe)`
2024-03-16 15:34:31 -07:00