Commit Graph

28850 Commits

Author SHA1 Message Date
Kathy Gray
ce9368c39c Diagnostics change for ambiguous overloads previously specifying 'this'
Updates the message to use the type or ValueDecl instead of saying 'this' on 'Found this candidate' messages to provide more information where possible in selecting overloads

Per comment during draft iteration uses getInterfaceType and adds removeSelfParam to ValueDecl.t

Migrate to calling interfaceType and remove SelfParam

Update tests to reflect type information in ambiguity resolution

All but 5 tests now passing. Those 5 either do not refer to overloading errors or do pass even when modified to accept type specification

Move implementation to ValueDecl now that tests largely pass
2025-10-10 17:46:22 +01:00
Kathy Gray
97dfc82255 Update tests to reflect type information in ambiguity resolution
All but 7 tests now passing. Those 7 tests either do not refer to these circumstances or do not seem to pass even when modified to accept type specifications.
2025-10-10 17:46:22 +01:00
Kathy Gray
84ef25afbc Migrate to calling interfaceType and remove SelfParam
Migrate more tests
2025-10-10 17:46:22 +01:00
Kathy Gray
5e407bce89 Diagnostics change for ambiguous overloads previously specifying 'this'
Updates the message to use the type or ValueDecl instead of this on previous 'Found this candidate' messages
Note: doees not yet change all test cases so more tests are failing

Improve Diagnostic message on overload ambiguitiy

Remove messages that say 'found this candidate' in favour of providing the type for the candidate to aid in selection when the candidates are presented in a dialogue window.

Fix more tests
2025-10-10 17:46:22 +01:00
Pavel Yaskevich
798b50b38a [Concurrency] Fix @Sendable closures not inferring nonisolated(nonsending)
If there are no explicit concurrency attributes, isolated parameters,
or captures associated with the closure it should infer `nonisolated(nonsending)`
for the parent conversion injected by the solver (this conversion is injected
because the solver cannot check captures to elide it).

The change pushes `isIsolationInferenceBoundaryClosure` check down
with added benefit of getting preconcurrency context from the parent.
2025-10-10 17:46:22 +01:00
John McCall
e5b6a88c5e Merge pull request #84181 from rjmccall/isolation-fixes
Isolation fixes for closures and defer bodies
2025-09-10 08:39:09 -04:00
Hamish Knight
f8218e3254 Merge pull request #83777 from hamishknight/ext-cleanup
[Sema] Clean up extension binding a little
2025-09-10 09:37:20 +01:00
Hamish Knight
872176bdd1 Merge pull request #84149 from hamishknight/case-and-pat
A few pattern cleanups + fixes
2025-09-10 09:36:22 +01:00
Slava Pestov
0063c3c522 Merge pull request #84131 from slavapestov/remove-covariant-result-type-post-cleanup
Sema: Clean up getTypeOfMemberReference() and buildMemberRef()
2025-09-10 01:39:38 -04:00
Slava Pestov
60246a2889 Sema: Further split up getTypeOfMemberTypeReference() 2025-09-09 18:58:10 -04:00
Slava Pestov
68be47f166 Sema: Re-organize some logic in getTypeOfMemberReference() 2025-09-09 18:58:10 -04:00
Slava Pestov
13b4b03aca Sema: Fix crash in IgnoreAssignmentDestinationType::diagnoseForAmbiguity() 2025-09-09 18:58:10 -04:00
Slava Pestov
45ec809330 Sema: Clean up property wrapper application in getTypeOfMemberReference()
If there are no property wrappers to unwrap, we don't need to take the
FunctionType apart and put it back together again.
2025-09-09 18:58:10 -04:00
Slava Pestov
6dc2e7558d Sema: Don't modify openedType in getMemberReferenceTypeFromOpenedType() 2025-09-09 18:58:09 -04:00
Slava Pestov
b6676fa38f Sema: Move ConstructorDecl hack out of getMemberReferenceTypeFromOpenedType() 2025-09-09 18:58:09 -04:00
Slava Pestov
27c52eb4a9 Sema: Clean up buildOtherConstructorRef() 2025-09-09 18:58:09 -04:00
Slava Pestov
9e2d4c520f Sema: More DynamicSelfType cleanup 2025-09-09 18:58:09 -04:00
Hamish Knight
17fe3de8c7 [Sema] Clean up extension binding a little
- Turn `BindExtensionsForIDEInspectionRequest` into the main extension
binding request.
- Change `ExtendedNominalRequest` such that it's no longer what
extension binding calls into to do the name lookup, instead it calls
directly into `computeExtendedNominal`. `getExtendedNominal` can
then be the entrypoint for `ExtendedNominalRequest` and assumes that
extension binding has already run. This avoids needing to fake the
dependency relationship in the DeclChecker.
2025-09-09 23:18:52 +01:00
Hamish Knight
d9d0b2e6a3 [Sema] Make extension binding lazy for SourceLoader
This will mainly be useful once extension binding is fully
requestified, but even now it's a good idea to ensure module loading
isn't kicking name lookup.
2025-09-09 23:18:52 +01:00
John McCall
367520cd3f Fix two bugs with the isolation of defer bodies.
The first bug is that we weren't computing isolation correctly for
nested defers. This is an unlikely pattern of code, but it's good to fix.

