Commit Graph

1705 Commits

Author SHA1 Message Date
Ellie Shin
c2bb890f63 Merge pull request #64488 from apple/es-load
Do not load modules of the same package if built from interface
2023-03-22 23:26:12 -07:00
Ellie Shin
fc2b61da71 - Do not load modules of the same package if built from interface.
- Show diagnostics with an interface path

Resolves rdar://104617990
2023-03-22 17:30:27 -07:00
Alexis Laferrière
599346885e [Serialization] Differentiate module loading behavior for non-public imports
Differentiate `internal` and `fileprivate` imports from
implementation-only imports at the module-wide level to offer a
different module loading strategy. The main difference is for non-public
imports from a module with testing enabled to be loaded by transitive
clients.

Ideally, we would only load transitive non-public dependencies on
testable imports of the middle module. The current module loading logic
doesn't allow for this behavior easily as a module may be first loaded
for a normal import and extra dependencies would have to be loaded on
later imports. We may want to refactor the module loading logic to allow
this if needed.

rdar://106514965
2023-03-21 16:46:53 -07:00
Alexis Laferrière
3e79583e4e Merge pull request #64404 from xymus/access-level-import-tests
[Sema] Reenable two access-level on imports tests
2023-03-16 12:56:33 -07:00
Kavon Farvardin
a8a44ebb17 Merge pull request #64106 from kavon/enable-moveonly-by-default
Enable moveonly / noncopyable types by default
2023-03-15 09:59:29 -07:00
Kavon Farvardin
2c7d9a5047 update tests given move-only types are enabled
the main things still left behind the experimental flag(s) are
- move-only classes (guarded by MoveOnlyClasses feature)
- noimplicitcopy
- the _borrow operator
2023-03-14 18:35:13 -07:00
Pavel Yaskevich
ed5984abe6 Merge pull request #64213 from xedin/rdar-104384604
[BuilderTransform] Verify that builder type has at least one accessible build{Partial}Block
2023-03-14 15:07:43 -07:00
Alexis Laferrière
f4d2d2a30f [Sema] Reenable access-level on imports tests 2023-03-14 09:35:24 -07:00
Kavon Farvardin
ea1e83b1d7 move noncopyable types out from behind the feature flag
Since these types depend on lexical borrow scopes (a SIL
option), we're now making that the requirement whenever
such types appear.
2023-03-13 22:39:31 -07:00
Michael Gottesman
40449a6987 [move-only] Emit a clearer message around deinits.
Specifically:

1. Fix the error message so that when we say you can't have a deinit that a
deinit can be on a noncopyable type along side a class or an actor.

2. Even though we already error on @objc enums and say they cannot be
noncopyable, we did not emit an error on the deinit saying that @objc enums
cannot have a deinit. I put in a nice to have error just to make it even
clearer.

rdar://105855978
rdar://106566054
2023-03-12 14:47:34 -07:00
Alexis Laferrière
c95e11c011 Merge pull request #64181 from xymus/res-dir-limitation 2023-03-08 17:13:02 -08:00
Pavel Yaskevich
6b323f1663 [BuilderTransform] Verify that builder type has at least one accessible build{Partial}Block
Check accessibility of all build{Partial}Block overloads and
diagnose if none of them are as accessible as type, otherwise
swift interfaces could end up with invalid result builder
declarations when type is public and all builder methods are
internal.

Resolves: rdar://104384604
2023-03-08 12:46:50 -08:00
Alexis Laferrière
109e93cb88 [Serialization] Allow rebuilding modules from the resource dir on SDK mismatch
Modules loaded from the resource dir are not usually rebuilt from the
swiftinterface as it would indicate a configuration problem. Lift that
behavior for SDK mismatch and still rebuild them.

This use case applies when a toolchain is used with a different SDK than
the one use to build the modules in the toolchain.

rdar://106101760
2023-03-07 10:00:27 -08:00
Kavon Farvardin
da3f2e2666 add addtl coverage for when the moveonly type is not used
We want to ensure that the deserialization error added
for this test doesn't trigger when the moveonly type
is not used by the importing module.

