Commit Graph

28352 Commits

Author SHA1 Message Date
Alexis Laferrière
321f9aa707 Merge pull request #77454 from xymus/public-imports-of-private-as-error
Sema: Report public imports of private modules as errors by default
2024-11-07 15:47:07 -08:00
Gábor Horváth
88c2269e69 Merge pull request #77323 from swiftlang/gaborh/use-imported-locs
[cxx-interop] Use the locations imported from C++
2024-11-07 17:44:07 +00:00
Alexis Laferrière
d90664c7f1 Sema: Report public imports of private modules as errors by default
Align the behavior between release and debug compilers to always report
this as an error. Downstream compilers already make this an error.

rdar://136041870
2024-11-07 09:41:33 -08:00
Allan Shortlidge
817e4517de Merge pull request #77442 from tshortli/disable-availability-checking 2024-11-07 00:47:04 -08:00
Doug Gregor
7a43b44a2e Merge pull request #77440 from DougGregor/no-fallback-diag-in-transaction
[Constraint solver] Disable fallback diagnostic when error emitted into a transaction
2024-11-06 21:39:59 -08:00
Nate Chandler
8995602107 [NFC] Promote static to member function. 2024-11-06 20:52:21 -08:00
Nate Chandler
76dc6e12a8 [NFC] Cache preexisting synthesized accessor.
Move the bailout from getSynthesizedAccessor from the wrapper function
into the evaluate body.  Will enable the request to do work on
non-synthesized accessors, which is required to provide a default
implementation for modify2 and read2 members.
2024-11-06 20:52:21 -08:00
Nate Chandler
f1f0ccdeff [NFC] Improved predicate names. 2024-11-06 20:52:21 -08:00
Nate Chandler
953aca419d [Gardening] Accessor name spelling in comment. 2024-11-06 20:52:21 -08:00
Nate Chandler
11db6766be [Gardening] Deleted duplicated word in comment. 2024-11-06 20:52:21 -08:00
Doug Gregor
64e08d7e47 Merge pull request #77436 from DougGregor/parse-expression-macro-buffer-as-expression 2024-11-06 20:25:49 -08:00
Allan Shortlidge
d8be24b395 Sema: Fix -disable-availability-checking.
Suppression of diagnostics about use of unavailable declarations in
equivalently unavailable contexts now relies on querying the
`TypeRefinementContext` hierarchy. Generation of the TypeRefinementContext tree
was suppressed when `-disable-availability-checking` was specified, though,
causing some unavailability diagnostics to be emitted when they ought to be
suppressed.

Instead of refusing to generate a `TypeRefinementContext` hierarchy, instead
just avoid populating nodes for `if #available` checks for OS versions since
these checks are meant to have no effect when `-disable-availability-checking`
is specified.

Resolves rdar://138987918.
2024-11-06 17:20:31 -08:00
Doug Gregor
720429daf4 [Constraint solver] Disable fallback diagnostic when error emitted into a transaction
When we are using diagnostic transactions to disable immediate emission
of diagnostics, `DiagnosticEngine::hadAnyError()` no longer accurately
reports whether an error occurred. Thread the DiagnosticTransaction
into the ConstraintSystem so we can also check whether it contains an
error before emitting the fallback diagnostic.

Fixes rdar://128272346.
2024-11-06 17:07:13 -08:00
Konrad `ktoso` Malawski
aadc67ec0e Revert "Make IsolatedDeinit non-experimental" 2024-11-07 09:59:00 +09:00
Doug Gregor
78b89b201c Parse expression macro expansion buffers as expressions
This started out as a crash, where an expression macro could not be
defined in terms of one of the builtin macros (e.g., `#line`), because
we were expecting a macro expansion expression but didn't get one.
Easy fix.

However, this uncovered a second bug, which is that we couldn't handle
an expression macro expansino to `#line`. This is because we were
parsing the macro expansion buffer as "top level items", which treats
`#line` at the start of a line as a deprecated alias of
`#sourceLocation`. Switch over to parsing a single expression in these
contexts, and fix up an issue where `#isolation` didn't even have that
expression.

Fixes rdar://139372780.
2024-11-06 15:55:38 -08:00
Pavel Yaskevich
73d658ae5a [Concurrency] Allow witnesses to adopt concurrency before requirements
Allow witnesses to introduce `any Sendable` types into their interface
before requirements (predicated on presence of `@preconcurrency` and
Swift 5 language mode) as a pathway for concurrency adoption.

