Skip to content

Commit afc8954

Browse files
Merge pull request #4601 from swiftwasm/main
[pull] swiftwasm from main
2 parents 12f8b3d + b4dceb6 commit afc8954

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+791
-158
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,13 @@ to track the status of our builds, please refer to our [GitHub Actions page](htt
2828
| **macOS** | x86_64 |[![Build Status](https://ci.swift.org/job/oss-swift-incremental-RA-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-incremental-RA-macos)|[![Build Status](https://ci.swift.org/job/oss-swift-package-macos/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-macos)|
2929
| **Ubuntu 18.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-18_04)|
3030
| **Ubuntu 20.04** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|[![Build Status](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-ubuntu-20_04)|
31-
| **CentOS 8** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|[![Build Status](https://ci.swift.org/job/oss-swift-package-centos-8/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-8)|
3231
| **CentOS 7** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-centos-7/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-7)|[![Build Status](https://ci.swift.org/job/oss-swift-package-centos-7/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-centos-7)|
3332
| **Amazon Linux 2** | x86_64 | [![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2)|[![Build Status](https://ci.swift.org/job/oss-swift-package-amazon-linux-2/lastCompletedBuild/badge/icon)](https://ci.swift.org/job/oss-swift-package-amazon-linux-2)|
3433

3534
**Swift Community-Hosted CI Platforms**
3635

3736
| **OS** | **Architecture** | **Build** |
3837
|---|:---:|:---:|
39-
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le)|
4038
|**[Ubuntu 20.04](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/wasm32_ubuntu_20.04.json)** | wasm32 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-20.04-webassembly/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-20.04-webassembly)|
4139
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
4240
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/main/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64)|

docs/LibraryEvolution.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ the following changes are permitted:
366366
- Adding or removing a conformance to a non-ABI-public protocol.
367367
- Adding ``@dynamicCallable`` to the struct.
368368

369-
The important most aspect of a Swift struct is its value semantics, not its
369+
The most important aspect of a Swift struct is its value semantics, not its
370370
layout. Note that adding a stored property to a struct is *not* a breaking
371371
change even with Swift's synthesis of memberwise and no-argument initializers;
372372
these initializers are always ``internal`` and thus not exposed to clients

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ ERROR(error_unsupported_target_os, none,
3636
ERROR(error_unsupported_target_arch, none,
3737
"unsupported target architecture: '%0'", (StringRef))
3838

39+
ERROR(error_experimental_feature_not_available, none,
40+
"experimental feature '%0' cannot be enabled in a production compiler",
41+
(StringRef))
42+
3943
ERROR(error_unknown_library_level, none,
4044
"unknown library level '%0', "
4145
"expected one of 'api', 'spi' or 'other'", (StringRef))

include/swift/AST/DiagnosticsSema.def

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6330,5 +6330,19 @@ ERROR(attr_incompatible_with_back_deploy,none,
63306330
"'%0' cannot be applied to a back deployed %1",
63316331
(DeclAttribute, DescriptiveDeclKind))
63326332

6333+
//------------------------------------------------------------------------------
6334+
// MARK: Implicit opening of existential types
6335+
//------------------------------------------------------------------------------
6336+
6337+
ERROR(result_requires_explicit_coercion,none,
6338+
"inferred result type %0 requires explicit coercion due to "
6339+
"loss of generic requirements",
6340+
(Type))
6341+
6342+
NOTE(candidate_result_requires_explicit_coercion,none,
6343+
"inferred result type %0 requires explicit coercion due to "
6344+
"loss of generic requirements",
6345+
(Type))
6346+
63336347
#define UNDEFINE_DIAGNOSTIC_MACROS
63346348
#include "DefineDiagnosticMacros.h"

include/swift/Basic/Feature.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818
namespace swift {
1919

2020
class LangOptions;
21-
21+
2222
/// Enumeration describing all of the named features.
2323
enum class Feature {
2424
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
25-
FeatureName,
26-
#include "swift/Basic/Features.def"
25+
FeatureName,
26+
#include "swift/Basic/Features.def"
2727
};
2828

2929
constexpr unsigned numFeatures() {
3030
enum Features {
3131
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option) \
32-
FeatureName,
32+
FeatureName,
3333
#include "swift/Basic/Features.def"
3434
NumFeatures
3535
};
@@ -51,6 +51,10 @@ inline bool featureImpliesFeature(Feature feature, Feature implied) {
5151
return (unsigned) feature < (unsigned) implied;
5252
}
5353

54+
/// Get the feature corresponding to this "experimental" feature, if there is
55+
/// one.
56+
llvm::Optional<Feature> getExperimentalFeature(llvm::StringRef name);
57+
5458
}
5559

5660
#endif // SWIFT_BASIC_FEATURES_H

include/swift/Basic/Features.def

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@
4848
LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
4949
#endif
5050

51-
LANGUAGE_FEATURE(StaticAssert, 0, "#assert", langOpts.EnableExperimentalStaticAssert)
51+
#ifndef EXPERIMENTAL_FEATURE
52+
# define EXPERIMENTAL_FEATURE(FeatureName) \
53+
LANGUAGE_FEATURE(FeatureName, 0, #FeatureName, \
54+
langOpts.hasFeature(#FeatureName))
55+
#endif
56+
5257
LANGUAGE_FEATURE(AsyncAwait, 296, "async/await", true)
5358
LANGUAGE_FEATURE(EffectfulProp, 310, "Effectful properties", true)
5459
LANGUAGE_FEATURE(MarkerProtocol, 0, "@_marker protocol", true)
@@ -78,5 +83,14 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated
7883
SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync", true)
7984
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)", true)
8085

86+
EXPERIMENTAL_FEATURE(StaticAssert)
87+
EXPERIMENTAL_FEATURE(VariadicGenerics)
88+
EXPERIMENTAL_FEATURE(NamedOpaqueTypes)
89+
EXPERIMENTAL_FEATURE(FlowSensitiveConcurrencyCaptures)
90+
EXPERIMENTAL_FEATURE(MoveOnly)
91+
EXPERIMENTAL_FEATURE(OneWayClosureParameters)
92+
EXPERIMENTAL_FEATURE(TypeWitnessSystemInference)
93+
94+
#undef EXPERIMENTAL_FEATURE
8195
#undef SUPPRESSIBLE_LANGUAGE_FEATURE
8296
#undef LANGUAGE_FEATURE

include/swift/Basic/LangOptions.h

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
#ifndef SWIFT_BASIC_LANGOPTIONS_H
1919
#define SWIFT_BASIC_LANGOPTIONS_H
2020

21+
#include "swift/Basic/Feature.h"
2122
#include "swift/Basic/FunctionBodySkipping.h"
2223
#include "swift/Basic/LLVM.h"
2324
#include "swift/Basic/Version.h"
2425
#include "swift/Config.h"
2526
#include "llvm/ADT/ArrayRef.h"
2627
#include "llvm/ADT/Hashing.h"
2728
#include "llvm/ADT/SmallString.h"
29+
#include "llvm/ADT/SmallSet.h"
2830
#include "llvm/ADT/SmallVector.h"
2931
#include "llvm/ADT/StringRef.h"
3032
#include "llvm/ADT/Triple.h"
@@ -312,23 +314,13 @@ namespace swift {
312314
/// Specifies how strict concurrency checking will be.
313315
StrictConcurrency StrictConcurrencyLevel = StrictConcurrency::Targeted;
314316

315-
/// Enable experimental #assert feature.
316-
bool EnableExperimentalStaticAssert = false;
317-
318317
/// Enable experimental concurrency model.
319318
bool EnableExperimentalConcurrency = false;
320319

321-
/// Enable experimental support for named opaque result types, e.g.
322-
/// `func f() -> <T> T`.
323-
bool EnableExperimentalNamedOpaqueTypes = false;
324-
325320
/// Enable support for implicitly opening existential argument types
326321
/// in calls to generic functions.
327322
bool EnableOpenedExistentialTypes = false;
328323

329-
/// Enable experimental flow-sensitive concurrent captures.
330-
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
331-
332324
/// Disable experimental ClangImporter diagnostics.
333325
bool DisableExperimentalClangImporterDiagnostics = false;
334326

@@ -338,16 +330,6 @@ namespace swift {
338330
/// Enable inference of Sendable conformances for public types.
339331
bool EnableInferPublicSendable = false;
340332

341-
/// Enable experimental 'move only' features.
342-
bool EnableExperimentalMoveOnly = false;
343-
344-
/// Enable variadic generics.
345-
bool EnableExperimentalVariadicGenerics = false;
346-
347-
/// Enable experimental associated type inference using type witness
348-
/// systems.
349-
bool EnableExperimentalAssociatedTypeInference = false;
350-
351333
/// Disable the implicit import of the _Concurrency module.
352334
bool DisableImplicitConcurrencyModuleImport =
353335
!SWIFT_IMPLICIT_CONCURRENCY_IMPORT;
@@ -369,6 +351,9 @@ namespace swift {
369351
/// behavior. This is a staging flag, and will be removed in the future.
370352
bool EnableNewOperatorLookup = false;
371353

354+
/// The set of features that have been enabled.
355+
llvm::SmallSet<Feature, 2> Features;
356+
372357
/// Use Clang function types for computing canonical types.
373358
/// If this option is false, the clang function types will still be computed
374359
/// but will not be used for checking type equality.
@@ -616,6 +601,13 @@ namespace swift {
616601
return EffectiveLanguageVersion.isVersionAtLeast(major, minor);
617602
}
618603

604+
/// Determine whether the given feature is enabled.
605+
bool hasFeature(Feature feature) const;
606+
607+
/// Determine whether the given feature is enabled, looking up the feature
608+
/// by name.
609+
bool hasFeature(llvm::StringRef featureName) const;
610+
619611
/// Returns true if the given platform condition argument represents
620612
/// a supported target operating system.
621613
///
@@ -725,10 +717,6 @@ namespace swift {
725717
/// Disable constraint system performance hacks.
726718
bool DisableConstraintSolverPerformanceHacks = false;
727719

728-
/// Enable experimental support for one-way constraints for the
729-
/// parameters of closures.
730-
bool EnableOneWayClosureParameters = false;
731-
732720
/// See \ref FrontendOptions.PrintFullConvention
733721
bool PrintFullConvention = false;
734722
};

include/swift/Option/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,11 @@ def strict_concurrency : Joined<["-"], "strict-concurrency=">,
691691
"concurrency model, or 'complete' ('Sendable' and other checking is "
692692
"enabled for all code in the module)">;
693693

694+
def enable_experimental_feature :
695+
Separate<["-"], "enable-experimental-feature">,
696+
Flags<[FrontendOption]>,
697+
HelpText<"Enable an experimental feature">;
698+
694699
def Rpass_EQ : Joined<["-"], "Rpass=">,
695700
Flags<[FrontendOption]>,
696701
HelpText<"Report performed transformations by optimization passes whose "

include/swift/Sema/CSFix.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ enum class FixKind : uint8_t {
394394
/// Ignore a type mismatch while trying to infer generic parameter type
395395
/// from default expression.
396396
IgnoreDefaultExprTypeMismatch,
397+
398+
/// Coerce a result type of a call to a particular existential type
399+
/// by adding `as any <#Type#>`.
400+
AddExplicitExistentialCoercion,
397401
};
398402

399403
class ConstraintFix {
@@ -2981,6 +2985,37 @@ class IgnoreDefaultExprTypeMismatch : public AllowArgumentMismatch {
29812985
}
29822986
};
29832987

2988+
class AddExplicitExistentialCoercion final : public ConstraintFix {
2989+
Type ErasedResultType;
2990+
2991+
AddExplicitExistentialCoercion(ConstraintSystem &cs, Type erasedResultTy,
2992+
ConstraintLocator *locator)
2993+
: ConstraintFix(cs, FixKind::AddExplicitExistentialCoercion, locator),
2994+
ErasedResultType(erasedResultTy) {}
2995+
2996+
public:
2997+
std::string getName() const override {
2998+
return "add explicit existential type coercion";
2999+
}
3000+
3001+
bool diagnose(const Solution &solution, bool asNote = false) const override;
3002+
3003+
static bool
3004+
isRequired(ConstraintSystem &cs, Type resultTy,
3005+
ArrayRef<std::pair<TypeVariableType *, OpenedArchetypeType *>>
3006+
openedExistentials,
3007+
ConstraintLocatorBuilder locator);
3008+
3009+
static bool isRequired(ConstraintSystem &cs, Type resultTy,
3010+
llvm::function_ref<Optional<Type>(TypeVariableType *)>
3011+
findExistentialType,
3012+
ConstraintLocatorBuilder locator);
3013+
3014+
static AddExplicitExistentialCoercion *create(ConstraintSystem &cs,
3015+
Type resultTy,
3016+
ConstraintLocator *locator);
3017+
};
3018+
29843019
} // end namespace constraints
29853020
} // end namespace swift
29863021

lib/AST/ASTPrinter.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,30 @@ static bool usesFeatureNoAsyncAvailability(Decl *decl) {
29992999
return decl->getAttrs().getNoAsync(decl->getASTContext()) != nullptr;
30003000
}
30013001

3002+
static bool usesFeatureVariadicGenerics(Decl *decl) {
3003+
return false;
3004+
}
3005+
3006+
static bool usesFeatureNamedOpaqueTypes(Decl *decl) {
3007+
return false;
3008+
}
3009+
3010+
static bool usesFeatureFlowSensitiveConcurrencyCaptures(Decl *decl) {
3011+
return false;
3012+
}
3013+
3014+
static bool usesFeatureMoveOnly(Decl *decl) {
3015+
return false;
3016+
}
3017+
3018+
static bool usesFeatureOneWayClosureParameters(Decl *decl) {
3019+
return false;
3020+
}
3021+
3022+
static bool usesFeatureTypeWitnessSystemInference(Decl *decl) {
3023+
return false;
3024+
}
3025+
30023026
static void
30033027
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
30043028
llvm::function_ref<void()> action) {

lib/Basic/LangOptions.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,20 @@ bool LangOptions::isCustomConditionalCompilationFlagSet(StringRef Name) const {
224224
!= CustomConditionalCompilationFlags.end();
225225
}
226226

227+
bool LangOptions::hasFeature(Feature feature) const {
228+
if (Features.contains(feature))
229+
return true;
230+
231+
return false;
232+
}
233+
234+
bool LangOptions::hasFeature(llvm::StringRef featureName) const {
235+
if (auto feature = getExperimentalFeature(featureName))
236+
return hasFeature(*feature);
237+
238+
return false;
239+
}
240+
227241
std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
228242
clearAllPlatformConditionValues();
229243

@@ -409,6 +423,15 @@ bool swift::isSuppressibleFeature(Feature feature) {
409423
llvm_unreachable("covered switch");
410424
}
411425

426+
llvm::Optional<Feature> swift::getExperimentalFeature(llvm::StringRef name) {
427+
return llvm::StringSwitch<Optional<Feature>>(name)
428+
#define LANGUAGE_FEATURE(FeatureName, SENumber, Description, Option)
429+
#define EXPERIMENTAL_FEATURE(FeatureName) \
430+
.Case(#FeatureName, Feature::FeatureName)
431+
#include "swift/Basic/Features.def"
432+
.Default(None);
433+
}
434+
412435
DiagnosticBehavior LangOptions::getAccessNoteFailureLimit() const {
413436
switch (AccessNoteBehavior) {
414437
case AccessNoteDiagnosticBehavior::Ignore:

lib/Driver/ToolChains.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void ToolChain::addCommonFrontendArgs(const OutputInfo &OI,
236236
options::OPT_disable_actor_data_race_checks);
237237
inputArgs.AddLastArg(arguments, options::OPT_warn_concurrency);
238238
inputArgs.AddLastArg(arguments, options::OPT_strict_concurrency);
239+
inputArgs.AddAllArgs(arguments, options::OPT_enable_experimental_feature);
239240
inputArgs.AddLastArg(arguments, options::OPT_warn_implicit_overrides);
240241
inputArgs.AddLastArg(arguments, options::OPT_typo_correction_limit);
241242
inputArgs.AddLastArg(arguments, options::OPT_enable_app_extension);

0 commit comments

Comments
 (0)