Commit Graph

2448 Commits

Author SHA1 Message Date
Slava Pestov
74f8960bd8 Sema: Remove OneWayExpr and Builtin.one_way 2024-12-21 00:42:13 -08:00
Anthony Latsis
b6def6ec71 Merge pull request #77892 from AnthonyLatsis/magnolia-grandiflora
Sema: Subscript called with opened existential cannot produce lvalue if result is type-erased
2024-12-18 12:25:45 +00:00
Anthony Latsis
6612c9cf89 Sema: Subscript called with opened existential cannot produce lvalue if result is type-erased 2024-12-17 23:03:38 +00:00
Pavel Yaskevich
a2f711cf8e [ConstraintSystem] Make any Sendable -> Any behave the same in all language modes 2024-12-16 13:57:33 -08:00
Pavel Yaskevich
5e08f7e257 [CSApply/SILGen] Implement any Sendable to Any erasure for generic arguments
In non-strict concurrency mode when `@preconcurrency` declarations
are involved `any Sendable` should be treated as `Any` in generic
argument positions to support passing types that (partially) adopted
concurrency annotations to types that haven't yet done so.
2024-12-11 17:19:14 -08:00
Slava Pestov
d6b08c3c6d Merge pull request #77997 from slavapestov/csapply-astcontext
Sema: Stash the ASTContext in the ExprRewriter
2024-12-06 04:59:48 -05:00
Slava Pestov
8b3e219e37 Sema: Stash the ASTContext in the ExprRewriter 2024-12-05 18:41:31 -05:00
Hamish Knight
48dc186269 [CS] Correctly handle compound-applied functions with property wrappers
Avoid wrapping parameters in the function reference
for compound applies, and make sure we consult
the parameter label in the compound name if it's
present to determine whether to match using the
projected value or not. This matches the existing
logic in `unwrapPropertyWrapperParameterTypes`.
2024-12-05 15:55:20 +00:00
Hamish Knight
0fdb038fc9 Merge pull request #77896 from hamishknight/functionref-split
[AST] Split out "is compound" bit on FunctionRefKind
2024-12-03 09:53:37 +00:00
Pavel Yaskevich
1f7b76edd3 Merge pull request #77816 from xedin/fix-property-wrapper-projected-value-applies
[CSApply] Avoid shortcutting argument conversion when parameter has a…
2024-12-02 13:52:30 -08:00
Anton Korobeynikov
8e53ccd671 [AutoDiff] Peel off @sendable implicit conversion when checking for unsupported differentiable function conversion (#77869) 2024-12-02 10:29:37 -08: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
be1c9ad3eb [CSApply] CurryThunks: Add an assert to make sure that all applied property wrappers are used 2024-11-22 15:04:20 -08:00
Pavel Yaskevich
44908acd75 [CSApply] Avoid shortcutting argument conversion when parameter has an external property wrapper
The check to see whether argument matches the parameter exactly
causes two problems: prevents projected value initialized injection;
and, if there are multiple parameters with property wrappers,
would apply incorrect wrapper to other locations because the wrapper
application index wasn't incremented.

Resolves: rdar://140282980
2024-11-22 14:02:06 -08:00
Hamish Knight
68648f74ef [CS] Use adjusted type for single curry thunks
This matches the double curry thunk logic and
ensures that the resulting autoclosure matches the
expected type of the reference, avoiding mismatches
with parent expressions.

rdar://140212823
2024-11-21 12:14:00 +00:00
Hamish Knight
683c7ceb31 [CS] Simplify opened types earlier in buildMemberRef
Doesn't seem to be any reason not to do this
up-front, cleans up the code a little. Should be
NFC.
2024-11-21 12:13:59 +00:00
Slava Pestov
06b4953b85 Sema: Remove a usage of QueryTypeSubstitutionMap 2024-11-18 11:40:39 -05:00
Slava Pestov
47156e006b AST: Introduce ProtocolConformanceRef::forAbstract() 2024-11-16 16:16:06 -05:00
Hamish Knight
d8ec851c93 [Sema] NFC: Address review feedback on #77537 2024-11-12 18:35:17 +00:00
Hamish Knight
eef4716731 [Completion] Avoid doing extra type-checking in CSApply
Avoid type-checking local decls and macros, the
type-checking here should instead be handled by
TypeCheckASTNodeAtLocRequest.
2024-11-11 19:34:21 +00:00
Hamish Knight
fab09c50a0 Merge pull request #77479 from hamishknight/macro-misc-diag-fixes
[Sema] A couple of fixes for MiscDiagnostics on macro expansions
2024-11-11 19:27:58 +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
be94e5d305 [CS] NFC: Sink LocalDeclsToTypeCheck into ExprRewriter 2024-11-09 00:24:53 +00:00
Hamish Knight
caceca6530 [CS] NFC: Move some code
Always bothered me the constructor for
ExprRewriter is buried in the middle of the class.
2024-11-09 00:24:53 +00:00
Slava Pestov
f702e46751 Merge pull request #77475 from slavapestov/fix-rdar139237781
Sema: Fix handling of appliedPropertyWrappers in ConstraintSystem::replaySolution()
2024-11-08 15:15:27 -05:00
Slava Pestov
d67e89d89c Sema: Fix handling of appliedPropertyWrappers in ConstraintSystem::replaySolution()
When we replay a solution, we must record changes in the trail, so fix the
logic to do that. This fixes the first assertion failure with this test case.

The test case also exposed a second issue. We synthesize a CustomAttr in
applySolutionToClosurePropertyWrappers() with a type returned by simplifyType().
Eventually, CustomAttrNominalRequest::evaluate() looks at this type, and passes
it to directReferencesForType(). Unfortunately, this entry point does not
understand type aliases whose underlying type is a type parameter.
However, directReferencesForType() is the wrong thing to use here, and we
can just call getAnyNominal() instead.

Fixes rdar://139237781.
2024-11-08 10:46:07 -05:00
Hamish Knight
2d7500eda6 [AST] Remove ParenType
Today ParenType is used:

1. As the type of ParenExpr
2. As the payload type of an unlabeled single
   associated value enum case (and the type of
   ParenPattern).
3. As the type for an `(X)` TypeRepr

For 1, this leads to some odd behavior, e.g the
type of `(5.0 * 5).squareRoot()` is `(Double)`. For
2, we should be checking the arity of the enum case
constructor parameters and the presence of
ParenPattern respectively. Eventually we ought to
consider replacing Paren/TuplePattern with a
PatternList node, similar to ArgumentList.

3 is one case where it could be argued that there's
some utility in preserving the sugar of the type
that the user wrote. However it's really not clear
to me that this is particularly desirable since a
bunch of diagnostic logic is already stripping
ParenTypes. In cases where we care about how the
type was written in source, we really ought to be
consulting the TypeRepr.
2024-10-31 11:32:40 +00:00
Slava Pestov
b961a7ec51 Sema: Record isolated parameters in the trail 2024-10-07 16:50:48 -04:00
Amritpan Kaur
6066418340 Merge pull request #73242 from amritpan/metatype-kp-implementation 2024-09-28 02:46:15 -07:00
Amritpan Kaur
ffb8baf342 [Sema] Remove checks preventing metatype keypaths in Sema. 2024-09-25 12:54:51 -07:00
Kavon Farvardin
df73eecdeb Sema: generalize findSyntacticErrorForConsume
Since this function is being called from the constraint solver now, we
need to generalize the way it obtains the Type of an Expression, as the
expression itself may not know its own type, only the solver does.

resolves rdar://134371893 / https://github.com/swiftlang/swift/issues/75999
2024-09-24 13:59:29 -07:00
Hamish Knight
1cc00e3676 [CS] NFC: Remove SolutionApplicationToFunctionResult
This is now no longer needed.
2024-09-17 12:35:11 +01:00
Hamish Knight
1f79cbdca1 [CS] Sink closure attribute/param checking into applySolution
The cases where CSApply fails should be fairly
limited these days, and there doesn't seem to be
any reason we shouldn't run these on failure anyway.
2024-09-17 12:35:11 +01:00
Hamish Knight
930dc18eb7 [CS] Avoid delaying application for multi-statement closures
We ought to be able to apply the solution to them
immediately now.
2024-09-17 12:35:11 +01:00
Hamish Knight
f0151c1d21 [CS] Delay type-checking of local decls
Delay `typeCheckDecl` for local decls until the
end of CSApply. This replaces the existing logic
for delaying type-checking for local functions.
2024-09-17 12:35:10 +01:00
Hamish Knight
d99d881af5 [CS] NFC: Factor out base class SyntacticElementTargetRewriter
Pass this instead of a function for rewriting
targets.
2024-09-17 12:35:10 +01:00
Hamish Knight
002c6d169b [CS] Remove some calls to setExprTypes
`rewriteTarget` already calls `setExprTypes` for
expressions, so these are redundant.
2024-09-17 12:35:10 +01:00
Doug Gregor
05e8140c6d Provide macro module name in MacroExpansionExpr creation
This properly passes the module name through from attached macros to
the freestanding macro that are used under-the-hood for type checking.
2024-09-16 16:44:17 -07:00
Hamish Knight
b1c90feb52 [CS] Sink closure property wrapper application into applySolution
We need to make sure property wrappers are
applied before `checkParameterList`.
2024-09-14 15:37:21 +01:00
Hamish Knight
2d6a38b2cd [CS] Call checkParameterList for single-expr closures
Previously we would only call this in the delayed
application logic, which is currently run for
multi-statement closures. I'm planning on
removing that code path, which uncovered this
issue.
2024-09-14 15:37:21 +01:00
Hamish Knight
ee0e408a8c [Sema] Remove separate closure type-checking logic
`participatesInInference` is now always true for
a non-empty body, remove it along with the separate
type-checking logic such that empty bodies are
type-checked together with the context.
2024-09-08 16:17:11 +01:00
Alejandro Alonso
45d7ea39a5 Merge pull request #75518 from Azoy/integer-generics
Implement Value generics
2024-09-05 15:33:46 -07:00
Alejandro Alonso
0df42e9841 Lower UDRE to TypeValue if it references a value generic 2024-09-04 15:13:29 -07:00
Alejandro Alonso
75c2cbf593 Implement value generics
Some requirement machine work

Rename requirement to Value

Rename more things to Value

Fix integer checking for requirement

some docs and parser changes

Minor fixes
2024-09-04 15:13:25 -07:00
Slava Pestov
851a829063 Sema: Consolidate logic for opening existentials in OpenedExistentials.cpp 2024-09-04 14:57:38 -04:00
Pavel Yaskevich
44d83aee8a [CSApply] Start marking closures that require dynamic isolation checking
If a closure is passed as an argument to a not-fully concurrency
checked callee - require dynamic isolation checking.

This information is going to be used by SILGen to inject expected
executor precondition when necessary.
2024-08-22 09:57:17 -07:00
Pavel Yaskevich
a4d9b3b5b2 [AST] Add a bit to closure expr to indiciate whether it requires dynamic isolation checking
This is an important information for closures because the compiler
might need to emit dynamic actor isolation checks in some circumstances
(i.e. when a closure is isolated and passed to a not fully concurrency
checked API).
2024-08-22 09:57:06 -07:00
Pavel Yaskevich
3df5e9c997 Merge pull request #75991 from xedin/rename-ispassedtosendingparameter
[AST] NFC: Rename `ParameterInfoList::isPassedToSendableParameter` to…
2024-08-21 09:14:00 -07:00
Pavel Yaskevich
f64bf5ff95 [AST] NFC: Rename ParameterInfoList::isPassedToSendableParameter to isSendableParameter
Just like other members of that type, `isPassedToSendableParameter` bit
set tracks information per parameter. The "passed" bit is applicable
to the argument rather than the parameter itself so it should bit kept
on the `AbstractClosureExpr`.
2024-08-20 13:17:04 -07:00