Resolves: rdar://134503878
2024-11-06 15:24:36 -08:00
Hamish Knight
4faabc9111 Merge pull request #77417 from hamishknight/duplicate-macro
[CS] Filter out invalid macros from overload set
2024-11-06 18:46:18 +00:00
Allan Shortlidge
b345418eca Merge pull request #77408 from tshortli/revert-package-fixes
Revert removal of `-package-name` from swiftinterfaces
2024-11-06 10:31:34 -08:00
Chris Miles
f7f6cd144e Merge pull request #77350 from swiftlang/eng/chrismiles/Instrumenter-buildPatternAndVariable-crash
Fixes build logger call crashing with ImplicitOpenExistentials.
2024-11-06 10:21:10 -08:00
Hamish Knight
4e7a119235 [CS] Filter out invalid macros from overload set
This matches how we handle OverloadSetRefExpr and
avoids a crash for e.g redeclared macros.
2024-11-06 12:43:41 +00:00
Konrad `ktoso` Malawski
52d55a1426 Merge pull request #77364 from nickolas-pohilets/mpokhylets/non-experimental-isolated-deinit 2024-11-06 11:49:07 +09:00
Allan Shortlidge
49b59f69c9 Revert https://github.com/swiftlang/swift/pull/75745.
Finishes resolving rdar://139236053.
2024-11-05 14:37:56 -08:00
Chris Miles
5380d8c25f Fixes build logger call crashing with ImplicitOpenExistentials.
When ImplicitOpenExistentials was enabled (default in Swift language mode 6) the Instrumenter would crash the compiler when building logger calls. This was due to an incorrect assumption that the newly created apply expr wouldn't change type when type-checked. However, the type checker is free to change the kind of expression and did so in circumstances where the call expr was wrapped in an open existential expr.
2024-11-05 14:24:54 -08:00
Allan Shortlidge
919ec930f9 Merge pull request #77384 from tshortli/rename-unmet-availability-requirement 2024-11-05 10:56:55 -08:00
Pavel Yaskevich
c2299ecaa4 Merge pull request #77377 from xedin/rdar139235128
[BuildTransform] Fix `walkExplicitReturnStmts` to walk implicit state…
2024-11-05 09:16:36 -08:00
Mykola Pokhylets
c139d1b1a7 Make IsolatedDeinit non-experimental 2024-11-05 12:19:01 +01:00
Allan Shortlidge
161dc2e09e Sema: Rename getUnmetDeclAvailabilityRequirement().
Name it `getUnsatisfiedAvailabilityConstraint()` to match
`AvailabilityConstraint`.
2024-11-04 19:58:28 -08:00
Allan Shortlidge
4fa02cd11a AST: Rename UnmetAvailabilityRequirement to AvailabilityConstraint.
Also, pull its definition out into a separate header.
2024-11-04 19:58:28 -08:00
Pavel Yaskevich
c5d0916746 [BuildTransform] Fix walkExplicitReturnStmts to walk implicit statements
Some statements introduce implicit braces and other things,
`walkExplicitReturnStmts` cannot ignore that while trying
to find explicit returns.

Resolves: rdar://139235128
2024-11-04 16:42:50 -08:00
Sima Nerush
13dae34d45 Merge pull request #77227 from simanerush/0449-remove-flag
[SE-0449] Remove `GlobalActorInferenceCutoff` feature flag.
2024-11-04 16:24:34 -08:00
Hamish Knight
36f2f46c83 Merge pull request #77345 from hamishknight/opaque-cache
[AST] Use cached deserialized decl in `getOpaqueResultTypeDecl`
2024-11-05 00:17:39 +00:00
Sima Nerush
4ee76c55b4 [SE-0449] Remove GlobalActorInferenceCutoff feature flag. 2024-11-04 12:15:55 -08:00
Hamish Knight
7061a20edd [CS] Remove ConstraintSystem::getVarType
The logic here for completion wasn't actually
helping things since it would result in adding the
var overload to the system, which would result
in an ErrorType binding. We could turn the ErrorType
into a placeholder when resolving the overload,
but the simpler solution is to just allow CSGen
to turn the reference into a PlaceholderType. This
matches what we do for regular solving, and fixes
a crash with an IUO completion.

