Commit Graph

23610 Commits

Author SHA1 Message Date
Allan Shortlidge
f11eaf16eb Sema: Diagnose accessor exportability.
Properties may have `@_spi` setters and therefore the exportability of a
referenced accessor may differ from the exportability of the storage.
2023-05-01 15:34:08 -07:00
Allan Shortlidge
aef5e42457 Sema: Inherit SPI groups when synthesizing modify accessor.
Resolves rdar://108069565
2023-05-01 15:34:08 -07:00
Kavon Farvardin
ee819c80a9 Build support for ~Copyable atop @_moveOnly
We parse `~Copyable` in an inheritance clause of enum and
struct decls as a synonym for the `@_moveOnly` attribute
being added to that decl. This completely side-steps the
additional infrastructure for generalized suppressed
conformances in favor of a minimal solution. One benefit of
this minimal solution is that it doesn't risk introducing
any back-compat issues with older compilers or stdlibs.

The trade-off is that we're more committed to supporting
`@_moveOnly` in compiled modules in the future. In fact,
this change does not deprecate `@_moveOnly` in any way.

resolves rdar://106775103
2023-05-01 14:36:39 -07:00
Pavel Yaskevich
dba1b3436a [CSBindings] Diagnose leading-dot inference failure when base type is attempted as placeholder
Diagnose base inference failure only if base gets inferred to be
a placeholder, any transitive placeholder inference points to the
problem being elsewhere.
2023-05-01 14:19:14 -07:00
Alex Hoppen
237c70ea9c [CodeComplete] Offer completion suggestions for default argument values inside the macro declaration
We were not type checking the default argument initializer because `MacroDecl` is not an `AbstractFucntionDecl`. Add `MacroDecl` to the list of nodes we know how to get parameters from.

rdar://108163564
2023-05-01 13:48:18 -07:00
Pavel Yaskevich
f830eb6549 Merge pull request #65538 from platinumdragon1024/unused-var
[NFC] Remove an unused MallocAllocator variable
2023-05-01 09:43:36 -07:00
Rintaro Ishizaki
987e5698ae Merge pull request #65519 from rintaro/macros-nestedexpand-rdar108622244
[Macros] Don't expand macros inside macro expession arguments
2023-05-01 09:06:21 -07:00
Adrian Tong
ede5998fb7 Remove an unused MallocAllocator variable 2023-04-30 15:41:39 -07:00
Doug Gregor
a9c085fe62 Remove unused code 2023-04-30 10:14:44 -07:00
Pavel Yaskevich
366213d90c Merge pull request #65479 from xedin/rdar-108534555
[CSDiagnostics] Teach `diagnoseConflictingGenericArguments` about holes
2023-04-28 17:18:25 -07:00
Doug Gregor
00c67413fd Merge pull request #65509 from DougGregor/stored-property-aux-decls
Walk auxiliary declarations when gathering stored properties
2023-04-28 16:43:30 -07:00
Rintaro Ishizaki
5c2faf3228 [Macros] Don't expand macros inside macro expession arguments
Macro expressions nested in macro arguments should be type checked, but
should not be expanded.

rdar://108622244
2023-04-28 15:58:05 -07:00
Rintaro Ishizaki
ac218c2c5a Merge pull request #65453 from rintaro/macros-expandexpr-request-rdar108530760
[Macros] Requestify MacroExpansionExpr expansion
2023-04-28 15:57:40 -07:00
Doug Gregor
aff9751a12 Walk auxiliary declarations when gathering stored properties
Make sure we walk auxiliary declarations when gathering stored
properties. This ensures that we will get any stored properties
introduced by peer macros.

Fixes rdar://108534298.
2023-04-28 14:05:16 -07:00
Doug Gregor
3eaeafa022 Merge pull request #65501 from DougGregor/accessor-macro-subsume-init 2023-04-28 13:27:39 -07:00
Ellie Shin
2941051fe2 Merge pull request #65481 from apple/es-pkg-import
Limit loading error when importing a module built from interface with package-name
2023-04-28 12:55:07 -07:00
Doug Gregor
593c2364e8 [Macros] "Subsume" the initializer when an accessor macros adds non-observers
When an accessor macro adds a non-observing accessor to a property, it
subsumes the initializer. We had previously modeled this as removing
the initializer, but doing so means that the initializer could not be
used for type inference and was lost in the AST.

Explicitly mark the initializer as "subsumed" here, and be more
careful when querying the initializer to distinguish between "the
initializer that was written" and "the initializer that will execute"
in more places. This distinction already existed at the
pattern-binding level, but not at the variable-declaration level.

