Commit Graph

23843 Commits

Author SHA1 Message Date
Hamish Knight
09bb346b03 [CS] Walk UnresolvedDeclRefExprs in UnresolvedVarCollector
This matches what we do in VarRefCollector, and is
needed because we currently delay the pre-checking
of patterns due to the fact that we don't resolve
them until CSGen. We ought to consider changing
this, but until then, adjust the logic here to
ensure we properly connect an ExprPattern that
references an outer var with any type variables
it may involve.

rdar://112264204
2023-07-17 17:32:46 +01:00
Sophia Poirier
6e47a36808 Merge pull request #67292 from sophiapoirier/pack-stored-propety-shadows-global
[ConstraintSystem] implement implicit pack materialization for abstract tuples instead of explicit '.element'
2023-07-14 15:11:05 -07:00
nate-chandler
400d3d1422 Merge pull request #67272 from nate-chandler/rdar112152116
[Sema] Allow implicit dynamic @nonobjc.
2023-07-14 10:49:19 -07:00
Sophia Poirier
fa41015ae4 [ConstraintSystem] implement implicit pack materialization for abstract tuples instead of explicit '.element' 2023-07-14 10:32:38 -07:00
Ben Barham
f7334a1968 Merge pull request #67299 from ahoppen/ahoppen/result-builder-signature-crash
[CodeComplete] Fix a crash when completing in the signature of a function annotated with result builder
2023-07-14 10:31:20 -07:00
Holly Borla
c55d0e2e44 Merge pull request #67106 from hborla/validate-extension-macros
[Macros] Add missing macro validation.
2023-07-14 07:53:43 -07:00
Alex Hoppen
f212dd8b1a [CodeComplete] Fix a crash when completing in the signature of a function annotated with result builder
When we are completing inside a function signature, the function doesn’t have a body. We were still running `PreCheckResultBuilderApplication`, which crashed if the body was `nullptr`.

rdar://111489024
2023-07-14 12:58:03 +02:00
Holly Borla
04ea8b0a67 [Macros] Diagnose macros attached to declarations they cannot apply to. 2023-07-13 17:07:24 -07:00
Holly Borla
05c3ffc749 [Macros] Validate that extension macro expansions only include names covered
by the macro declaration.
2023-07-13 06:59:18 -07:00
Slava Pestov
aa026f4d06 Merge pull request #67266 from slavapestov/transform-type-parameter-packs
Fix various places where we didn't handle "bound" pack references correctly
2023-07-13 08:09:04 -04:00
Allan Shortlidge
e973ff941f Merge pull request #67225 from tshortli/allow-usable-from-inline-access-in-default-args
Sema: Allow default arguments to access `@usableFromInline` decls
2023-07-12 20:40:24 -07:00
Michael Gottesman
377d5e1148 Merge pull request #67203 from gottesmm/pr-926bc2579371ebafa050d23a22d39b2a177ecd6a
[reference-bindings] Inout Binding ensure that we handle fields correctly
2023-07-12 15:06:59 -07:00
Slava Pestov
8a132c0248 Sema: Replace some usages of mapPackTypeIntoElementContext() with mapContextualPackTypeIntoElementContext() 2023-07-12 18:02:14 -04:00
Konrad `ktoso` Malawski
2044cb78cf Merge pull request #66934 from kabiroberai/main 2023-07-13 06:53:23 +09:00
Nate Chandler
8b662a7fea [Sema] Allow implicit dynamic @nonobjc.
Back in https://github.com/apple/swift/pull/24959, marking a decl both
dynamic and @nonobjc was allowed.  So implicitly mark decls that are
@nonobjc dynamic when -enable-implicit-dynamic is specified.

rdar://112152116
2023-07-12 14:23:50 -07:00
Allan Shortlidge
496d29c47f AST: Remove FragileFunctionKind.allowUsableFromInline.
It was effectively always true after allowing default argument expressions to
reference `@usableFromInline` decls.
2023-07-12 12:47:06 -07:00
Alex Lorenz
4d084100ce [cxx-interop] Mark C++ functions with unavailable return type as unavailable
This prevents users from calling functions with unsupported or unavailable return types. This ensures that users don't for example call a function that returns a non-copyable and non-movable type

