Skip to content

Commit c39b58d

Browse files
Merge pull request #4465 from swiftwasm/main
[pull] swiftwasm from main
2 parents 353db38 + bf41986 commit c39b58d

File tree

152 files changed

+800
-551
lines changed

Some content is hidden

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

152 files changed

+800
-551
lines changed

include/swift/AST/Decl.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4875,12 +4875,22 @@ class AbstractStorageDecl : public ValueDecl {
48754875
return getImplInfo().supportsMutation();
48764876
}
48774877

4878-
/// isSettable - Determine whether references to this decl may appear
4879-
/// on the left-hand side of an assignment or as the operand of a
4880-
/// `&` or 'inout' operator.
4878+
/// Determine whether references to this storage declaration may appear
4879+
/// on the left-hand side of an assignment, as the operand of a
4880+
/// `&` or 'inout' operator, or as a component in a writable key path.
48814881
bool isSettable(const DeclContext *UseDC,
48824882
const DeclRefExpr *base = nullptr) const;
48834883

4884+
/// Determine whether references to this storage declaration in Swift may
4885+
/// appear on the left-hand side of an assignment, as the operand of a
4886+
/// `&` or 'inout' operator, or as a component in a writable key path.
4887+
///
4888+
/// This method is equivalent to \c isSettable with the exception of
4889+
/// 'optional' storage requirements, which lack support for direct writes
4890+
/// in Swift.
4891+
bool isSettableInSwift(const DeclContext *UseDC,
4892+
const DeclRefExpr *base = nullptr) const;
4893+
48844894
/// Does this storage declaration have explicitly-defined accessors
48854895
/// written in the source?
48864896
bool hasParsedAccessors() const;
@@ -7989,6 +7999,17 @@ inline bool AbstractStorageDecl::isSettable(const DeclContext *UseDC,
79897999
return sd->supportsMutation();
79908000
}
79918001