This is the proper fix for the circular reference issue described in
rdar://108565923 (test case in the prior commit).
2023-04-28 09:50:00 -07:00
Doug Gregor
7852c8ecac Revert "[Macros] Ensure that we compute the interface type before we add accessors"
This reverts commit ef7970bad3. We
shouldn't need this.
2023-04-28 08:36:02 -07:00
Ellie Shin
ceb2884183 Currently it errors when loading a module built from interface if it has package-name.
This disallows building an interface file that imports such module which should be allowed
since interface does not contain package symbols unless usableFromInline or inlinable.
This change limits erroring only when building a .swift file.

Resolves rdar://108633068
2023-04-27 16:25:11 -07:00
Pavel Yaskevich
0b7aeed4b8 [CSDiagnostics] Teach diagnoseConflictingGenericArguments about holes
Only fully resolved substitutions are eligible to be considered
as conflicting, if holes are involved in any position that automatically
disqualifies a generic parameter.

Resolves: rdar://108534555
Resolves: https://github.com/apple/swift/issues/63450
2023-04-27 14:58:26 -07:00
Allan Shortlidge
af059049bb Merge pull request #65456 from tshortli/improve-override-of-unavailable-diagnostics
Sema: Improve diagnostics for overrides of unavailable decls
2023-04-27 14:45:35 -07:00
Rintaro Ishizaki
35db928e89 [Macros] Requestify MacroExpansionExpr expansion
The request returns the expanded buffer ID even if it failed to
typecheck the expanded buffer.
This makes refactoring 'Expand Macro' work regardless of the
typechecking results.

rdar://108530760
2023-04-27 14:40:34 -07:00
Doug Gregor
1fbbd02d2a Merge pull request #65457 from DougGregor/macro-type-refinement-context 2023-04-26 23:40:24 -07:00
Allan Shortlidge
6e5562a6c8 Sema: Improve diagnostics for overrides of unavailable decls.
Unavailable decls cannot be overridden by available decls. This change improves
the compiler diagnostics for this restriction in a few ways:

- Duplicate diagnostics are suppressed for getters and setters inside property
  declarations that have already been diagnosed.
- Diagnostics are suppressed for implicit accessors since they would typically
  duplicate diagnostics for the explicit accessors the implicit ones are
  derived from.
- Decls inside unavailable a derived class are no longer incorrectly diagnosed.
2023-04-26 18:29:22 -07:00
Doug Gregor
879a10b860 [Macros] Ensure that the type refinement context accounts for macros
Make sure that we include all of the AST nodes from a macro expansion
buffer when building the type refinement context, not just the
declarations.
2023-04-26 18:27:10 -07:00
Doug Gregor
aa127f7535 [Type refinement context] Don't recurse into macro expansions.
Macro expansion buffers will have their type refinement contexts built
lazily, associated with the source file for the macro expansion
buffer. By not recursing into macro expansions, we break false
reference cycles among different files.

Fixes rdar://107394143
2023-04-26 16:06:36 -07:00
Pavel Yaskevich
dc8c05ac13 [Diagnostics] Suppress unused expression warning if result is discardable pack expansion
Examine pack expansion pattern to determine whether expression
result could be discarded without a warning (applies to tuples
with a single unlabeled pack expansion element as well).

Resolves: rdar://108064941
2023-04-26 13:43:49 -07:00
Allan Shortlidge
d18b2caa2b Merge pull request #65431 from tshortli/distributed-actor-swiftinterface
Sema: Relax distributed actor typechecking for swiftinterfaces
2023-04-26 13:38:31 -07:00
swift-ci
2ad15893eb Merge pull request #65434 from jreference/61440-no-generic-env-for-type-param
Sema: fix for 61440 (lib/AST/GenericEnvironment) no generic environme…
2023-04-26 12:01:17 -07:00
Richard Wei
69445e69ee Merge pull request #65429 from rxwei/108280416 2023-04-26 09:22:30 -07:00
Slava Pestov
dd0531e890 Merge pull request #65400 from slavapestov/generic-param-shadowing
Sema: Ban shadowing generic parameters from outer scopes
2023-04-26 12:08:51 -04:00
Allan Shortlidge
0e9b8a1e0a Sema: Relax distributed actor typechecking for swiftinterfaces.
Some decls that are expected to be synthesized for distributed actors are
printed explicitly in swiftinterfaces so diagnostics and assertions need to
take that possibility into account.

