Commit Graph

7889 Commits

Author SHA1 Message Date
nate-chandler
6cd7974c5a Merge pull request #84405 from nate-chandler/rdar160692694
[DiagnoseStaticExclusivity] Fix this assertion.
2025-09-19 19:37:50 -07:00
Hamish Knight
801cd646ad Merge pull request #84390 from hamishknight/out-of-place
[Sema] Reject placeholders in type resolution for param and result types
2025-09-19 23:19:48 +01:00
Nate Chandler
edf41ceff6 [DiagnoseStaticExclusivity] Fix this assertion.
This function is called in one place in an assertion.  It asserts that
the function in question is the stdlib's swap.  In language mode 6, the
called value may be wrapped in a `function_conversion_expr` for
`@Sendable`.  That's irrelevant for the purposes of this assertion, so
look through such conversions.

rdar://160692694
2025-09-19 11:47:31 -07:00
Hamish Knight
46df852610 [Sema] Reject placeholders in type resolution for param and result types
Not all clients can properly handle the presence of placeholders in
interface types and it doesn't seem worth the complexity for the 
type replacement diagnostic.
2025-09-19 14:22:39 +01:00
Hamish Knight
2769b3398b [test] Update a couple of crasher signatures 2025-09-19 13:13:00 +01:00
Hamish Knight
54ff7b339c [test] Fix up crasher test names
Turns out my code for this has been wrong all this time and hasn't
been been including leading zeros for each hex byte.
2025-09-19 13:11:53 +01:00
nate-chandler
d7d4ba391a Merge pull request #84378 from nate-chandler/rdar160742150
[AllocBoxToStack] Fix missing [nothrow] of apply.
2025-09-18 21:27:23 -07:00
Hamish Knight
ed1a372ed3 Merge pull request #84368 from hamishknight/unresolved 2025-09-18 20:30:54 +01:00
Nate Chandler
30098ad3e0 [AllocBoxToStack] Fix missing [nothrow] of apply.
When specializing an apply which is annotated `[nothrow]`, the resulting
function's apply must still be annotated `[nothrow]`.

rdar://160742150
2025-09-18 12:20:28 -07:00
Hamish Knight
deab5f7970 Merge pull request #84280 from hamishknight/csapply-cleanup
Reapply: [Sema] Remove some unreachable code from CSApply
2025-09-18 14:25:51 +01:00
Hamish Knight
a976af09ba [IDE] Ignore unresolved types in WithSolutionSpecificVarTypesRAII
Make sure we don't try to set an UnresolvedType as a VarDecl interface
type in WithSolutionSpecificVarTypesRAII.
2025-09-17 23:00:27 +01:00
Hamish Knight
aa9aa58cea [Sema] Handle PlaceholderTypes in associated type inference
Avoid attempting to infer an associatedtype as a type that contains
placeholders.
2025-09-17 20:51:06 +01:00
Hamish Knight
d1b8084bc1 [Sema] Avoid resolving placeholders for protocol requirement params
We can't ever have default arguments in protocols anyway.
2025-09-17 20:51:06 +01:00
Hamish Knight
8102e39f39 [CS] Record fix when encountering decl reference with placeholder type
We allow placeholder types in interface types in certain cases to allow
better recovery since we can suggest the inferred type as a replacement.
When referencing those decls though we need to make sure we record a fix
since we cannot form a valid solution with them.
2025-09-17 20:51:06 +01:00
Hamish Knight
ab64e53b0c [Sema] Only resolve PlaceholderType result for FuncDecl with body
We allow resolving PlaceholderType here to allow MiscDiagnostics to
suggest replacing it with the inferred result type, but we won't run
that logic for non-FuncDecls and FuncDecls without bodies. Make sure
we reject placeholders in those cases.
2025-09-17 20:41:20 +01:00
Hamish Knight
78ea361257 [AST] Override getLocFromSource for ParamDecl
Ensure we can still produce a source location even if there's no name
loc, which is the case for e.g enum associated types.
2025-09-17 20:41:20 +01:00
Hamish Knight
cdf0bfbaf7 [CS] Remove a couple uses of recordAnyTypeVarAsPotentialHole
It's not actually clear these are necessary anymore, and in one case
it actually makes a diagnostic worse.
2025-09-17 16:11:53 +01:00
Hamish Knight
63d63d8c60 [CS] Bail from conjunction for non-zero SK_Hole
Previously we would only do this for `SK_Fix`, do the same for `SK_Hole`
since otherwise the score clearing logic for the conjunction could
result in losing the hole score.
2025-09-15 21:43:58 +01:00
Hamish Knight
b7519fabe6 [CS] Add IgnoreInvalidASTNode fix for invalid generic argument
Make sure we record a fix here to ensure we don't try to do CSApply
with holes.
2025-09-15 11:48:56 +01:00
Hamish Knight
6761d8474d Merge pull request #84273 from hamishknight/the-whole-hole
[CS] Avoid forming DependentMemberType with hole base in `InferableTypeOpener`
2025-09-15 09:33:34 +01:00
Hamish Knight
411e14d00b Merge pull request #84275 from hamishknight/skippy
[CS] Avoid skipping SingleValueStmtExpr branch with ReturnStmt for completion
2025-09-15 09:33:17 +01:00
Hamish Knight
6de09e1956 [test] Add some more known crashers 2025-09-14 10:35:53 +01:00
Hamish Knight
adb40dd82e [test] Update a couple of crasher signatures 2025-09-14 10:35:53 +01:00
Hamish Knight
0f7490aae1 [CS] Avoid forming DependentMemberType with hole base in InferableTypeOpener
Type substitution can form DependentMemberTypes with error base types,
avoid forming a DependentMemberType with a hole base in
`InferableTypeOpener`, instead form a hole that covers the entire type.
2025-09-14 10:09:39 +01:00
Hamish Knight
f1ad703430 [CS] Avoid skipping SingleValueStmtExpr branch with ReturnStmt for completion
We still need to solve a branch with a ReturnStmt to avoid leaving
the contextual result type unbound. This isn't currently legal anyway,
so isn't likely to come up often in practice, but make sure we can
still solve.
2025-09-13 19:15:34 +01:00
Rintaro Ishizaki
31b5d55f33 Merge pull request #84128 from rintaro/parse-attr-lparen-space-rdar147785544
[Parse] Change whitespace rule between attribute name and '(' in Swift 6
2025-09-12 18:19:53 -07:00
Hamish Knight
014ed51ab1 Merge pull request #84220 from hamishknight/times-arrow
[AST] Allow storing original expression in `ErrorTypeRepr`
2025-09-12 17:06:34 +01:00
Hamish Knight
be89557600 Merge pull request #84217 from hamishknight/fix-crash
[Completion] Simplify opened function type in `tryResolveDoubleAppliedFunction`
2025-09-11 16:27:14 +01:00
Hamish Knight
c84d2abb05 [AST] Allow storing original expression in ErrorTypeRepr
This is useful for ArrowExpr when the sub-expressions aren't valid
TypeExprs. Rather than throwing away the AST, attach it to the
ErrorTypeRepr to ensure we can still type-check it. This ensures
semantic functionality still works correctly, and fixes a crash where
we'd stop visiting an invalid binding pattern, losing track of the
nested VarDecl.
2025-09-11 13:21:03 +01:00
Hamish Knight
9beb2e3e36 [Completion] Simplify opened function type in tryResolveDoubleAppliedFunction 2025-09-11 10:31:46 +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
872176bdd1 Merge pull request #84149 from hamishknight/case-and-pat
A few pattern cleanups + fixes
2025-09-10 09:36:22 +01:00
nate-chandler
b740a457c3 Merge pull request #84185 from nate-chandler/rdar159211502
[SILVerifier] Ease this over-strict verification.
2025-09-09 23:47:35 -07: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
Rintaro Ishizaki
b119407966 [Parse] Change whitespace rule between attribute name and '(' in Swift 6
In Swift 6 and later, whitespace is no longer permitted between an
attribute name and the opening parenthesis. Update the parser so that
in Swift 6+, a `(` without preceding whitespace is always treated as
the start of the argument list, while a '(' with preceding whitespace is
considered the start of the argument list _only when_ it is unambiguous.

