Commit Graph

439 Commits

Author SHA1 Message Date
Hamish Knight
c853d81d37 [CS] Always eagerly bind member type var to hole for missing member
We know this is where the issue is so we ought to always produce a
concrete hole.
2025-11-16 11:47:21 +00:00
Becca Royal-Gordon
60cc537f70 Improve module selector constraint solver diagnostics 2025-10-24 16:23:49 -07:00
Hamish Knight
d65f28984a [CS] Improve diagnostics for non-metatype type(of:) contextual type
Emit a custom diagnostic for this case, and handle holes.
2025-10-06 21:45:48 +01:00
Hamish Knight
0b3747d7c4 Revert "[CS] Record fix when encountering decl reference with placeholder type"
This reverts commit 8102e39f39.
2025-09-19 14:22:39 +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
Slava Pestov
13b4b03aca Sema: Fix crash in IgnoreAssignmentDestinationType::diagnoseForAmbiguity() 2025-09-09 18:58:10 -04:00
Hamish Knight
5b8dfc70ab [CS] Emit fallback diagnostic if needed for IgnoreInvalidASTNode
If no other error has been emitted, make sure we emit a fallback
diagnostic rather than crashing in the ASTVerifier or SILGen.
2025-08-28 15:31:48 +01:00
Felipe Mussi Ferreira Peixoto
9779591212 [CSDiagnostics] Prevent nested type references in KeyPath components (#83625)
This change adds detection for nested type references in KeyPath
components and applies the appropriate fix to generate meaningful error
messages, following the same pattern already established for method
references.

The fix ensures that invalid KeyPath references fail gracefully in
normal mode and provide helpful diagnostics in diagnostic mode,
improving the developer experience when working with KeyPaths.

Resolves: https://github.com/swiftlang/swift/issues/83197
2025-08-27 14:50:14 -07:00
Hamish Knight
fb7f2d0ff2 [CS] Limit the number of chained @dynamicMemberLookup lookups
Set an upper bound on the number of chained lookups we attempt to
avoid spinning while trying to recursively apply the same dynamic
member lookup to itself.

rdar://157288911
2025-08-01 19:08:04 +01:00
Pavel Yaskevich
3ae8d5680f [CSFix] Fix getConcurrencyFixBehavior to account for non-decl overloads
Adjust the downgrade check for static member references to
account for the fact that argument could come of a tuple or
some other reference that doesn't have a declaration associated
with it.

Resolves: rdar://153083848
2025-06-26 15:08:51 -07:00
Hamish Knight
6d0da8d5cc [CS] Avoid solver-allocated inputs with typesSatisfyConstraint
Escaping solver-allocated types into a nested allocation arena is
problematic since we can e.g lazily compute the `ContextSubMap` for a
`NominalOrBoundGenericNominalType`, which is then destroyed when we
exit the nested arena. Ensure we don't pass any types with type
variables or placeholders to `typesSatisfyConstraint`.

rdar://152763265
2025-06-12 12:11:19 +01:00
Alejandro Alonso
02d9779ba3 Merge pull request #81184 from Azoy/no-more-is-array-type
[AST] Rename isArrayType and split the InlineArray portion
2025-05-08 20:52:51 -07:00
Pavel Yaskevich
a57310b61d [CSFix] SE-0470: Warn about missing @Sendable for unapplied static member references until future Swift version
Static member referenced were marked as `@Sendable` by `InferSendableFromCaptures`
because metatypes used to be always Sendable which is no longer the case, so in
order to maintain the source compatibility we need to downgrade missing `@Sendable`
to a warning for unapplied static member references.

This affects primarily operators at the moment because other static members
form a curry thunk with a call inside and would be diagnosed as a capture.

Resolves: rdar://150777469
2025-05-07 00:17:28 -07:00
Alejandro Alonso
e68b398d41 Rename isArrayType and split the InlineArray portion 2025-04-29 15:57:10 -07:00
Doug Gregor
2a7de1b559 Store the conforming type within an abstract ProtocolConformanceRef
An "abstract" ProtocolConformanceRef is a conformance of a type
parameter or archetype to a given protocol. Previously, we would only
store the protocol requirement itself---but not track the actual
conforming type, requiring clients of ProtocolConformanceRef to keep
track of this information separately.

Record the conforming type as part of an abstract ProtocolConformanceRef,
so that clients will be able to recover it later. This is handled by a uniqued
AbstractConformance structure, so that ProtocolConformanceRef itself stays one
pointer.

There remain a small number of places where we create an abstract
ProtocolConformanceRef with a null type. We'll want to chip away at
those and establish some stronger invariants on the abstract conformance
in the future.
2025-03-23 20:53:48 -07:00
Amritpan Kaur
98cd675eb9 Guard feature behind experimental flag. 2025-03-19 10:54:09 -07:00
Amritpan Kaur
970159c09d [CSDiagnostics] Block async, throws and mutating methods. 2025-03-19 08:56:03 -07:00
Amritpan Kaur
7ff563eb0c [CSDiagnostics] Remove checks preventing method/initializer keypaths. 2025-03-19 08:56:03 -07:00
Artem Chikin
de26e960e2 Rename '_const' attribute to 'CompileTimeLiteral'
To pave the way for the new experimental feature which will operate on '@const' attribute and expand the scope of what's currently handled by '_const' without breaking compatibility, for now.
2025-03-04 07:30:02 -08:00
Doug Gregor
6a4d1a41c4 Prohibit isolated conformances with Sendable(Metatype) constraints
Within the constraint system, introduce a new kind of conformance constraint,
a "nonisolated conforms-to" constraint, which can only be satisfied by
nonisolated conformances. Introduce this constraint instead of the normal
conforms-to constraint whenever the subject type is a type parameter that
has either a `Sendable` or `SendableMetatype` constraint, i.e., when the type
or its values can escape the current isolation domain.
2025-03-01 08:19:42 -08:00
Pavel Yaskevich
13e3269d16 [CSFix] Fix a null pointer dereference in getStructuralTypeContext
First problem - the logic used constraint system, which shouldn't
be required, second - it expects the type to be always present in
`ContextualTypeInfo` but that's not the case for some patterns.

Resolves: rdar://131819800
2025-02-24 13:57:28 -08:00
Alejandro Alonso
e4fb1f6761 Rename Slab to InlineArray 2025-02-11 10:26:44 -08:00
Alejandro Alonso
f76d841540 Rename to Slab 2025-01-09 10:39:45 -08:00
Alejandro Alonso
61702fb813 Implement Vector literals 2025-01-08 10:35:55 -08:00
Hamish Knight
2fd6863b1d [CS] Remove AutoClosureForwarding fix
The fix is currently unused, and the
FailureDiagnostic can be inlined into
MissingCallFailure.
2024-12-29 12:25:19 +00:00
Hamish Knight
d25bdfa4a3 [CS] Remove hack for rdar://139234188
Now that "is compound" is a separate bit in
FunctionRefInfo, we can correctly track the
application level for an EnumElementPattern.
2024-12-03 11:32:11 +00:00
Hamish Knight
73fb36f371 [AST] Split out "is compound" bit on FunctionRefInfo
FunctionRefKind was originally designed to represent
the handling needed for argument labels on function
references, in which the unapplied and compound cases
are effectively the same. However it has since been
adopted in a bunch of other places where the
spelling of the function reference is entirely
orthogonal to the application level.

Split out the application level from the
"is compound" bit. Should be NFC. I've left some
FIXMEs for non-NFC changes that I'll address in a
follow-up.
2024-12-02 14:11:33 +00:00
Hamish Knight
a4d51419ba [AST] NFC: Rename FunctionRefKind -> FunctionRefInfo 2024-12-02 14:11:32 +00: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
Holly Borla
a31a9d3642 [Concurrency] Downgrade @preconcurrency @Sendable conversion failures
to warnings even in Swift 6.
2024-11-07 16:02:37 -08:00
Pavel Yaskevich
9dc1403a3c [CSDiagnostics] SE-0438: Add a tailored diagnostic for unsupported static member references
Libraries of modules built with older compilers (< 6.1) don't have
symbols required to enable staitc member support in key path context.
2024-10-30 10:53:42 -07:00
Pavel Yaskevich
e68e4ea1b1 [CSFix] Add a new kind of invalid ref in key path - unsupported static members
Replaces feature flag check with module compiler version check
which implements the behavior discussed in the SE-0438.
2024-10-30 10:53:42 -07:00
Amritpan Kaur
8ebc928649 Guard feature behind experimental flag. 2024-09-27 22:42:04 -07:00
Amritpan Kaur
02b9bcbda2 [Sema] Update diagnostics. 2024-09-25 12:54:52 -07:00
Amritpan Kaur
ffb8baf342 [Sema] Remove checks preventing metatype keypaths in Sema. 2024-09-25 12:54:51 -07:00
Pavel Yaskevich
c49aeaf177 Merge pull request #76354 from xedin/improve-mismatch-diagnostics-in-optional-context
[CSSimplify] Rework how/when mismatches between optional types are fixed
2024-09-11 10:14:19 -07:00
Pavel Yaskevich
890e45d1e1 [CSSimplify] Increase impact of treat r-value as l-value fix in certain situations
If location (member) isn't mutable in the current context
or there are other problems at this location, increase impact
of the fix since it compounds the problem.
2024-09-10 10:35:28 -07:00
Allan Shortlidge
58a77206c4 ConstraintSystem: Remove UnviableReason::UR_MissingImport.
Now that `MemberImportVisibility` behavior is implemented using ranking there
is no need to support the `UR_MissingImport` unviability reason.
2024-09-10 09:47:42 -07:00
Pavel Yaskevich
2a6cc12a63 [ConstraintSystem] Downgrade some invalid specialization uses to a warning until Swift 6 language mode
Some invalid specializations were previously allowed by the compiler
and we found some existing code that used that (albeit invalid) syntax,
so we need to stage that error as a warning until Swift 6 language mode
to avoid source compatibility break.

Resolves: rdar://134740240
2024-08-29 00:15:08 -07:00
Slava Pestov
375363a473 AST: Move global conformance lookup entry points to ConformanceLookup.h 2024-08-08 23:35:58 -04:00
Greg Titus
d87e049cde Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify.
New separate fix for allow generic function specialization.
Improve parse heuristic for isGenericTypeDisambiguatingToken.
Degrade concrete type specialization fix to warning for macros.
2024-07-30 18:51:34 -07:00
Pavel Yaskevich
0343bb18af Revert "[Sema] Add specialization constraints for func and variable types, then diagnose w/fixes." 2024-07-25 15:43:15 -07:00
Greg Titus
47acc09e11 Merge pull request #74909 from gregomni/generic-arg
[Sema] Add specialization constraints for func and variable types, then diagnose w/fixes.
2024-07-24 19:38:11 -07:00
Greg Titus
6e917b567a Improve diagnoses of generic specializations
Always add constraints, find fixes during simplify.
New separate fix for allow generic function specialization.
Improve parse heuristic for isGenericTypeDisambiguatingToken.
2024-07-24 14:25:11 -07:00
Allan Shortlidge
d002da0ef2 AST: Add a IgnoreMissingImports option to name lookup.
Control enforcement of member import visibility requirements via a new option,
instead of piggy-backing on the existing IgnoreAccessControl option. Adopt the
option when doing fallback lookups for unviable members so that the compiler
can diagnose the reason that a member is inaccessible more reliably.
Previously, with MemberImportVisibility enabled decls with the package access
level could be mis-diagnosed as inaccessible due to their access level when
really they were inaccessible due to a missing import.

Resolves rdar://131501862.
2024-07-10 22:57:15 -07:00
Hamish Knight
4beaaf32ad [CS] Improve placeholder diagnostics slightly
Make sure `CouldNotInferPlaceholderType` can
produce a diagnostic for a `PlaceholderType`
locator element, and avoid emitting an extra
diagnostic for a placeholder type in an invalid
position.
2024-07-07 23:42:33 +01:00
Slava Pestov
86d567f95a AST: ModuleDecl::lookupConformance() is a static method 2024-07-06 12:05:47 -04:00
Michael Gottesman
56cb980540 Merge pull request #74564 from gottesmm/pr-9be87019f95149167c2e03043b7a86b82f9d282c
Follow up fixes with feedback from #74129
2024-06-25 10:24:26 -07:00
Michael Gottesman
9b0e0f5010 Follow up fixes with feedback from #74129
Didn't need to modify any tests since this shouldn't have any functional
change. Just a slight cleanup.
2024-06-19 20:04:05 -07:00
Tim Kientzle
1098054291 Merge branch 'main' into tbkka-assertions2 2024-06-18 17:52:00 -07:00