Commit Graph

9 Commits

Author SHA1 Message Date
Hamish Knight
b6a09d1b33 Reapply: [CS] Make sure macro arguments go through coerceCallArguments
Previously we would avoid rewriting the arguments in CSApply, but
that can result in incorrect behavior in MiscDiagnostics passes, e.g
incorrectly treating all closure arguments as escaping. Make sure
we rewrite the arguments as we would in regular type-checking.

rdar://148665502
2025-04-16 19:22:52 +01:00
Hamish Knight
475e02a381 Revert "[CS] Make sure macro arguments go through coerceCallArguments" 2025-04-15 18:44:14 +01:00
Hamish Knight
b82f95b508 [CS] Make sure macro arguments go through coerceCallArguments
Previously we would avoid rewriting the arguments in CSApply, but
that can result in incorrect behavior in MiscDiagnostics passes, e.g
incorrectly treating all closure arguments as escaping. Make sure
we rewrite the arguments as we would in regular type-checking.

rdar://148665502
2025-04-07 16:29:50 +01:00
Hamish Knight
34f809055a [Sema] Downgrade implicit self diag to warning for macro args
We previously missed diagnosing this for macro
args, fixing it turned out to be a bit more source
breaking than initially thought though, so downgrade
to a warning until Swift 7.

rdar://141963700
2025-01-10 14:36:29 +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
Hamish Knight
ed1589de4c [Sema] Walk MacroExpansionDecls in BaseDiagnosticWalker
I missed this in my previous PR, but this is needed
to ensure we visit macro arguments for macro expansion
exprs that have substitute MacroExpansionDecls since
we prefer to visit the arguments on the decl once
the expression has been expanded.
2024-11-12 18:26:53 +00:00
Hamish Knight
1b5ed65a57 [Sema] Consistently run MiscDiagnostics on macro arguments
Previously we would only run MiscDiagnostics
passes on macro arguments for some statement
diagnostics, update the expression walkers that
inherit from BaseDiagnosticWalker such that we
consistently do MiscDiagnostics on macro arguments.
2024-11-11 19:29:59 +00:00
Hamish Knight
9c3b8a6256 [CS] Delay macro expansion until end of CSApply
Attempting to expand macros in the middle of
CSApply can result in attempting to run
MiscDiagnostics within a closure that hasn't yet
had the solution applied to the AST, which can
crash the implicit-self diagnostic logic. Move
the expansion to the end of CSApply such that
expansions are type-checked along with local
decls, ensuring it's run after the solution has
been applied to the AST.

rdar://138997009
2024-11-09 00:24:53 +00:00
Hamish Knight
6352b01635 [Sema] Avoid double-diagnosing in macro expansions
Avoid walking into macro expansions for
MiscDiagnostics, the expansions will instead be
visited when they're type-checked on their own.
2024-11-09 00:24:52 +00:00