This change makes the following closure be parsed correctly:

  { @MainActor (arg: Int) in ... }

rdar://147785544
2025-09-09 16:44:29 -07: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
Nate Chandler
9bbfb2106b [SILVerifier] Ease this over-strict verification.
It's permitted for a `witness_method` instruction to have multiple
type-dependent operands.  This can happen when for example when one
local archetype is defined in terms of another.

rdar://159211502
2025-09-09 15:44:08 -07:00
John McCall
3088b85c2c Don't crash if there's a request cycle with DefaultArgumentExprRequest. 2025-09-09 14:26:57 -04:00
Hamish Knight
dcacc5917e [test] Disable USR verification for a couple of SDK completion tests
rdar://159844268
2025-09-09 17:07:04 +01:00
Hamish Knight
9db82cbe62 [AST] Avoid walking a few more expressions in WalkToVarDecls
Avoid walking TapExprs, SingleValueStmtExprs, and key paths. The latter
is important since they can contain invalid VarDecls that will no
longer be visited by the ASTWalker after key path resolution, so we
don't want to create case body vars for them.
2025-09-09 13:48:40 +01:00
Allan Shortlidge
c931935aa2 Test: Fix availability in a79aa9924bdc378.swift. 2025-09-08 19:20:17 -07:00
Hamish Knight
a2f7d239ab [test] Add some more known crashers 2025-09-08 08:16:31 +01:00
Ahmed Elrefaey
1bc96857a8 Merge pull request #82464 from a7medev/feat/full-documentation-in-code-completion
[IDE] Add full documentation to code completion result
2025-09-04 10:06:21 +01: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
Pavel Yaskevich
96900f9bd0 Merge pull request #84012 from xedin/rdar-158063151
[CSOptimizer] Don't match `nil` to `_OptionalNilComparisonType`
2025-09-02 07:05:21 -07:00
Pavel Yaskevich
df962a83c6 [CSOptimizer] Don't match nil to _OptionalNilComparisonType
This type is only intended for pattern matching against `nil`
and the solver shouldn't early attempt to infer this type for
`nil` for arguments of `==` and `!=` operators it should instead
be inferred from other argument or result.

Resolves: rdar://158063151
2025-09-01 20:47:56 -07:00
Hamish Knight
1f0d22807c [test] Add some more known crashers 2025-09-01 09:28:55 +01:00
Hamish Knight
19b16a5b6d [test] Update a couple of crasher signatures 2025-09-01 09:28:55 +01:00
Hamish Knight
a1e4a08ac7 Merge pull request #83593 from hamishknight/disable-fallback
[IDE] Remove fallback type-checking logic
2025-08-31 10:09:22 +01:00