Commit Graph

28352 Commits

Author SHA1 Message Date
Allan Shortlidge
b3f6421091 AST: Remove DeclAttributes::getPotentiallyUnavailable().
This utility duplicated logic that is now meant to be encapsulated by
`getUnsatisfiedAvailabilityConstraint()`.
2024-11-19 17:19:51 -08:00
Allan Shortlidge
6bf0e628be AST: Rename AvailabilityContext::getDefault() to forInliningTarget().
Mirrors the factory methods on `AvailabilityRange`.
2024-11-19 17:19:51 -08:00
Nate Chandler
bdf662a871 [CoroutineAccessors] Default impls are transparent
Like every other method entry in the default witness table, the default
implementations of the `read2` and `modify2` accessors that just call
`read` and `modify` respectively should be transparent.
2024-11-19 15:52:24 -08:00
Nate Chandler
8eaae59c3b [NFC] AST: Moved impl from Sema.
Now that the function is declared in AST, it should be implemented
there.
2024-11-19 15:52:24 -08:00
Pavel Yaskevich
9912c4405d Merge pull request #77653 from xedin/revert-BindingSet-isViable-changes
[CSBindings] Revert changes in `BindingSet::isViable`
2024-11-19 14:22:57 -08:00
Slava Pestov
1ecba36e76 Sema: Cache Solution::getTotalMemory()
This is showing up in performance profiles.
2024-11-19 16:04:57 -05:00
Pavel Yaskevich
4a9d20d877 Merge pull request #77684 from xedin/switch-swiftinterface-version-to-use-Version
[Frontend] Switch `-interface-compiler-version` to `Version`
2024-11-19 08:56:58 -08:00
Hamish Knight
51dadb03f0 Merge pull request #77691 from hamishknight/fix-sendable-keypath-dynamic-member
[Completion] Fix Sendable KeyPath dynamic member subscripts
2024-11-19 09:11:30 +00:00
Meghana Gupta
5b5acc64e0 Promote Nonescapable types to a language feature 2024-11-18 18:09:17 -08:00
JanBaig
8af3aef7c4 [CSGen] Fix compiler crash when property wrapper applied to a param lacks wrappedValue initializer 2024-11-18 19:23:28 -05:00
Pavel Yaskevich
7c8000b3a5 [Frontend] Switch -interface-compiler-version to Version
`SWIFT_COMPILER_VERSION` has more than 4 components and it's
easier to use `Version` API over `VersionTuple` as well.
2024-11-18 15:11:36 -08:00
Slava Pestov
872f242e93 Merge pull request #77683 from slavapestov/opened-type-optzn
Sema: Clean up and optimize interface type opening
2024-11-18 17:40:52 -05:00
Slava Pestov
473cb0b837 Sema: Downgrade nonisolated lazy error to warning until -swift-version 6
Fixes rdar://139238003.
2024-11-18 17:24:58 -05:00
Hamish Knight
d877d05524 [Completion] Fix Sendable KeyPath dynamic member subscripts
Introduce `getKeyPathTypeForDynamicMemberLookup`
which returns the KeyPath type, and can be used
from both `RootAndResultTypeOfKeypathDynamicMemberRequest`
and `isValidKeyPathDynamicMemberLookup`. This ensures
we look to the superclass for e.g protocol compositions
with `Sendable`. This also means we now return an
interface type, which is what the client of
`RootAndResultTypeOfKeypathDynamicMemberRequest`
wanted anyway.