Fixes https://github.com/apple/swift/issues/64401
2023-07-11 16:40:57 -07:00
Michael Gottesman
c8f50b3814 [reference-bindings] Make the never mutated diagnostic only apply to vars, not also to inout bindings. 2023-07-11 13:27:51 -07:00
Pavel Yaskevich
4760b95282 Merge pull request #67183 from xedin/convert-effects-into-storageRestrictions
[AST/Sema] Implement @storageRestrictions attribute
2023-07-11 11:57:14 -07:00
Pavel Yaskevich
62719b05ac Merge pull request #67157 from amritpan/kp-declcontext
[Constraint System] Store key path root, value, and decl context for use across constraint system.
2023-07-10 23:09:09 -07:00
Amritpan Kaur
1d8e7ef2fe [CSGen] Record keypath for use across constraint system. 2023-07-10 15:54:22 -07:00
Michael Gottesman
8f64bceb17 Merge pull request #67202 from gottesmm/pr-bf5ceafdd45802deafe22132048f87ea30198725
[reference-bindings] Add Sema checks for inout reference bindings to make sure we can only attach to lvalues
2023-07-10 15:16:55 -07:00
Sima Nerush
83a7e05608 [Sema] Record a fix about extra parens for computed properties (#67042)
Co-authored-by: Sima Nerush <sima_nerush@apple.com>
2023-07-10 14:34:32 -07:00
Michael Gottesman
f2bfa1cbac [reference-bindings] Add Sema checks for inout reference bindings to make sure we can only attach to lvalues
rdar://112029192
2023-07-10 12:47:46 -07:00
Alex Hoppen
3a0b72620a Merge pull request #63717 from ahoppen/ahoppen/remaining-solver-based 2023-07-09 08:14:43 +02:00
Holly Borla
b7a53f9303 [Macros] Handle the case where an extension macro conformance has a null
type repr because it was deserialized.
2023-07-07 17:16:03 -07:00
Pavel Yaskevich
06216fc0f1 [Sema] InitAccessors: Synthesize memberwise inits only with init accessor properties 2023-07-07 13:56:02 -07:00
Alex Hoppen
ed4dc1becd Change Optional -> llvm::Optional 2023-07-07 21:16:33 +02:00
Alex Hoppen
527a79e9f8 [IDE] Set constraint system options from solveForCodeCompletion in applyResultBuilderBodyTransform when solving for code completion 2023-07-07 19:51:01 +02:00
Alex Hoppen
f2017b82ac [IDE] Don't fallback type check if the completion expression is inside a closure 2023-07-07 19:51:01 +02:00
Alex Hoppen
1bacfe9cd4 [IDE] Ignore unspported constructs in result builders in code completion mode 2023-07-07 19:51:01 +02:00
Alex Hoppen
928a03a2e0 [CodeCompletion] Migrate conforming methods list to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
4d1e44fbf1 [CodeCompletion] Don't typecheck expression if result builder transform was applied 2023-07-07 19:51:01 +02:00
Alex Hoppen
00eaed3af9 [CodeCompletion] Migrate postfix expr completion to solver-based 2023-07-07 19:51:01 +02:00
Alex Hoppen
1e723ddbc2 [CodeCompletion] Don't increase the score for holes at the code completion token 2023-07-07 19:50:46 +02:00
Alex Hoppen
0c413109d3 [CodeComplete] Skip conjunction elements unrelated to the code completion token 2023-07-07 19:50:46 +02:00
Alex Hoppen
48dd99b12d [IDE] Don't rank based on overload choices of function calls that contain the code completion token 2023-07-07 19:50:46 +02:00
Alex Hoppen
4c186c0a9a [CodeCompletion] Fix code completion issues related to type checking tap expressions in the cosntraint system 2023-07-07 19:50:46 +02:00
Alex Hoppen
6cec68e302 [IDE] Ignore score kinds that represent implicit conversions when solving for code completion
Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
77bd8ad746 [CSGen/SyntaticElement] Remove logic that connects tap expressions to closures
Both single- and multi-statement closures now use variable reference
collector to identify variables used in the interpolation body, which
means that it's not longer necessary to connect to the closure explicitly
(if interpolation is contained in one).
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
ff0c942aa9 [CSSyntacticElement] Fix solution applicator to identify context correctly
`TapExpr` do not form their own declaration context which means
that using `context.getAsDeclContext` is incorrect for them.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
2fd5b5fb04 [CSGen] Interpolations: Collect all vars referenced in the body to preserve connection to context
Since "tap" bodies are now type-checked together with the context,
it's imperative that the variable that represents an interpolation
never gets disconnected from its context in the constraint system,
otherwise it wouldn't be possible to determine types for the
references.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
ac6ea62cec [CSGen] NFC: Extract var reference collector to be used in more places 2023-07-07 19:50:46 +02:00
Pavel Yaskevich
773513a5c7 [Sema] Run structural/availability diagnostics on tap bodies
Since interpolations are now type-checked using conjunctions
these diagnostics could be rank as part of the root expression
or statement verification.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
60fa909387 [CSSyntacticElement] Make sure that body of tap is solved in isolation
It doesn't need access to anything besides external declarations
which could be brought into the scope by context analyzer.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
096f6f8bcd [CSApply] Don't delay tap expression solution application 2023-07-07 19:50:46 +02:00
Pavel Yaskevich
e337a3947d [ConstraintSystem] Implement tap expression checking in the solver
Generate a conjunction for each tap expression body as soon as it
gets a contextual type instead of separate post-factum type-checking
via `typeCheckTapBody`.
2023-07-07 19:50:46 +02:00
Pavel Yaskevich
2ba70dff88 [CSClosure] Add TapExpr as a member of SyntacticElementContext 2023-07-07 19:50:46 +02:00
Pavel Yaskevich
28a39d6df1 [AST] NFC: Add a way to request initialized/accesses properties from init accessor 2023-07-07 10:00:36 -07:00
Pavel Yaskevich
94522ff81a [Sema] InitAccessors: Implement validation of @storageRestrictions attribute 2023-07-07 10:00:36 -07:00