The second bug is that getActorIsolationOfContext was looking through
defers, but getActorIsolation itself was not. This was causing defer
bodies to be emitted in SILGen without an isolation parameter, which
meant that #isolation could not possibly provide the right value. Fixing
this involves teaching SILGen that non-async functions can have
nonisolated(nonsending) isolation, but that's relatively straightforward.

This commit doesn't fix #isolation or adequately test SILGen, but that'll
be handled in a follow-up.
2025-09-09 14:26:57 -04:00
Hamish Knight
10ed17549c [CS] Set the naming pattern in markInvalid
This normally gets populated by successful type-checking, we still want
to populate it if we fail though to avoid attempting to type-check the
parent statement again.
2025-09-09 13:48:40 +01:00
Hamish Knight
84847bcd06 [Sema] Relax a check in VarDeclUsageChecker
We don't want to just check the first pattern, we're interested in
the first pattern that binds the given variable. That can be determined
by checking if it's canonical or not.
2025-09-09 13:48:40 +01:00
Hamish Knight
1983172278 [Sema] Rename bindSwitchCasePatternVars -> diagnoseCaseVarMutabilityMismatch
Now that we wire up the parents up-front, this no longer needs to
set the parents. As such, remove the logic and rename to reflect the
fact that it now just diagnoses mutability mismatches.
2025-09-09 13:48:40 +01:00
Hamish Knight
c02c69a783 [AST] Introduce CaseStmt::createImplicit
This allows us to re-use the same logic to create the case body
variables.
2025-09-09 13:48:40 +01:00
Hamish Knight
245e2874ae [AST] Eagerly wire up VarDecl parents when creating CaseStmt
Rather than waiting until type-checking, we can set the parents
immediately when we create the CaseStmt. This requires fixing up
NamingPatternRequest to look at the recursive parent statement as
now the VarDecl may have a variable parent.
2025-09-09 13:48:40 +01:00
Hamish Knight
84befd43ab [AST] Make case body variables for CaseStmt non-optional
We don't really care about the distinction between empty and nil here.
2025-09-09 13:48:40 +01:00
Hamish Knight
805b6d9c39 [CS] Remove some dead code in visitCaseItemPattern
We don't wire up the parent variables until after type-checking, and
`recordInferredSwitchCasePatternVars` already handles joining the
pattern types, so we can remove this.
2025-09-09 13:48:40 +01:00
Allan Shortlidge
0c5eac5c3e Sema: Downgrade missing import diagnostics for key paths.
For now, downgrade the `MemberImportVisibility` diagnostics introduced in
https://github.com/swiftlang/swift/pull/83934 to warnings.

Resolves rdar://160146503.
2025-09-08 16:15:49 -07:00
Slava Pestov
af3b5e8e3b Sema: Clean up getMemberReferenceTypeFromOpenedType() 2025-09-08 10:31:49 -04:00
Slava Pestov
6b2e5985d6 Sema: Small cleanup in getMemberReferenceTypeFromOpenedType() 2025-09-08 10:31:49 -04:00
Slava Pestov
ab4e754ef9 Sema: Don't stick CovariantReturnConversionExpr around property access with DynamicSelfType base
It could be that refTy->hasDynamicSelfType() is true whereas
varDecl->getValueInterfaceType()->hasDynamicSelfType() is false.
This happens if the base of the access is dynamic Self, so the
refTy is (Self) -> @lvalue Int or whatever.

Note that replaceDynamicSelfType() behaves correctly in this case;
it leaves that Self in place, because it's in contravariant
position.

However, the other place where we check the condition would then
form a nonsensical CovariantReturnConversionExpr around the result
of the access, even though no conversion was necessary here; the
type of the returned value does not involve Self.

Simplify this logic further with the correct condition.