rdar://138418296
2024-11-18 22:22:43 +00:00
Pavel Yaskevich
26e888e45e Merge pull request #77652 from xedin/issue-77644
[CSSimplify] Handle invalid type specializations
2024-11-18 10:14:14 -08:00
Slava Pestov
9a93a8a420 Sema: Fix latent bug in CSRanking.cpp
I believe openedType1 should be computed using innerDC1 not innerDC2.
2024-11-18 12:31:36 -05:00
Slava Pestov
06b4953b85 Sema: Remove a usage of QueryTypeSubstitutionMap 2024-11-18 11:40:39 -05:00
Slava Pestov
09df48f9fb Sema: Remove DenseMap usage when opening types 2024-11-18 11:40:38 -05:00
Hamish Knight
4946c799af [AST] Remove ModuleDecl::addFile
Rather than exposing an `addFile` member on
ModuleDecl, have the `create` members take a
lambda that populates the files for the module.
Once module construction has finished, the files
are immutable.
2024-11-17 14:17:20 +00:00
Hamish Knight
e2ba36f7f4 Factor out ModuleDecl overload of import resolution
This resolves imports for the entire module.
2024-11-17 14:17:20 +00:00
Slava Pestov
47156e006b AST: Introduce ProtocolConformanceRef::forAbstract() 2024-11-16 16:16:06 -05:00
Pavel Yaskevich
d01c9cbaee [CSBindings] Revert changes in BindingSet::isViable
This change although correct cases performance issues
in some scenarios.
2024-11-15 15:46:29 -08:00
Slava Pestov
3b5c2a18b7 Sema: Fix yet another call to SubstitutionMap::getProtocolSubstitutions()
The conforming type didn't match the conformance, which is going to
be flagged by SubstitutionMap::verify().
2024-11-15 17:26:34 -05:00
Slava Pestov
4d87f25c81 Sema: Fix another call to SubstitutionMap::getProtocolSubstitutions()
The conforming type didn't match the conformance, which is going to
be flagged by SubstitutionMap::verify().
2024-11-15 17:26:34 -05:00
Slava Pestov
5d40673112 Sema: Fix call to SubstitutionMap::getProtocolSubstitutions()
The conforming type didn't match the conformance, which is going to
be flagged by SubstitutionMap::verify().
2024-11-15 17:26:33 -05:00
Slava Pestov
1fc2cd9fad Sema: Remove some pointless passing around of ModuleDecl 2024-11-15 17:26:33 -05:00
Pavel Yaskevich
30c196118e [CSSimplify] Handle invalid type specializations
If the base type of the specialization is invalid,
the AST node is going to be replaced with `ErrorExpr`.

We need to handle that gracefully when attempting
to apply specialization in such situations.

Resolves: https://github.com/swiftlang/swift/issues/77644
2024-11-15 11:10:51 -08:00
Slava Pestov
47196614e6 Merge pull request #77595 from slavapestov/fix-rdar139747886
Sema: Fix request cycle due to unnecessary Sendable check with static method
2024-11-15 12:02:16 -05:00
Rintaro Ishizaki
0f1b650716 [AST] MacroRoleAttr accept any 'Expr *' as the conformances arguments 2024-11-14 15:10:11 -08:00
nate-chandler
6b43670258 Merge pull request #77603 from nate-chandler/general-coro/20241113/1
[CoroutineAccessors] Several small fixes.
2024-11-14 07:06:35 -08:00
Nate Chandler
430307a29d [CoroutineAccessors] Don't synthesize overrides.
Such storage decls don't actually have entries in the wtable.
2024-11-13 21:33:08 -08:00
Nate Chandler
9bbb8e8e70 [CoroutineAccessors] Set field on RequirementMatch
The WitnessSubstitutions field must be set to the appropriate
substitution map.
2024-11-13 21:33:07 -08:00
Doug Gregor
11ed132614 [Clang importer + macros] Handle name lookup and type checking for expanded macros
Introduce a number of fixes to allow us to fully use declarations that
are produced by applying a peer macro to an imported declarations.
These changes include:
* Ensuring that we have the right set of imports in the source file
containing the macro expansion, because it depends only on the module
it comes from
* Ensuring that name lookup looks in that file even when the
DeclContext hierarchy doesn't contain the source file (because it's
based on the Clang module structure)

Expand testing to be sure that we're getting the right calls,
diagnostics, and generated IR symbols.
2024-11-13 21:21:56 -08:00
Pavel Yaskevich
7c35c881a9 [CSSimplify] CGFloat-Double: Fix ambiguity when assigning CGFloat to double property/variable
Situations like:
```
  let _: Double = <<CGFloat>>
  <var/property of type Double> = <<CGFloat>>
```

Used to be supported due to an incorrect fix added in
diagnostic mode. Lower impact here means that right-hand
side of the assignment is allowed to maintain CGFloat
until the very end which minimizes the number of conversions
used and keeps literals as Double when possible.

