Commit Graph

1245 Commits

Author SHA1 Message Date
Pavel Yaskevich
10c794e568 [CSDiagnostics] Produce a diagnostic for patterns with extraneous elements
Extend `ExtraneousArgumentsFailure` to handle enum element
pattern mismatches.

Resolves: rdar://123466496
2024-02-26 14:30:29 -08:00
li3zhen1
9a6d2b5304 [CSDiagnostics] Add callee side note for holes in generic pack element 2024-02-22 12:39:18 -05:00
Li, Zhen
b44fbf60c6 [CSDiagnostics] Add diags for holes in generic parameter pack 2024-02-21 23:25:25 -05:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Slava Pestov
1c24b880ec Merge pull request #70467 from AnthonyLatsis/recursive-member-typerepr
AST: Remodel `MemberTypeRepr` to be recursive
2024-02-16 11:36:31 -05:00
Kavon Farvardin
88e4ece3ca Diagnostics: invertibles and conformsTo 2024-02-13 15:14:39 -08:00
Anthony Latsis
14d38e7f01 [NFC] Sema: Refactor for recursive MemberTypeRepr representation 2024-02-09 17:23:41 +03:00
Anthony Latsis
bbf03c0481 [NFC] Sema/TypeCheckType: Refactor for recursive MemberTypeRepr representation 2024-02-09 17:23:40 +03:00
Hamish Knight
2c77947000 Merge pull request #71006 from hamishknight/implicit-last-expression
Introduce implicit last expression results
2024-02-08 10:15:01 +00:00
Hamish Knight
1003b2f30b [CS] Remove CTP_ImpliedReturnStmt
Unify with `CTP_ReturnStmt`, and have the
SyntacticElementTarget carry the ReturnStmt for
regular type-checking, which we can use to record
implied returns.
2024-02-07 18:14:23 +00:00
John McCall
2f8a33cf0a Experimental type-checking support for @isolated(any) function types. 2024-02-06 22:54:27 -05:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Frederick Kellison-Linn
0735629c8d Merge pull request #39612 from Jumhyn/keypath-function-conversion
[ConstraintSystem] Allow function-function conversions for keypath literals
2024-02-03 10:26:13 -08:00
Rintaro Ishizaki
b12370a7ca Merge pull request #71342 from rintaro/ast-attrkind 2024-02-02 13:16:14 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Rintaro Ishizaki
b839718351 [AST] Use scoped enum for attribute kinds
Align with other kind enum e.g. DeclKind.
2024-02-02 09:36:48 -08:00
Rintaro Ishizaki
07bb0380a1 [AST] Use class names for type attribute kind enum
Align with DeclAttrKind.
2024-02-02 09:36:47 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
Slava Pestov
821c3a39c2 Sema: Introduce ResolveValueWitnessesRequest 2024-01-31 21:56:45 -05:00
Hamish Knight
9b64990d24 [AST] Remove the "single expression body" bit
Remove this bit from function decls and closures.
Instead, for closures, infer it from the presence
of a single return or single expression AST node
in the body, which ought to be equivalent, and
automatically takes result builders into
consideration. We can also completely drop this
query from AbstractFunctionDecl, replacing it
instead with a bit on ReturnStmt.
2024-01-30 14:08:54 +00:00
John McCall
41cdfb04ad Introduce a proper TypeAttribute class hierarchy.
The old TypeAttributes reprsentation wasn't too bad for a small number of
simple attributes.  Unfortunately, the number of attributes has grown over
the years by quite a bit, which makes TypeAttributes fairly bulky even at
just a single SourceLoc per attribute.  The bigger problem is that we want
to carry more information than that on some of these attributes, which is
all super ad hoc and awkward.  And given that we want to do some things
for each attribute we see, like diagnosing unapplied attributes, the linear
data structure does require a fair amount of extra work.

I switched around the checking logic quite a bit in order to try to fit in
with the new representation better.  The most significant change here is the
change to how we handle implicit noescape, where now we're passing the
escaping attribute's presence down in the context instead of resetting the
context anytime we see any attributes at all.  This should be cleaner overall.

The source range changes around some of the @escaping checking is really a
sort of bugfix --- the existing code was really jumping from the @ sign
all the way past the autoclosure keyword in a way that I'm not sure always
works and is definitely a little unintentional-feeling.

I tried to make the parser logic more consistent around recognizing these
parameter specifiers; it seems better now, at least.
2024-01-28 22:30:26 -05:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Slava Pestov
2764333fea Sema: Introduce ResolveTypeWitnessesRequest 2024-01-24 21:45:34 -05:00
Slava Pestov
9831b0cfa9 Sema: Stop recording missing witnesses in the ConformanceChecker 2024-01-24 18:21:30 -05:00
Frederick Kellison-Linn
0d79f4523a Allow function-function conversions for keypath literals
Remove keypath subtype asserts; always use cached root type

Add tests for keypaths converted to funcs with inout param

