Commit Graph

24025 Commits

Author SHA1 Message Date
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
Pavel Yaskevich
9719cd01ef [AST] InitAccessors: Introduce new @storageRestrictions(initializes:accesses:) attribute
This is the replacement for `initializes`, `accesses` attributes.
2023-07-07 10:00:35 -07:00
Amritpan Kaur
dab7dbfdfd [NFC] Correct variable names 2023-07-07 08:47:40 -07:00
Amritpan Kaur
b008a4ba35 [CSSolver] Add supporting calls to pass around keyPath info
around the constraint system.
2023-07-07 08:47:40 -07:00
Kshitij Jain
8b73c98286 Fixes https://github.com/apple/swift/issues/59100 (#67162)
The above referenced issue was causing a compiler crash when writing
differentiable protocols and corresponding implementers, without importing
the `_Differentiation` module.

Changes in this CR fix the issue by marking any `@differentiable`
attributes as invalid, if the `_Differentiation` module has not been
imported. This ignores the `@differentiable` attributes when the
protocol witnesses are being verified. Witness verification was previously
leading to an error (due to missing `@differentiable` attribute on the protocol
requirement implementer), and the corresponding diagnostic emission code was
then leading to a crash, because it was expecting the `_Differentiation`
module to be present.
2023-07-07 07:32:55 -05:00
Sophia Poirier
7cc38fd0d4 Merge pull request #67164 from sophiapoirier/pack-environments-for-elements
add tracking of pack environments for pack elements to Constraint System
2023-07-06 19:30:28 -07:00
Anton Korobeynikov
eb82df6bc6 [AutoDiff] Support differentiable functions with multiple semantic results (#66873)
Add support for differentiable functions having multiple semantic results

Co-authored-by: Brad Larson <larson@sunsetlakesoftware.com>
2023-07-06 16:31:39 -07:00
Andrew Savonichev
b6acb6fbef [AutoDiff] Check @noDerivative for function type comparison (#67121)
As described in the issue #62922, the compiler should not allow to discard @noDerivative attribute and keep @differentiable. The patch adds a diagnostic for this case.

Resolves #62922.
2023-07-06 15:21:30 -07:00
Alexis Laferrière
019bd3c762 Merge pull request #67131 from xymus/warn-ioi-without-lib-evolution
[Sema] Warn on `@_implementationOnly` imports from a module without library-evolution
2023-07-06 15:17:31 -07:00
Sophia Poirier
63e30b5525 [Variadic Generics] add tracking of pack environments for pack elements to Constraint System 2023-07-06 13:44:10 -07:00
Slava Pestov
830bd75738 Merge pull request #67124 from slavapestov/runtime-pack-expansion-demangling
Runtime demangler support for pack expansions
2023-07-06 08:41:44 -04:00
Doug Gregor
f5427eaea2 Merge pull request #67148 from DougGregor/accessor-macros-finishing-touches 2023-07-05 22:56:46 -07:00
Doug Gregor
16bfd783f4 [Macros] When a macro defines a getter or setter, remove didSet/willSet
As with the initial value of a property that is converted from a stored
property to a computed property by an accessor macro, remove
didSet/willSet. It is the macro's responsibility to incorporate their
code or diagnose them.

Fixes rdar://111101833.
2023-07-05 19:37:21 -07:00
Luciano Almeida
6c19f3c216 Merge pull request #66276 from CrazyFanFan/kongkaikai/fix_66206
[Diagnostics] Fix #66206: Remove the whitespace on the left-hand side of "??"
2023-07-05 22:21:36 -03:00
Doug Gregor
82239e9d0a [Macros] Accessor macros can decide not to emit getter/setter if the property has one
If an accessor macro is placed on a computed property, then opts not to
produce a getter/setter, we would produce an error because the macro
didn't make the computed property... computed. Fix that; it's already
computed, and it's fine not to add accessors.

Fixes rdar://111586568.
2023-07-05 17:19:12 -07:00
Alexis Laferrière
fabb345624 [Sema] Warn on uses of @_implementationOnly imports without library-evolution
@_implementationOnly was designed for use from resilient modules only,
using it from non-resilient modules in unsupported. This change adds a
warning about it.

If anyone hits this warning, they should either enable library-evolution
or consider adopting the new `internal import` when it is available as
it handles this scenario properly.

What leads to a crash: an @_implementationOnly import fully hides the
dependency from indirect clients. This can lead to the compiler being
unaware of some internal details of a non-resilient module when building
a client against it. In turn this may lead to run time crashes from
miscompilation.

In general one could still use @_implementationOnly in a non-resilient
modules as long as it's referenced only from function bodies. However,
references from even non-public properties does lead to important memory
layout information being hidden from clients of the module.

rdar://78129903
2023-07-05 16:20:42 -07:00
Alexis Laferrière
671cc805a8 [Sema] Refactor validateResilience to prepare for one more check 2023-07-05 16:20:42 -07:00
Slava Pestov
e83b7003b1 Sema: Remove unused function 2023-07-05 16:35:17 -04:00
Egor Zhdan
39a837c1b5 Merge pull request #67115 from apple/egorzhdan/cxx-semantics-kind
[cxx-interop] Tweak C++ type semantics detection
2023-07-05 19:09:00 +01:00
Kabir Oberai
4f523807c9 feedback 2023-07-05 00:10:40 -04:00