Commit Graph

28404 Commits

Author SHA1 Message Date
Doug Gregor
68914528db Make (Raw)ConformanceIsolation requests work on the normal protocol conformance
Reduce the burden on the evaluator's caching mechanism by handling the
unwrapping of a conformance down to its normal protocol conformance
outside of these requests. Thanks, Slava!
2025-06-04 14:26:18 -07:00
Doug Gregor
332151aa69 Only emit the non-sendable metatype capture diagnostic under region-based isolation
We effectively suppress sendable diagnostics when region-based
isolation is disabled, and RBI is enabled whenever strict concurrency
checking is enabled. So, suppress this diagnostic when RBI is enabled.

Fixes rdar://152583759.
2025-06-04 09:46:02 -07:00
Slava Pestov
c61a4fe333 Merge pull request #81949 from slavapestov/missing-part-of-se-0346
Sema: Implement missing part of SE-0346
2025-06-04 09:24:19 -04:00
Doug Gregor
9957f5240f Merge pull request #81933 from DougGregor/break-isolated-conformance-reference-cycle 2025-06-03 14:54:16 -07:00
Slava Pestov
185a91d955 Sema: Handle nested compositions and parameterized protocols in diagnoseRetroactiveConformances() 2025-06-03 17:28:19 -04:00
Slava Pestov
cd5ecbee16 Sema: Implement missing part of SE-0346
The proposal states that this should work, but this was never
implemented:

    protocol P<A> {
      associatedtype A
    }

    struct S: P<Int> {}

- Fixes https://github.com/swiftlang/swift/issues/62906.
- Fixes rdar://91842338.
2025-06-03 17:28:19 -04:00
Pavel Yaskevich
b189b8a320 Merge pull request #81936 from xedin/improve-optional-wrappedValue-mismatch-diagnostics
[CSSimplify] Fix `matchDeepEqualityTypes` to allow fixing of optionals
2025-06-03 09:19:50 -07:00
Allan Shortlidge
adedf15270 Merge pull request #81922 from tshortli/visionos-availability-remap-regression
AST/Sema: Fix remapping of iOS availability in diagnostics for visionOS
2025-06-03 04:58:31 -07:00
Hamish Knight
d00a3b5764 Merge pull request #81901 from hamishknight/hastype
[CS] Check `hasType` in `isPlaceholderVar`
2025-06-03 11:01:54 +01:00
Pavel Yaskevich
7305275dbd [CSSimplify] Produce tailored fixes for a few generic argument mismatches
- Mismatch in tuple element position should reference whole tuple
  with a note for mismatch position;
- Situations where optional object type is not a class but matched
  against `AnyObject` have a tailored fix.
2025-06-03 00:49:06 -07:00
Pavel Yaskevich
27c28d4d64 [CSSimplify] Fix matchDeepEqualityTypes to allow fixing of optionals
Attempting to propagate generic argument failures up is not always
reliable, `matchDeepEqualityTypes` should avoid using `TMF_ApplyingFix`
while dealing with optionals and instead let `repairFailures` decide
whether to use generic arguments mismatch fix to a more general one.
2025-06-03 00:48:59 -07:00
Pavel Yaskevich
65e83a8bb1 [CSSimplify] Increase impact of a generic argument mismatch if mismatch is contextual
If generic arguments mismatch ends up being recorded on the result
of the chain or `try` expression it means that there is a contextual
conversion mismatch.

For optional conversions the solver currently generates a disjunction
with two choices - bind and optional-to-optional conversion which is
anchored on the contextual expression. If we can get a fix recorded
there that would result in a better diagnostic. It's only possible
for optional-to-optional choice because it doesn't bind the
variable immediately, so we need to downgrade direct fixes to prevent
`bind` choice from considered better.
2025-06-02 23:49:52 -07:00
Doug Gregor
7472a0ca38 Split conformance isolation request to eliminate a reference cycle
Inference of conformance isolation needs to check whether all of the
witnesses are nonisolated. However, witness checking looks at
conformance isolation. To break this reference cycle, split the
conformance isolation request into two requests: a "raw" request that
looks at explicitly-specified isolation, and the existing one that
also performs inference. The existing one builds on the "raw" one, as
does a separate path for the conformance checker.