Add unit test for overload selection
2024-01-23 08:51:44 -05:00
Slava Pestov
884c475ada Sema: Replace ASTContext::addDelayedMissingWitnesses() with ASTContext::addDelayedMissingWitness()
Instead of passing a unique_ptr of an opaque type back and forth,
let's just push elements onto an std::vector. For now this change
is completely NFC, but further simplifications will become
possible shortly.
2024-01-22 08:25:29 -05:00
Slava Pestov
e894d4afbb Sema: FailureDiagnostic::resolveType() wraps GenericParameterTypes in ErrorTypes to avoid triggering asserts 2024-01-17 21:15:38 -05:00
Anthony Latsis
96ee57b00b Merge pull request #70623 from AnthonyLatsis/init-sema
Move unqualified `init` diagnosis from Parse to Sema
2024-01-18 03:53:33 +03:00
Pavel Yaskevich
6cdab78028 Merge pull request #70867 from xedin/dynamic-enforcement-of-witness-isolation-with-preconcurrency
[TypeChecker/SILGen] Dynamic enforcement of witness/objc isolation with @preconcurrency attribute
2024-01-17 10:01:37 -08:00
Slava Pestov
14d1fcb51a AST: TypeChecker::conformsToProtocol() => ModuleDecl::checkConformance() 2024-01-16 17:08:00 -05:00
Pavel Yaskevich
e8b7a26eac [AST] Add a flag to indicate that the conformance is @preconcurrency 2024-01-16 11:51:42 -08:00
Pavel Yaskevich
e40d4e42f8 [Diagnostics] Adjust isMisplacedMissingArgument to handle unresolved closures when matching to new parameter
Cannot rely that closure type is always resolved, but if the
other parameter has a correct shape, consider it a match.
2024-01-08 14:43:28 -08:00
Pavel Yaskevich
859106eed1 [Diagnostics] Expand trailing closure failure to handle all closure arguments 2024-01-08 14:09:18 -08:00
Pavel Yaskevich
92577723fb [Diagnostics] Add a tailored note when passing a closure to a non-closure accepting parameter 2024-01-08 14:09:18 -08:00
Anthony Latsis
bd2f48d9d2 [NFC] AST: Introduce and use Identifier::isConstructor 2023-12-25 21:09:17 +03:00
Sima Nerush
b6d0afba1f Merge pull request #67594 from simanerush/simanerush/pack-iteration-impl
[SE-0408] Enable Pack Iteration
2023-12-07 17:09:48 -08:00
Sima Nerush
23485990e5 Diagnose that where clause is not supported 2023-12-03 21:51:41 -08:00
Pavel Yaskevich
1f42585fdd [AST] NFC: Rename KeyPathExpr::{get, set}RootType to {get, set}ExplicitRootType 2023-11-28 13:01:43 -08:00
Pavel Yaskevich
bd4ee4681b Merge pull request #70007 from xedin/keypath-application-improvements
[ConstraintSystem] Modernization of key path application handling
2023-11-28 12:44:42 -08:00
Slava Pestov
1b1963e904 Sema: Remove 'inferred result type requires explicit coercion' diagnostic 2023-11-27 14:05:36 -05:00
Pavel Yaskevich
8a0d61faac [CSDiagnostics] Add a diagnostic for an invalid key path subscript index argument 2023-11-21 14:53:46 -08:00
Pavel Yaskevich
9f21b95fcb [CSDiagnostics] A tailored diagnostic when passing key path as an argument to non-key path parameter
Produce a tailored diagnostic that omits a fully unresolved key path
type (`KeyPath<_, _>`) when key path without an explicit root type is
passed as an argument to non-keypath parameter type (i.e. `Int`).
2023-11-08 19:54:32 -08:00
Pavel Yaskevich
4f5123eaf5 [CSDiagnostics] Make contextual key path type mismatch diagnostic consistent 2023-11-08 19:54:31 -08:00
Pavel Yaskevich
8b4985054a [CSDiagnostics] Differentiate between key path type and value issues
Make sure that contextual mismatch uses a correct locator when
the issue is with key path value type instead of the key path
type.
2023-11-01 09:15:14 -07:00
Kavon Farvardin
5e6c23e989 [Sema] diagnostic for conditional Copyable
We were allowing the catch-all "X is not compatible with generics yet"
diagnostic to be emitted when there's a failure to satisfy a requirement
for a conditional Copyable conformance. Instead, allow the existing
infrastructure to diagnose such failures-to-conform to emit a diagnostic
.

This patch also adds a check to catch future catch-all diagnostics in
asserts builds, since I'd like to phase out that diagnostic when
NoncopyableGenerics is enabled.
2023-10-18 13:52:14 -07:00
Pavel Yaskevich
23701bbb6d Merge pull request #69174 from xedin/rdar-116122902
[CSDiagnostics] Adjust how requirement failures anchor type is computed
2023-10-17 21:08:36 -07:00
Pavel Yaskevich
b3da15e324 [CSDiagnostics] Use simplified locator to find owner type of a requirement failure
Only simplified locator points to the right underlying expression.

Resolves: rdar://116122902
2023-10-13 10:45:50 -07:00
Slava Pestov
e298fb5a04 Merge pull request #69116 from slavapestov/fix-apply-variadic-generic-args
Sema: Fix two bugs with type resolution of generic arguments
2023-10-11 15:00:07 -04:00
Slava Pestov
67308e6894 Sema: Fix crash-on-invalid with incorrect use of variadic generic type
Applying generic arguments to a variadic generic type uses the
PackMatcher to build a mapping between generic parameters and
arguments.

The PackMatcher is symmetric, so there was an unexpected failure
mode that wasn't handled: if the variadic generic type had some
non-pack parameters, but the argument list was a single pack
expansion type, the match would succeed, grouping all of the
generic parameters into a single match.

This is non-sensical, so we need to explicitly check for this
case and diagnose it. This requires a new diagnostic, since
otherwise the general diagnostic we emit for variadic generic
type mismatches doesn't make sense, since it's complaining
about there being too few generic parameters.

Fixes rdar://116713961 / https://github.com/apple/swift/issues/69012.
2023-10-11 10:39:26 -04:00
Hamish Knight
03b6623f72 Merge pull request #69074 from hamishknight/over-extended 2023-10-10 10:25:57 +01:00