Commit Graph

42290 Commits

Author SHA1 Message Date
Slava Pestov
b14563f8e8 Merge pull request #74201 from slavapestov/macro-expansion-mangling
Change macro expansion mangling to avoid request cycles
2024-06-14 01:41:45 -04:00
Michael Gottesman
16d0194d77 [sending] Improve the sending mismatch errors and make them warnings when not in swift 6.
This will ensure that we do not break anyone who has adopted APIs like
CheckedContinuation.resume that now have sending parameters.

An example of where this can come up is shown by the ProcessType in SwiftToolsCore:

```swift
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@discardableResult
public func waitUntilExit() async throws -> ProcessResult {
    try await withCheckedThrowingContinuation { continuation in
        DispatchQueue.processConcurrent.async {
            self.waitUntilExit(continuation.resume(with:))
        }
    }
}
```

This fails to compile since self.waitUntilExit doesn't expect a function that
takes a sending parameter. We want to give people time to fix such issues.
2024-06-13 22:23:08 -07:00
Alexis Laferrière
4dc060303e Merge pull request #74142 from xymus/access-level-conformances
Sema: Report public conformances to non-publicly imported protocols
2024-06-13 19:34:37 -07:00
Karoy Lorentey
e563f660bb [AST] Update availability of features targeting 6.0 2024-06-13 18:00:45 -07:00
Karoy Lorentey
284044132e [AST] Define placeholder availability for the 6.1 runtime 2024-06-13 18:00:45 -07:00
Karoy Lorentey
30f121d3a0 [AST] Define runtime version 6.0 2024-06-13 18:00:45 -07:00
Tim Kientzle
a1708ef8b1 Merge pull request #74394 from tbkka/tbkka-remotemirror-no-more-mpe-metadata-partial
Remove RemoteInspection code to fetch no-longer-used reflection metadata
2024-06-13 16:40:04 -07:00
Pavel Yaskevich
b5930625be Merge pull request #74315 from xedin/rdar-129599097
[AST] `@preconcurrency` conformance applies to implied conformances a…
2024-06-13 16:30:02 -07:00
Slava Pestov
9793f77daa AST: New mangling for expansion locations to avoid request cycles
Fixes rdar://127078338.
2024-06-13 17:45:30 -04:00
Tim Kientzle
c20ef6de2a Remove RemoteInspection code to fetch no-longer-used reflection metadata
without relying on spare bit information in the reflection metadata
(which was added in #40906).  As a result, we can remove the
code from #40906.

This is the first step in such removal.  It removes the RemoteMirror
code for looking up such metadata.  It leaves behind:

* Sufficient stubs for LLDB to continue to build.  Once LLDB is updated, these stubs can be removed as well.

* The compiler code to emit such metadata.  This allows new binaries to still reflect MPEs on older runtimes.  This will need to be kept for a transitional period.
2024-06-13 09:34:43 -07:00
Hamish Knight
26e8245e22 [Sema] Requestify pattern resolution
Add a cached request to perform pattern resolution.
This is needed to prevent the constraint system
from resolving the same pattern multiple times
along different solver paths, which could result
in creating different pattern nodes for each path.
Once pattern resolution is moved to pre-checking
we ought to be able to make this uncached.

rdar://128661960
2024-06-13 15:27:47 +01:00
Gábor Horváth
de9aefc842 Merge pull request #74330 from apple/gaborh/core-foundation-types
[cxx-interop] Fix extra indirection when exporting CFData arguments
2024-06-13 08:29:34 +01:00
Kavon Farvardin
9eba052ab2 Merge pull request #74322 from kavon/se427-noimplicit-for-invertible
SE-427: Make conditional conformances to Copyable more explicit.
2024-06-12 22:03:49 -07:00
nate-chandler
6694bbab90 Merge pull request #74360 from nate-chandler/rdar127518559
[ConsumeAddrChecker] Diagnose consumes of borrows.
2024-06-12 20:33:07 -07:00
Michael Gottesman
6d15e41a2f Merge pull request #74123 from gottesmm/pr-9e8378fdeee3204a34f48ea8d2ff8f0be40a4674
[region-isolation] Make store_borrow a store operation that does not require
2024-06-12 19:43:17 -07:00
Michael Gottesman
2ac874e8e3 [sending] Fix a few bugs around closure inference of sending parameters and results.
I found this while writing tests for the earlier part of this work. Since this
is also type checking work, I am just folding this work into that work.
2024-06-12 16:13:05 -07:00
Michael Gottesman
bd472b12be [region-isolation] Make store_borrow a store operation that does not require.
TLDR:

The reason why I am doing this is it ensures that temporary store_borrow that we
create when materializing a value before were treated as uses. So we would error
on this:

```swift
@MainActor func transferToMain<T>(_ t: T) async {}

func test() async {
  let x = NonSendableKlass()
  await transferToMain(x)
  await transferToMain(x)
}
```

----

store_borrow is an instruction intended to be used to initialize temporary
alloc_stack with borrows. Since it is a temporary, we do not want to error on
the temporaries initialization... instead, we want to error on the use of the
temporary parameter.

This is achieved by making it so that store_borrow still performs an
assign/merge, but does not require that src/dest be alive. So the regions still
merge (yielding diagnostics for later uses).

It also required me to make it so that PartitionOp::{Assign,Merge} do not
require by default. Instead, we want the individual operations to always emit a
PartitionOp::Require explicitly (which they already did).

One thing to be aware of is that when it comes to diagnostics, we already know
how to find a temporaries original value and how to handle that. So this is the
last part of making store_borrow behave nicely.

rdar://129237675
2024-06-12 15:01:38 -07:00
Alexis Laferrière
67694c2ab0 Sema: Report public conformances to non-publicly imported protocols
Exportability checking for non-public imports relies on classic
access-level checks for some of the work. However while conforming
to a local internal protocol from a public type is allow we should
disallow it for imported types, even when imported as internal.

Track exportability issues on conformances to protocols separately
from the general category. Use that information to improve the
diagnostics and report these issues for access-level on imports.

rdar://128420980
2024-06-12 14:48:46 -07:00
Alex Hoppen
f5d15f4f60 Merge pull request #74241 from ahoppen/enum-case-rename
Fix renaming enum case parameters with unnamed associated arguments
2024-06-12 14:46:46 -07:00
Kavon Farvardin
a1e14ae0c7 Sema: ext's must add solo invertible conformances
This helps prevent confusion after not inferring requirements if the
extension adds a Copyable conformance.
2024-06-12 14:44:22 -07:00
Kavon Farvardin
2893e3dd8d Sema: reword inverse-on-extension message
We should be saying "can't suppress Copyable" instead, since you can't
"suppress" ~Copyable.
2024-06-12 14:44:22 -07:00
Nate Chandler
29ee0ed56e [Gardening] Clarified documentation. 2024-06-12 13:12:21 -07:00
eeckstein
b7b93a12a0 Merge pull request #74329 from eeckstein/fix-block-cloning
SIL: update borrowed-from instructions when cloning a basic block
2024-06-12 20:38:13 +02:00
Hamish Knight
09a1f0b0c1 [CS] NFC: Factor out includingParentApply 2024-06-12 19:38:09 +01:00
Gabor Horvath
ae1f8042c0 [cxx-interop] Fix extra indirection when exporting CFData arguments/return values
The clang nodes associated with Swift's Core Foundation types can already be
represented by a pointer. The interop code does not need to add an extra
layer of indirection in those cases.

rdar://119840281
2024-06-12 16:39:20 +01:00
Artem Chikin
3dfeb5f876 Merge pull request #74307 from artemcm/CacheVisibleClangModulesInModules
Cache visible Clang modules for interface printing in `ModuleDecl`
2024-06-12 07:33:13 -07:00
nate-chandler
3aca85bfb3 Merge pull request #74298 from nate-chandler/rdar129593468
[NoncopyableWrapperElim] Process undef values.
2024-06-12 06:55:48 -07:00
Hamish Knight
af0062725e [Completion] Complete ownership specifiers in parameters
Complete ownership specifiers such as `consuming`,
`borrowing`, and `inout` in parameter type
position. While here, also complete `isolated`.

rdar://127261573
2024-06-12 13:36:07 +01:00
Hamish Knight
d8c7440e96 [AST] Demote inout to a SWIFT_KEYWORD
Defining it as a `DECL_KEYWORD` means code
completion will try and complete it in decl
position. It shouldn't really be considered a decl
keyword, so define it as `SWIFT_KEYWORD`.
2024-06-12 13:36:06 +01:00
Hamish Knight
c6ff153503 [AST] Unmark consuming and borrowing as UserInaccessible
These are official features now (SE-0377). This
allows them to show up in code completion.
2024-06-12 13:36:06 +01:00
Erik Eckstein
d80813ee3b SIL: update borrowed-from instructions when cloning a basic block
Cloning blocks might split CFG edges which can "convert" terminator result arguments to phi-arguments.
In this case a borrowed-from instruction must be inserted.

Fixes a SIL verifier crash caused by SimplifyCFG's jump threading.
rdar://129187525
2024-06-12 12:56:34 +02:00
Alex Hoppen
155773c38e Fix renaming enum case parameters with unnamed associated arguments
We treated enum case parameters the same way as function parameters and weren’t considering that they can be unlabeled. That caused us to insert eg. `_ ` in front of the case’s type, producing `case myCase(_ String)`, which is invalid. When we are inside an enum case parameter and the parameter label is empty, treat it the same as a function call, which will leave the label untouched if it isn’t modified and insert a label including a colon if a new label is introduced.

https://github.com/apple/sourcekit-lsp/issues/1228
2024-06-11 19:18:59 -07:00
Xi Ge
bcdcdf19f6 Merge pull request #74302 from nkcsgexi/revert-pkg-export
Revert recent changes for exportability for package declarations
2024-06-11 17:13:21 -07:00
Nate Chandler
fed3cb84c6 [NFC] SIL: Expose undef values. 2024-06-11 16:25:31 -07:00
Nate Chandler
f39b70a86d [NFC] SIL: Extracted remove "any" m-o wrapping. 2024-06-11 16:25:29 -07:00
Nate Chandler
78c18374c3 [NFC] SIL: Extracted has "any" move-only wrapping.
This predicate is used in several places.
2024-06-11 16:25:14 -07:00
Nate Chandler
b5b637c72e [NFC] SIL: Renamed helper.
removing...To -> removing...From
2024-06-11 16:25:11 -07:00
Yuta Saito
8428b36571 Merge pull request #74277 from kateinoigakukun/katei/save-public-autolink-library-interface
[ModuleInterface] Save `-public-autolink-library` module option
2024-06-12 08:08:18 +09:00
Pavel Yaskevich
414295df96 [AST] @preconcurrency conformance applies to implied conformances as well
A `@preconcurrency` conformance to an inherited protocol should imply
`@preconcurrency` on its parents as well. For example:

```swift
protocol Parent {
  func a()
}

protocol Child: Parent {
  func b()
}

@MainActor
class Test: @preconcurrency Child {
  func a() {
  }

  func b() {
  }
}
```

`Test` conformance to `Parent` implied by its conformance to `Child`
should carry `@preconcurrency` and inject dynamic actor isolation checks
to witness of `a()`.

Resolves: https://github.com/apple/swift/issues/74294
Resolves: rdar://129599097
2024-06-11 15:52:41 -07:00
Meghana Gupta
f1a887515b Merge pull request #74195 from meg-gupta/immortal
Add dependsOn(immortal)
2024-06-11 15:51:34 -07:00
Xi Ge
34d9b6cb6b Revert "Sema: Report references to missing imports from package extensions"
This reverts commit 12f7abcef6.
2024-06-11 14:03:45 -07:00
Artem Chikin
71ec06e656 Cache visible Clang modules for interface printing in 'ModuleDecl'
Instead of caching the collection of visible Clang modules in the 'TypePrinter', compute and cache them in the 'ModuleDecl'. When printing a textual interface, the compiler will instantiate many new instances of 'TypePrinter', which means caching them there is not useful.
2024-06-11 13:04:16 -07:00
Xi Ge
6f5b40543d Revert "Handle package exportability."
This reverts commit d182d01c28.
2024-06-11 11:54:00 -07:00
Meghana Gupta
c14559173d Add dependsOn(immortal) 2024-06-11 11:18:10 -07:00
Slava Pestov
322ce5a1ab SIL: Consistently drop substitution map when forming apply instructions
Fixes rdar://129298104.
2024-06-11 10:36:15 -04:00
Pavel Yaskevich
51d817cd0e Merge pull request #74242 from iMostfa/feature/SR-9615-escaping-and-inout-support
Remove `@escaping` from inout closures
2024-06-11 00:28:33 -07:00
eeckstein
8dec8f6058 Merge pull request #74259 from eeckstein/fix-fixed-abi-runtime-effects
PerformanceDiagnostics: avoid false meta-data alarms for non-loadable types
2024-06-11 07:26:34 +02:00
Yuta Saito
6a11171755 [ModuleInterface] Save -public-autolink-library module option
Serialize the `-public-autolink-library <name>` option to the
moduleinterface file because it can affect the LINK_LIBRARY entries in a
swiftmodule file. Without saving the option, the library won't be linked
when a module compiled from the moduleinterface is used.

This change marks the `-public-autolink-library` option as a module
interface option and reads it when building a swiftmodule by module
loader.
2024-06-11 02:22:31 +00:00
Holly Borla
8ead72414a Merge pull request #74244 from hborla/deprecated-default-implementation
[Sema] Diagnose deprecated default implementations in the witness checker.
2024-06-10 17:33:32 -07:00
iMostafa
9769418dfa Better message diagnostics for inout @escaping closure 2024-06-10 21:40:10 +02:00