Resolves rdar://108533918
2023-04-26 08:44:44 -07:00
jreference
e18b40b743 Sema: fix for 61440 (lib/AST/GenericEnvironment) no generic environment provided for type with type parameter 2023-04-26 22:02:41 +08:00
swift-ci
f80c472ce2 Merge pull request #65412 from ktoso/wip-tryDiagnoseExecutor-must-survive-missing-job-type
[Concurrency] Handle missing Job type in old SDKs in tryDiagnoseExecutor
2023-04-25 20:00:19 -07:00
Richard Wei
3ba2f877ab [Macros] Diagnose top-level expansion of undefined freestanding macro
The root problem is that `ResolveMacroRequest` was shortcuting after calling `lookupMacros`. When type-checking a freestanding macro, it shouldn't need to call `lookupMacros` at all, but should go straight to CSGen.

rdar://108280416
2023-04-25 18:59:42 -07:00
Slava Pestov
290701cb4d Sema: Ban shadowing generic parameters from outer scopes
Code like that is usually indicative of programmer error, and does not
round-trip through module interface files since there is no source
syntax to refer to an outer generic parameter.

For source compatibility this is a warning, but becomes an error with
-swift-version 6.

Fixes rdar://problem/108385980 and https://github.com/apple/swift/issues/62767.
2023-04-25 17:41:23 -04:00
Doug Gregor
067e4ec501 Merge pull request #65410 from DougGregor/macro-cycle-break-part-deux 2023-04-25 06:37:24 -07:00
Konrad `ktoso` Malawski
e17cc50177 [Concurrency] Handle missing Job type in old SDKs in tryDiagnoseExecutor 2023-04-25 15:24:36 +09:00
Doug Gregor
1f6b3f6cb2 Only declarations that are members of a type or extension can have member attributes
The last step in breaking the cycle through visible declaration lookup,
e.g., with invalid code. Prior to this, we would get a false cyclic
reference through the parameters of a function when they try to find
property wrappers on the parameters.
2023-04-24 21:25:11 -07:00
Doug Gregor
4f6ab4b9dc Anchor the macro-resolution request on the declaration to which the macro is attached
The macro-resolution request for an attached macro was expressed in
terms of the custom attribute and the declaration context enclosing the
attribute. While the declaration context is the correct one for
resolving the types and arguments of the custom attribute, the
declaration provides a better anchor for cases where the same
attribute applies to multiple declarations, e.g., with
member-attribute macros, leading to false cyclic references.
2023-04-24 21:17:55 -07:00
Pavel Yaskevich
d6019ac466 Merge pull request #65366 from xedin/issue-65360
[CSSolver] Fix a crash in diagnostics related to pattern matching
2023-04-24 16:27:25 -07:00
nate-chandler
0c0ec72255 Merge pull request #65377 from nate-chandler/rdar108385761
[SILGen] Consuming a param implies it's eager-move.
2023-04-24 12:49:46 -07:00
Pavel Yaskevich
20d7642ca4 [CSGen] Allow expression pattern types to be holes 2023-04-24 10:02:00 -07:00
Nate Chandler
525541fd1c [Sema] Ban @_eagerMove on Copyable things. 2023-04-21 21:59:31 -07:00
Pavel Yaskevich
8a26df8166 [ConstraintSystem] NFC: Standardize the way of type holefication
Introduce `ConstraintSystem::recordTypeVariablesAsHoles` as a
standard way to record that unbound type variables found in a
type are holes in the given constraint system.
2023-04-21 15:22:13 -07:00
Pavel Yaskevich
b081bdbf57 [CSGen] Allow is pattern types to be holes 2023-04-21 12:14:41 -07:00
Pavel Yaskevich
70eeccb3cc [CSSimplify] Fix attempt to rebind type variables in sequence element pattern 2023-04-21 11:45:20 -07:00
Doug Gregor
ae4a5ded8f [Macros] Improve parsing, representation, and serialization of role attributes
Parse compound and special names in the macro role attributes
(`@freestanding` and `@attached`). This allows both compound names and
initializers, e.g., `init(coding:)`.

Fixes rdar://107967344.
2023-04-21 11:36:06 -07:00
Pavel Yaskevich
1c3667b52a Merge pull request #65310 from calda/cal--SE-3065-bad-pattern-check
[SE-0365] Fix issue where boolean condition before `let self` condition would prevent using implicit self
2023-04-21 09:54:27 -07:00
Alex Lorenz
346ba0153a Merge pull request #65338 from hyp/eng/enum-fix-indirect
[interop][SwiftToCxx] do not expose unsupported enums yet
2023-04-21 08:15:42 -07:00