rdar://89369091
2024-11-04 17:08:20 +00:00
Hamish Knight
152812cc86 [AST] Use cached deserialized decl in getOpaqueResultTypeDecl
Mangling and looking up the opaque result type decl
for serialized decls is a fairly expensive
operation. Instead, fallthrough to the request
which will have a cached value set by deserialization.
This shaves ~30ms off the cached completion for:

```swift
import SwiftUI

struct V: View {
  var body: some View {
    Table(#^CC^#
  }
}
```
2024-11-04 11:29:55 +00:00
Allan Shortlidge
c044321697 Sema: Replace TypeChecker::checkConformanceAvailability().
Adopt `getUnmetDeclAvailabilityRequirement()` instead.
2024-11-03 17:20:56 -08:00
Allan Shortlidge
7b5757b29b Sema: Replace TypeChecker::checkDeclarationAvailability().
Adopt `getUnmetDeclAvailabilityRequirement()` instead.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
0377ef4afd Sema: Take a SourceLoc in getUnmetDeclAvailabilityRequirement().
Introduce a convenience overload for the common case where the
AvailabilityContext must first be looked up by source location.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
ca34f42419 AST: Introduce UnmetAvailabilityRequirement::isConditionallySatisfiable(). 2024-11-03 11:37:01 -08:00
Allan Shortlidge
5dc654c73b AST: Move UnmetAvailabilityRequirement to Availability.h.
This type will need to be used outside of Sema.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
a95891cbb8 Sema: Rename checkDeclarationAvailability().
Type checker functions with the prefix "check" usually check some requirement
and then diagnose it if it isn't satisfied. `checkDeclarationAvailability()`
doesn't diagnose on its own, so it should be named differently.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
d62a9cbd87 Sema: Make isDeclarationUnavailable() static.
It's now unused outside of `TypeCheckAvailability.cpp`.
2024-11-03 11:37:01 -08:00
Allan Shortlidge
e089c5850e Merge pull request #77258 from tshortli/discard-overloads-in-unavailable-extensions-in-constraint-solver
Sema: Correctly treat overloads in unavailable extensions as unavailable
2024-11-02 22:56:47 -07:00
Allan Shortlidge
98b34c6ff6 Sema: Correctly treat overloads in unavailable extensions as unavailable.
Instead of checking for unavailability attributes directly in the solver, which
does not correctly handle members of unavailable extensions, query
`checkDeclarationAvailability()` instead. By using the same underlying logic as
the availability checker the constraint solver can be confident in the accuracy
of this result.

Resolves rdar://87403752.
2024-11-02 17:15:11 -07:00
Rintaro Ishizaki
d4db99ce9d [Parse] Remove unnecessary dependencies to Parser.h
C++ swift::Parser is going to be replaced with SwiftParser+ASTGen.
Direct dependencies to it should be removed. Before that, remove
unnecessary '#include "swift/Parse/Parser.h"' to clarify what actually
depends on 'swift::Parser'.

Split 'swift::parseDeclName()' et al. into the dedicated files.
2024-11-02 01:23:59 -07:00
Allan Shortlidge
f4df1a8e52 Merge pull request #77316 from tshortli/unavailable-in-embedded
Sema: Allow calls to @_unavailableInEmbedded functions in compatible contexts
2024-11-01 17:16:22 -07:00
Pavel Yaskevich
0c364a79a6 Merge pull request #77332 from xedin/inout-regression-after-delay
[CSBindings] Don't delay bindings inferred through `inout` conversion
2024-11-01 15:13:26 -07:00
Pavel Yaskevich
8b2a3a42d6 Merge pull request #77226 from JanBaig/issue-macro-diag
[Diagnostics] Extend fix-it logic for misssing arguments without parenthesis
2024-11-01 15:12:58 -07:00
Allan Shortlidge
6ac729ea41 Sema: Allow calls to @_unavailableInEmbedded functions in compatible contexts.
Treat `@_unavailableInEmbedded` as if it were `@available(Embedded,
unavailable)` and apply platform compatibility logic in the availability
checker. Revert back to disallowing calls to universally unavailable functions
(`@available(*, unavailable)`) in all contexts.
2024-11-01 13:03:30 -07:00
Allan Shortlidge
d2f77f45c1 Merge pull request #77341 from tshortli/unavailable-types-in-unavailable-signatures
Sema: Fixes for availability checking in unavailable contexts
2024-11-01 12:40:24 -07:00
Hamish Knight
df7cac3114 Merge pull request #59141 from hamishknight/wrapping-paper
[AST] Remove ParenType
2024-11-01 16:52:23 +00:00