Resolves: rdar://139675914
2024-11-13 13:45:56 -08:00
Slava Pestov
59ba1a0294 Sema: Fix request cycle due to unnecessary Sendable check with static method
Fixes rdar://139747886.
2024-11-13 15:16:28 -05:00
Hamish Knight
1965f96aff Merge pull request #77554 from hamishknight/statement-misc-diags
[Sema] A couple more MiscDiagnostics cleanups/fixes
2024-11-13 18:04:46 +00:00
nate-chandler
11f9ea7529 Merge pull request #77572 from nate-chandler/rdar139759304
[BitwiseCopyable] Permit conformance in overlay.
2024-11-13 00:07:56 -08:00
Meghana Gupta
184058e4ac Merge pull request #76588 from meg-gupta/lifetimeremovefeatureguardincompiler
Remove feature guard on lifetime dependence inference
2024-11-12 18:38:41 -08:00
Nate Chandler
80390ce1d1 [BitwiseCopyable] Permit conformance in overlay.
rdar://139759304
2024-11-12 16:54:16 -08:00
Hamish Knight
9e5a105644 Merge pull request #77561 from hamishknight/completion-feedback
[Sema] NFC: Address review feedback on #77537
2024-11-13 00:25:41 +00:00
Allan Shortlidge
1e6effd0aa Merge pull request #77563 from tshortli/rename-type-refinement-context
AST: Rename TypeRefinementContext to AvailabilityScope
2024-11-12 15:21:19 -08:00
Alexis Laferrière
b5bf21758e Merge pull request #77538 from xymus/dont-warn-submodules-reexport
Sema: fix reporting reexporting submodules imports as unused in API
2024-11-12 13:59:39 -08:00
Allan Shortlidge
239720897a AST: Rename TypeRefinementContext to AvailabilityScope. 2024-11-12 11:34:25 -08:00
nate-chandler
359f898bbf Merge pull request #77546 from nate-chandler/general-coro/20241110/1
[CoroutineAccessors] Ban read+_read and modify+_modify.
2024-11-12 10:40:52 -08:00
Hamish Knight
d8ec851c93 [Sema] NFC: Address review feedback on #77537 2024-11-12 18:35:17 +00:00
Hamish Knight
b644cd87a9 [Sema] Ensure performStmtDiagnostics is called for CaseStmts
Previously we would check if we have a SwitchStmt,
and apply diagnostics such as `checkExistentialTypes`
to the CaseStmts individually. This however would
have been missed for `catch` statements. The change
to consistently call `performStmtDiagnostics` in
closures fixed this for `do-catch`'s in closures,
this commit fixes it for those outside of closures.
Because this is source breaking, the existential
diagnostic is downgraded to a warning until Swift
7 for catch statements specifically.

While here, also apply the ambiguous where clause
diagnostic to `catch` statements.
2024-11-12 18:26:54 +00:00
Hamish Knight
964ba731bb [Sema] Inherit ExprAvailabilityWalker from BaseDiagnosticWalker
Simplifies things a tiny amount, and ensures we
don't attempt to walk into non-PatternBindingDecls,
same as other MiscDiagnostic passes. I don't think
this currently makes a difference since I don't
believe we have any interesting cases where a Decl
is nested in an Expr without an intermediate Stmt,
but it's the right thing to do regardless.
2024-11-12 18:26:53 +00:00
Hamish Knight
6e09a4e2ae [Sema] NFC: Remove shouldWalkIntoClosure
This used to have some logic when multi-statement
closures were type-checked differently, it's always
true now.
2024-11-12 18:26:53 +00:00
Hamish Knight
9a339d937e [Sema] Clean up diagnoseStmtAvailability a bit
The walker here is really doing 2 completely
separate things, split it into 2 walkers. For
ExprAvailabilityWalker, we just want to recursively
continue walking looking for any sub-expressions
to diagnose. For StmtAvailabilityWalker we only
want to walk the top-level statement, and are
only interested in any TypeReprs it has. This lets
us get rid of the special handling for BraceStmt.
2024-11-12 18:26:53 +00:00
Hamish Knight
d2b298bd4b [CS] Avoid doing performStmtDiagnostics in CSApply
Instead, ensure we walk into expressions in
SyntacticDiagnosticWalker, allowing
`performStmtDiagnostics` to be called there for
all statements present in the target. This avoids
a case where we'd double diagnose.

While here, inherit the walker from
BaseDiagnosticWalker.
2024-11-12 18:26:53 +00:00