part of rdar://106262652
2023-03-06 17:42:55 -08:00
swift-ci
bdb484ac89 Merge pull request #64092 from meg-gupta/disabletests
Disabling tests failing in CI
2023-03-04 11:18:10 -08:00
Meghana Gupta
b262311f24 Disable access level import tests 2023-03-03 17:33:30 -08:00
Alexis Laferrière
4b14a8aab0 [Serialization] Test loading package dependencies 2023-03-03 11:43:21 -08:00
Alexis Laferrière
732a7f68e3 [Sema] Update test tracking dependencies of access-level on imports
This general test applies to all access-level. Let's precise that it
tests the scenario where a client is outside of the package to preserve
the current behavior. A new tests will check the behavior of a package
dependency for clients in package.
2023-03-03 11:42:59 -08:00
Sophia Poirier
70cffb06f3 [Variadic Generics] type parameter pack syntax change: T... -> each T 2023-03-02 14:42:28 -08:00
Alexis Laferrière
0d82ba3059 [ModuleInterface] Fixup tests about access-level on imports and dependencies 2023-03-01 14:41:11 -08:00
Alexis Laferrière
94aeb8c0ff [ModuleInterface] Hide non-public imports from a resilient module
When using access level on imports, consider non-public imports to be
implementation details not exposed to clients. As such, a client loading
a library doesn't need to load non-public transitive dependencies.

This behave like `@_implementationOnly imports` at a module-wide level,
but it is restricted to resilient modules only. An import with any
access-level in a non-resilient module remains visible to transitive
clients.
2023-03-01 00:11:59 -08:00
Richard Wei
ecc33865b9 [Macros] Fix MacroDecl serialization crash with custom parameter attributes
Type-check `MacroDecl`'s parameter list so that custom attributes on parameters will have a type. Fixes a serialization crash.
2023-02-23 05:00:28 +08:00
Holly Borla
f1953f311f [Macros] Don't invoke ResolveMacroRequest for the same custom attribute with
different DeclContexts.
2023-02-15 14:58:24 -08:00
Alexis Laferrière
9a1a32cd9b Merge pull request #63639 from xymus/serial-precise-tag
[Serialization] Don't fail the precise tag check if only the last digit doesn't match
2023-02-14 09:31:31 -08:00
Alexis Laferrière
a5ccbf3264 [Serialization] Only remark if the last digit mismatches in precise tag check
Weaken the precise tag check at loading swiftmodule to accept binary
modules build by a compiler with a tag where only the last digit is
different. We assume that the other digit in the version should ensure
compiler and stdlib compatibility. If the last digit doesn't match,
still raise a remark.

rdar://105158258
2023-02-13 14:28:10 -08:00
Alexis Laferrière
e079db233f [Serialization] Update env var to disable precise tag check
Rename the env var to SWIFT_IGNORE_SWIFTMODULE_REVISION as it's
recommended for use outside of testing.
2023-02-13 13:51:30 -08:00
Alexis Laferrière
62a646974f [Serialization] Move deserialization safety behind an env var or flag 2023-02-09 17:29:06 -08:00
Alexis Laferrière
09b06a8cd3 Revert "[Serialization] Enable deserialization safety by default"
This reverts commit af70cc5464.

# Conflicts:
#	test/Serialization/Safety/unsafe-decls.swift
2023-02-09 15:28:42 -08:00
Pavel Yaskevich
8eebb5bec1 Merge pull request #63522 from xedin/revert-type-wrappers
[AST/Sema/SIL] Revert TypeWrappers feature functionality
2023-02-09 09:27:18 -08:00
Erik Eckstein
d25b1ed834 Optimizer: Replace the MandatoryCombine pass with a Simplification pass, which is implemented in Swift
The Swift Simplification pass can do more than the old MandatoryCombine pass: simplification of more instruction types and dead code elimination.
The result is a better -Onone performance while still keeping debug info consistent.

Currently following code patterns are simplified:
* `struct` -> `struct_extract`
* `enum` -> `unchecked_enum_data`
* `partial_apply` -> `apply`
* `br` to a 1:1 related block
* `cond_br` with a constant condition
* `isConcrete` and `is_same_metadata` builtins

More simplifications can be added in the future.