8002+
inline bool
8003+
AbstractStorageDecl::isSettableInSwift(const DeclContext *UseDC,
8004+
const DeclRefExpr *base) const {
8005+
// TODO: Writing to an optional storage requirement is not supported in Swift.
8006+
if (getAttrs().hasAttribute<OptionalAttr>()) {
8007+
return false;
8008+
}
8009+
8010+
return isSettable(UseDC, base);
8011+
}
8012+
79928013
inline void
79938014
AbstractStorageDecl::overwriteSetterAccess(AccessLevel accessLevel) {
79948015
Accessors.setInt(accessLevel);

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ NOTE(unwrap_with_guard,none,
11601160
ERROR(optional_base_not_unwrapped,none,
11611161
"value of optional type %0 must be unwrapped to refer to member %1 of "
11621162
"wrapped base type %2", (Type, DeclNameRef, Type))
1163-
ERROR(invalid_optional_infered_keypath_root, none,
1163+
ERROR(invalid_optional_inferred_keypath_root, none,
11641164
"key path root inferred as optional type %0 must be unwrapped to refer to member %1 "
11651165
"of unwrapped type %2", (Type, DeclNameRef, Type))
11661166
NOTE(optional_base_chain,none,
@@ -4028,7 +4028,7 @@ ERROR(passing_noattrfunc_to_attrfunc,none,
40284028
"passing %select{non-escaping|non-sendable}0 parameter %1 to function "
40294029
"expecting %select{an @escaping|a @Sendable}0 closure",
40304030
(unsigned, Identifier))
4031-
ERROR(converting_noespace_param_to_generic_type,none,
4031+
ERROR(converting_noescape_param_to_generic_type,none,
40324032
"converting non-escaping parameter %0 to generic parameter %1 may allow it to escape",
40334033
(Identifier, Type))
40344034
ERROR(assigning_noattrfunc_to_attrfunc,none,
@@ -5654,7 +5654,7 @@ ERROR(attr_requires_availability_for_platform,none,
56545654
// This doesn't display as an availability diagnostic, but it's
56555655
// implemented there and fires when these subscripts are marked
56565656
// unavailable, so it seems appropriate to put it here.
5657-
ERROR(availabilty_string_subscript_migration, none,
5657+
ERROR(availability_string_subscript_migration, none,
56585658
"subscripts returning String were obsoleted in Swift 4; explicitly "
56595659
"construct a String from subscripted result", ())
56605660

include/swift/AST/ExtInfo.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ class ASTExtInfoBuilder {
358358

359359
constexpr Representation getRepresentation() const {
360360
unsigned rawRep = bits & RepresentationMask;
361-
assert(rawRep <= unsigned(Representation::Last) &&
362-
"unexpected SIL representation");
363361
return Representation(rawRep);
364362
}
365363

include/swift/AST/NameLookup.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,11 @@ SmallVector<InheritedNominalEntry, 4> getDirectlyInheritedNominalTypeDecls(
548548
SelfBounds getSelfBoundsFromWhereClause(
549549
llvm::PointerUnion<const TypeDecl *, const ExtensionDecl *> decl);
550550

551+
/// Retrieve the set of nominal type declarations that appear as the
552+
/// constraint type of any "Self" constraints in the generic signature of the
553+
/// given protocol or protocol extension.
554+
SelfBounds getSelfBoundsFromGenericSignature(const ExtensionDecl *extDecl);
555+
551556
/// Retrieve the TypeLoc at the given \c index from among the set of
552557
/// type declarations that are directly "inherited" by the given declaration.
553558
inline const TypeLoc &getInheritedTypeLocAtIndex(

include/swift/AST/NameLookupRequests.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,22 @@ class SelfBoundsFromWhereClauseRequest
270270
llvm::PointerUnion<const TypeDecl *, const ExtensionDecl *>) const;
271271
};
272272

273+
/// Request the nominal types that occur as the right-hand side of "Self: Foo"
274+
/// constraints in the generic signature of a protocol extension.
275+
class SelfBoundsFromGenericSignatureRequest
276+
: public SimpleRequest<SelfBoundsFromGenericSignatureRequest,
277+
SelfBounds(const ExtensionDecl *),
278+
RequestFlags::Uncached> {
279+
public:
280+
using SimpleRequest::SimpleRequest;
281+
282+
private:
283+
friend SimpleRequest;
284+
285+
// Evaluation.
286+
SelfBounds evaluate(Evaluator &evaluator, const ExtensionDecl *extDecl) const;
287+
};
288+
273289
/// Request all type aliases and nominal types that appear in the "where"
274290
/// clause of an extension.
275291
class TypeDeclsFromWhereClauseRequest :

include/swift/AST/NameLookupTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ SWIFT_REQUEST(NameLookup, SelfBoundsFromWhereClauseRequest,
6868
SelfBounds(llvm::PointerUnion<const TypeDecl *,
6969
const ExtensionDecl *>),
7070
Uncached, NoLocationInfo)
71+
SWIFT_REQUEST(NameLookup, SelfBoundsFromGenericSignatureRequest,
72+
SelfBounds(const ExtensionDecl * extDecl),
73+
Uncached, NoLocationInfo)
7174
SWIFT_REQUEST(NameLookup, SuperclassDeclRequest, ClassDecl *(NominalTypeDecl *),
7275
SeparatelyCached, NoLocationInfo)
7376
SWIFT_REQUEST(NameLookup, HasMissingDesignatedInitializersRequest,

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,6 @@ namespace swift {
759759
/// parameters of closures.
760760
bool EnableOneWayClosureParameters = false;
761761

762-
/// Enable experimental support for type inference through multi-statement
763-
/// closures.
764-
bool EnableMultiStatementClosureInference = true;
765-
766762
/// See \ref FrontendOptions.PrintFullConvention
767763
bool PrintFullConvention = false;
768764
};

include/swift/Frontend/Frontend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ class CompilerInstance {
606606
void setupStatsReporter();
607607
void setupDependencyTrackerIfNeeded();
608608

609-
/// \return false if successsful, true on error.
609+
/// \return false if successful, true on error.
610610
bool setupDiagnosticVerifierIfNeeded();
611611

612612
Optional<unsigned> setUpCodeCompletionBuffer();

include/swift/Frontend/FrontendInputsAndOutputs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class FrontendInputsAndOutputs {
142142
assertMustNotBeMoreThanOnePrimaryInputUnlessBatchModeChecksHaveBeenBypassed()
143143
const;
144144

145-
// Count-dependend readers:
145+
// Count-dependent readers:
146146

147147
/// \return the unique primary input, if one exists.
148148
const InputFile *getUniquePrimaryInput() const;

include/swift/Frontend/FrontendOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,8 @@ class FrontendOptions {
444444
bool IncludeSPISymbolsInSymbolGraph = false;
445445

446446
/// Whether to reuse a frontend (i.e. compiler instance) for multiple
447-
/// compiletions. This prevents ASTContext being freed.
448-
bool ReuseFrontendForMutipleCompilations = false;
447+
/// compilations. This prevents ASTContext being freed.
448+
bool ReuseFrontendForMultipleCompilations = false;
449449

450450
/// This is used to obfuscate the serialized search paths so we don't have
451451
/// to encode the actual paths into the .swiftmodule file.

0 commit comments

Comments
 (0)