Fixes rdar://159531634.
2025-09-08 10:31:27 -04:00
Hamish Knight
4d1a04b856 [CS] Remove AllowUnresolvedTypeVariables (#84146)
This has been unused for a while now.
2025-09-07 18:36:01 +01:00
Hamish Knight
23560df5f4 [CS] Remove AllowUnresolvedTypeVariables
This has been unused for a while now.
2025-09-07 12:17:18 +01:00
Hamish Knight
cac98f3a18 Merge pull request #84142 from hamishknight/for-none
[CS] NFC: Remove `CTP_ForEachStmt`
2025-09-06 22:43:28 +01:00
Hamish Knight
71d825dcb8 [CS] NFC: Remove CTP_ForEachStmt 2025-09-05 22:20:28 +01:00
Slava Pestov
aa3a0756f4 Merge pull request #84115 from slavapestov/remove-covariant-result-type
Remove TypeBase::replaceCovariantResultType()
2025-09-05 07:40:34 -04:00
Slava Pestov
55082c4eea Sema: Split off buildVarMemberRef() from buildMemberRef() 2025-09-04 18:07:46 -04:00
Slava Pestov
1ddcdc74d4 Sema: Convert conditional into an assert 2025-09-04 17:54:00 -04:00
Slava Pestov
250e3fd08b Sema: Split off buildStaticCurryThunk() from buildMemberRef() 2025-09-04 17:53:14 -04:00
Slava Pestov
d81fbd6c63 Sema: Split off buildDynamicMemberRef() from buildMemberRef() 2025-09-04 17:46:40 -04:00
Slava Pestov
853f50c90d Sema: Remove usage of replaceCovariantResultType() 2025-09-04 17:24:07 -04:00
Allan Shortlidge
b047396246 AST: Use availability to control decl visibility in public swiftinterfaces.
Declarations that are unavailable at runtime because of an `@available`
attribute referencing a custom domain that was imported `@_spiOnly` should be
hidden from public swiftinterface files in `-library-level=api` modules. For
remaining declarations that do get printed in the public swiftinterface, skip
printing any `@available` attribute that refers to the domains from those
`@_spiOnly` dependencies. This allows API developers to control declaration
visibility using availability defined by another module.

Resolves rdar://156512028.
2025-09-04 12:32:19 -07:00
Allan Shortlidge
ddca4b7404 Sema: Refactor diagnoseValueDeclRefExportability().
This is meant to make it clearer how exceptions for each `DisallowedOriginKind`
are handled.
2025-09-04 09:13:23 -07:00
Konrad `ktoso` Malawski
385938f731 Merge pull request #84072 from swiftlang/wip-nonisolated-thunks-retain-semantics 2025-09-04 08:29:26 +09:00
Hamish Knight
7fb532e4e6 Merge pull request #83776 from hamishknight/the-diags-never-stop-no
[Diags] Allow multiple in-flight diagnostics
2025-09-03 19:59:44 +01:00
Allan Shortlidge
d8cbb57304 Merge pull request #84069 from tshortli/available-attr-exportability-reason
Sema: Introduce an `ExportabilityReason` for availability attributes
2025-09-03 09:07:02 -07:00
Pavel Yaskevich
4236db7d30 Merge pull request #84066 from xedin/rdar-129359362
[TypeChecker] Avoid checking lazy property accessors if they haven't …
2025-09-03 07:14:54 -07:00
Konrad Malawski
ced1756142 [Concurrency/Distributed] ensure distributed thunks are @concurrent
Otherwise the "nonisolated nonsending by default" mode blows up as
distributed thunk signatures dont match expectations.

This undoes the fix from https://github.com/swiftlang/swift/pull/83940
and applies the fix on the synthesis side of the distributed thunks,
such that they are @concurrent always -- which keeps their old semantics
basically, regardless of what "default" mode we have.
2025-09-03 18:54:09 +09:00
Allan Shortlidge
91ddf93d0f Sema: Introduce an ExportabilityReason for availability attributes.
This allows diagnostics to be more precise and will also support logic that
allows for special cases for `@available` attributes in exportability checking.

Also fixes a bug where the exportability of `@available` attributes attached to
extensions were diagnosed twice for slightly differing reasons.
2025-09-02 23:13:08 -07:00
Pavel Yaskevich
6e7de5c1e0 [TypeChecker] Avoid checking lazy property accessors if they haven't been synthesized yet
Ttheir availability is going to match the property itself.
This is a workaround for lazy type-checking because synthesis
of accessors for such properties requires a reference to
`self` which won't be available because pattern binding
for the variable was skipped.

Resolves: rdar://129359362
Resolves: rdar://159463230
Resolves: https://github.com/swiftlang/swift/issues/84041
2025-09-02 17:12:28 -07:00