rdar://96708429
rdar://104562580
2023-02-09 06:50:05 +01:00
Pavel Yaskevich
5dded3da73 [Tests] NFC: Remove test-cases associated with TypeWrappers feature 2023-02-08 10:14:34 -08:00
Pavel Yaskevich
e2b22d9f62 [AST/Sema] Remove TypeWrapper feature functionality 2023-02-08 00:16:00 -08:00
Alexis Laferrière
5786221be3 Merge pull request #63479 from xymus/opaque-safety
[Serialization] Evaluate the safety of opaque types
2023-02-07 13:28:44 -08:00
Alexis Laferrière
4c51052a80 [Serialization] Evaluate the safety of opaque types
Some compilation paths access the opaque return type type by itself
without going through its function. So access to the type must be
protected, otherwise deserialization fails at getting the naming decl
when it's unsafe.

rdar://105085860
2023-02-07 09:36:18 -08:00
Holly Borla
d6e4b707db [Macros] Update member attribute macro test cases to account for a change in
the MemberAttributeMacro protocol in SwiftSyntax.
2023-02-06 10:15:09 -08:00
Alexis Laferrière
d2f5449251 Merge pull request #63365 from xymus/testable-safety
[Serialization] Disable deserialization safety when testing is enabled
2023-02-02 14:01:32 -08:00
Allan Shortlidge
022abe4d3b NFC: Update tests to use accepted spelling for @backDeployed. 2023-02-01 22:04:33 -08:00
Alexis Laferrière
99747693a5 [Serialization] Disable deserialization safety when testing is enabled
Resilient modules with testing enabled expose internal non-resilient
internal types. These types cannot be reliably used by testable clients
if they don't have all of their members known. For this reason, this
disabled deserialization safety in modules when testing is enabled.

rdar://104923020
2023-02-01 19:37:25 -08:00
Alexis Laferrière
9c16b4b013 [Serialization] Drop overridden relationship in constructors when safe
Deserialization recovery lead the compiler to drop public constructors
overridding internal constructors. This limits the logic to dropping the
overriding relationship instead of the whole constructor. This applies
when the overriden constructor fails to deserialize and only when the
overriding relationship was marked as not affecting ABI.

rdar://104704832
2023-01-30 11:12:24 -08:00
Doug Gregor
182950bacb Update to account for SwiftSyntaxMacros module rename and overhaul 2023-01-28 09:00:54 -08:00
Holly Borla
32a0705e90 [Macros] Use the singular 'memberAttribute' spelling for attached member
attribute macros.
2023-01-26 21:52:39 -08:00
Doug Gregor
976060e29c Merge pull request #63220 from AtariDreams/deprecations
Fix DeclarationMacro deprecations
2023-01-26 17:04:08 -08:00
Doug Gregor
5a9a654adb Adopt @freestanding(expression) for all @expression macros 2023-01-25 17:07:38 -08:00
Rose
0a380cbba3 Fix DeclarationMacro deprecations
These deprecations are simple renames, but this PR should get rid of the warnings.
2023-01-25 13:50:02 -05:00
swift-ci
ca1f3f7a54 Merge pull request #63179 from kavon/moveonly-structs-or-enums
Limit `@_moveOnly` to structs and enums
2023-01-24 07:05:24 -08:00
Kavon Farvardin
1356694043 experimentally allow move-only classes
A lot of existing regression tests rely on there
being some form of move-only classes, despite
them being something that will not be available
to users (and not complete).

This change introduces a `MoveOnlyClasses`
experimental feature so that those tests don't
need to be fully rewritten just yet. You need to
include `-enable-experimental-feature MoveOnlyClasses` along with
`-enable-experimental-move-only` to get move-only classes.
2023-01-23 22:33:27 -08:00
Alexis Laferrière
a0ee5c5312 Merge pull request #63116 from xymus/deser-safety-by-default
[Serialization] Enable deserialization safety by default
2023-01-23 17:18:48 -08:00
Holly Borla
94abc252bf [Macros] Type-check attached macro arguments. 2023-01-22 11:26:02 -08:00
Alexis Laferrière
e032b3191d Merge pull request #63096 from xymus/deser-safety-writing
[Serialization] Introduce main deserialization safety logic, on the writer side
2023-01-19 13:22:25 -08:00
Alexis Laferrière
af70cc5464 [Serialization] Enable deserialization safety by default
rdar://99495048
2023-01-19 10:50:55 -08:00