Fixes rdar://152461344.
2025-06-02 23:37:58 -07:00
Allan Shortlidge
f4b4dc9889 AST/Sema: Fix remapping of iOS availability in diagnostics for visionOS.
When compiling for visionOS, iOS availability attributes are remapped into the
visionOS availability domain automatically. While the version remapping was
being performed correctly, there was a regression that caused the platform name
to be printed incorrectly in many diagnostics. Whenever an iOS version is
remapped to a visionOS version, availability diagnostics will now present
those versions as visionOS versions instead of iOS versions.

Resolves rdar://146293165.
2025-06-02 17:55:38 -07:00
Pavel Yaskevich
71a8d8d8a4 [CSDiagnostics] Attempt fix-its for contextual generic argument mismatches 2025-06-02 17:39:56 -07:00
Doug Gregor
bfa991d5b3 Merge pull request #81910 from DougGregor/unsafe-string-interpolation
[Strict memory safety] Adjust "unsafe" location for string interpolations
2025-06-02 17:16:10 -07:00
Michael Gottesman
ec48e41d42 Merge pull request #81851 from gottesmm/pr-400c59de66fe5c91648aedb348d84cb7bd8d09f4
[flow-isolation] Allow for initialization of fields of a Global Actor isolated class in its nonisolated inits
2025-06-02 13:21:21 -07:00
Doug Gregor
6ba48f2738 [Strict memory safety] Adjust "unsafe" location for string interpolations
String interpolations can end up being unsafe in the call to
appendInterpolation when it's provided with unsafe types. Move the
location of the proposed "unsafe" out to the string interpolation
itself in these cases, which properly suppresses the warning.

Fixes rdar://151799777.
2025-06-02 12:36:36 -07:00
Pavel Yaskevich
e1e9f04398 Merge pull request #81863 from xedin/using-for-default-isolation-in-file-context
[AST/Sema] SE-0478:  Implement `using` declaration under an experimental flag
2025-06-02 09:56:29 -07:00
Michael Gottesman
501bad55a8 [flow-isolation] Allow for initialization of fields of a Global Actor isolated class in its nonisolated inits
This just involved loosening some checks in the type checker so we stopped
erroring in the type checker and instead deferred to SIL level checks.

rdar://131136194
2025-06-02 08:37:05 -07:00
Hamish Knight
9cad10ddcd [CS] Check hasType in isPlaceholderVar
Patterns assert that a type is set in `getType`, check `hasType`
before querying.

rdar://146383201
2025-06-02 14:33:10 +01:00
Allan Shortlidge
d5ef256b40 Merge pull request #81751 from tshortli/migratable-member-import-visibility 2025-06-01 08:49:01 -07:00
Hamish Knight
82e6d7bbee Merge pull request #81887 from hamishknight/warning-downgrade
[Sema] Downgrade multi-param default inference diag for methods
2025-06-01 02:58:59 +01:00
Pavel Yaskevich
83ac0f5042 [TypeChecker] Disable use of using in macro extensions 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
21ec5924f7 [AST] NFC: Capitalize UsingSpecifier::nonisolated for consistency 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
595c3b3a62 [Concurrency] Start using default isolation set in a file scope
Infer default actor isolation from `using` declaration in the
file scope and use it to override one that is set by `-default-isolation`
flag.
2025-05-31 10:49:50 -07:00
Pavel Yaskevich
36b77116bd [Concurrency] Add a request to retrieve default isolation of a file
The default isolation is computed based on `using` declaration
found in the file, if any.
2025-05-31 10:49:50 -07:00
Hamish Knight
2790ccce89 [Sema] Downgrade multi-param default inference diag for methods
We recently started enforcing this rule for methods, downgrade to a
warning until the next language mode to avoid source compatibility
breakage.
2025-05-31 17:33:58 +01:00
Slava Pestov
f6f0d75263 Merge pull request #81843 from slavapestov/hamish-fuzzer-fixes
Hamish fuzzer fixes
2025-05-31 12:28:56 -04:00
Hamish Knight
dde37c0f01 Merge pull request #81868 from hamishknight/x-of-hearts
Change InlineArray sugar separator `x` -> `of`
2025-05-31 10:05:26 +01:00
Doug Gregor
5c3faaaf92 Merge pull request #81884 from DougGregor/unsafe-for-loop-uses
[Strict memory safety] Show issues with unsafe constructs in the for..in loop
2025-05-30 23:28:53 -07:00
Doug Gregor
1d903b2e6e Merge pull request #81882 from DougGregor/unsafe-implied-conformance
[Strict memory safety] Improve Fix-Its for implied conformances
2025-05-30 22:18:35 -07:00
Doug Gregor
efacceeacd [Strict memory safety] Show issues with unsafe constructs in the for..in loop
We weren't showing the unsafe uses when we determine that a for..in
loop is unsafe. Do so, which generally means complaining about `next()`
being unsafe. Fixes rdar://151237127
2025-05-30 18:44:11 -07:00
Pavel Yaskevich
dad81fb4bc Merge pull request #81779 from xedin/diagnostic-fixes
[Diagnostics] A collection of diagnostic fixes/improvements
2025-05-30 18:37:16 -07:00
Doug Gregor
9af5884555 [Strict memory safety] Improve Fix-Its for implied conformances
The Fix-It was adding @unsafe prior to the extension, which is
incorrect. Make sure we apply @unsafe at the right location for the
explicit conformance.

Fixes rdar://151800162
2025-05-30 17:41:10 -07:00
Holly Borla
214b8d8497 Merge pull request #81860 from hborla/isolated-capture-fixes
[Concurrency] Fix a false-positive metatype capture diagnostic.
2025-05-30 16:05:28 -07:00
Allan Shortlidge
aca604660f AST/Sema: Make MemberImportVisibility a migratable feature.
The migration to `MemberImportVisibility` can be performed mechanically by
adding missing import declarations, so offer automatic migration for the
feature.

Resolves rdar://151931597.
2025-05-30 15:34:08 -07:00
Allan Shortlidge
d258fa783b AST: Simplify the interface of DiagnosticEngine::getBestAddImportFixItLoc().
For clarity, it should just take a `SourceFile`.
2025-05-30 15:34:08 -07:00
Allan Shortlidge
6ea2dd8fac AST/Sema: Remove code adding @_spi to suggested import fix-its.
The was never invoked because inaccessibility due to SPI protection level is
always diagnosed before missing imports are diagnosed. The functionality could
therefore not be tested and should be removed.
2025-05-30 15:34:08 -07:00
Doug Gregor
31fe75bc6b Merge pull request #81853 from DougGregor/objc-selector-effects
Effects: Treat #selector as covering throws/async effects in its operand
2025-05-30 15:28:27 -07:00
Slava Pestov
4e6352d5d9 Sema: Handle bogus DeclNameRefs in translateExprToDeclRefTypeRepr() 2025-05-30 16:27:01 -04:00
Slava Pestov
a3444a0c87 Sema: Handle invalid conformance in ApplyClassifier::classifyApply() 2025-05-30 16:27:01 -04:00
Slava Pestov
d3cf1a42b9 Sema: getBaseIdentifier() => isSimpleName() in synthesizeCodingKeysIfNeededForUnqualifiedLookup() 2025-05-30 16:27:01 -04:00
Slava Pestov
401f527bbb Sema: Don't construct TupleType with InOutType inside 2025-05-30 16:27:01 -04:00
Slava Pestov
0a0019ba76 Sema: Fix null pointer dereference with invalid ParamDecl 2025-05-30 14:44:24 -04:00
Slava Pestov
0e1561f05a Sema: Change a couple of Identifier usages to DeclName instead 2025-05-30 14:43:48 -04:00
Pavel Yaskevich
f31cdb3fec Merge pull request #81852 from xedin/rdar-151943924
[TypeCheckEffects] Fix `AbstractFunction::getType` to look through al…
2025-05-30 11:03:40 -07:00
Holly Borla
f0e77c7814 [Concurrency] Don't diagnose metatype captures in closures that are
isolated to the same actor as the enclosing context.
2025-05-30 10:58:38 -07:00
Doug Gregor
73031240fa Effects: Treat #selector as covering throws/async effects in its operand
Fixes rdar://151968656
2025-05-30 10:50:32 -07:00
Pavel Yaskevich
b12d844fcc [CSSimplify] Remove ad-hoc optional mismatch handling for arguments
Since we have `repairViaOptionalUnwrap`, let's use that to fix
argument/parameter mismatches instead of doing ad-hoc matching.
2025-05-30 09:52:57 -07:00