Skip to content

Commit 33012c3

Browse files
Merge pull request #4330 from swiftwasm/main
[pull] swiftwasm from main
2 parents 3554800 + 9664560 commit 33012c3

File tree

82 files changed

+1590
-532
lines changed

Some content is hidden

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

82 files changed

+1590
-532
lines changed

include/swift/AST/Attr.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
494494
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
495495
84)
496496
DECL_ATTR(_custom, Custom,
497-
OnAnyDecl | UserInaccessible |
497+
OnAnyDecl | RejectByParser |
498498
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
499499
85)
500500
SIMPLE_DECL_ATTR(propertyWrapper, PropertyWrapper,
@@ -718,7 +718,7 @@ DECL_ATTR(exclusivity, Exclusivity,
718718
128)
719719

720720
DECL_ATTR(_backDeploy, BackDeploy,
721-
OnAbstractFunction |
721+
OnAbstractFunction | OnAccessor | OnSubscript | OnVar |
722722
AllowMultipleAttributes | LongAttribute | UserInaccessible |
723723
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIBreakingToRemove,
724724
129)

include/swift/AST/Decl.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,11 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
825825
/// This function won't consider the parent context to get the information.
826826
Optional<llvm::VersionTuple> getIntroducedOSVersion(PlatformKind Kind) const;
827827

828+
/// Returns the OS version in which the decl became ABI as specified by the
829+
/// @_backDeploy attribute.
830+
Optional<llvm::VersionTuple>
831+
getBackDeployBeforeOSVersion(PlatformKind Kind) const;
832+
828833
/// Returns the starting location of the entire declaration.
829834
SourceLoc getStartLoc() const { return getSourceRange().Start; }
830835

@@ -998,12 +1003,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
9981003
/// deployment target.
9991004
bool isWeakImported(ModuleDecl *fromModule) const;
10001005

1001-
/// Returns true if the nature of this declaration allows overrides.
1002-
/// Note that this does not consider whether it is final or whether
1003-
/// the class it's on is final.
1006+
/// Returns true if the nature of this declaration allows overrides syntactically.
10041007
///
10051008
/// If this returns true, the decl can be safely casted to ValueDecl.
1006-
bool isPotentiallyOverridable() const;
1009+
bool isSyntacticallyOverridable() const;
10071010

10081011
/// Retrieve the global actor attribute that applies to this declaration,
10091012
/// if any.
@@ -7930,13 +7933,16 @@ inline unsigned ValueDecl::getNumCurryLevels() const {
79307933
return curryLevels;
79317934
}
79327935

7933-
inline bool Decl::isPotentiallyOverridable() const {
7936+
inline bool Decl::isSyntacticallyOverridable() const {
79347937
if (isa<VarDecl>(this) ||
79357938
isa<SubscriptDecl>(this) ||
79367939
isa<FuncDecl>(this) ||
79377940
isa<DestructorDecl>(this)) {
7941+
if (static_cast<const ValueDecl*>(this)->isFinal()) {
7942+
return false;
7943+
}
79387944
auto classDecl = getDeclContext()->getSelfClassDecl();
7939-
return classDecl && !classDecl->isActor();
7945+
return classDecl && !classDecl->isActor() && !classDecl->isFinal();
79407946
} else {
79417947
return false;
79427948
}

include/swift/AST/DiagnosticsSema.def

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,26 +1599,12 @@ WARNING(option_set_zero_constant,none,
15991599
NOTE(option_set_empty_set_init,none,
16001600
"use [] to silence this warning", ())
16011601

1602-
// FIXME(backDeploy): Refactor to share with back deployment attr
1603-
ERROR(originally_defined_in_dupe_platform,none,
1604-
"duplicate version number for platform %0", (StringRef))
1605-
16061602
ERROR(originally_definedin_topleve_decl,none,
16071603
"@%0 is only applicable to top-level decl", (StringRef))
16081604

1609-
// FIXME(backDeploy): Refactor to share with back deployment attr
1610-
ERROR(originally_definedin_need_available,none,
1611-
"need @available attribute for @%0", (StringRef))
1612-
16131605
ERROR(originally_definedin_must_not_before_available_version,none,
16141606
"symbols are moved to the current module before they were available in the OSs", (StringRef))
16151607

1616-
// FIXME(backDeploy): Refactor to share with back deployment attr
1617-
WARNING(originally_defined_in_on_non_public,
1618-
none, "@%0 does not have any effect on "
1619-
"%select{private|fileprivate|internal|%error|%error}1 declarations",
1620-
(StringRef, AccessLevel))
1621-
16221608
// Alignment attribute
16231609
ERROR(alignment_not_power_of_two,none,
16241610
"alignment value must be a power of two", ())
@@ -3139,10 +3125,28 @@ ERROR(attr_not_on_variadic_parameters,none,
31393125
"'%0' must not be used on variadic parameters", (StringRef))
31403126
ERROR(attr_not_on_subscript_parameters,none,
31413127
"'%0' must not be used on subscript parameters", (StringRef))
3128+
ERROR(attr_not_on_stored_properties,none,
3129+
"'%0' must not be used on stored properties", (DeclAttribute))
3130+
3131+
WARNING(attr_has_no_effect_on_decl_with_access_level,none,
3132+
"'%0' does not have any effect on "
3133+
"%select{private|fileprivate|internal|%error|%error}1 declarations",
3134+
(DeclAttribute, AccessLevel))
3135+
ERROR(attr_not_on_decl_with_invalid_access_level,none,
3136+
"'%0' may not be used on "
3137+
"%select{private|fileprivate|internal|%error|%error}1 declarations",
3138+
(DeclAttribute, AccessLevel))
3139+
3140+
ERROR(attr_has_no_effect_decl_not_available_before,none,
3141+
"'%0' has no effect because %1 is not available before %2 %3",
3142+
(DeclAttribute, DeclName, StringRef, llvm::VersionTuple))
31423143

31433144
ERROR(attr_ambiguous_reference_to_decl,none,
31443145
"ambiguous reference to %0 in '@%1' attribute", (DeclNameRef, StringRef))
31453146

3147+
ERROR(attr_contains_multiple_versions_for_platform,none,
3148+
"'%0' contains multiple versions for %1", (DeclAttribute, StringRef))
3149+
31463150
ERROR(override_final,none,
31473151
"%0 overrides a 'final' %1", (DescriptiveDeclKind, DescriptiveDeclKind))
31483152

@@ -3157,6 +3161,10 @@ ERROR(final_not_allowed_here,none,
31573161
"'final' may only be applied to classes, properties, methods, and "
31583162
"subscripts", ())
31593163

3164+
ERROR(attr_incompatible_with_non_final,none,
3165+
"'%0' cannot be applied to a non-final %1",
3166+
(DeclAttribute, DescriptiveDeclKind))
3167+
31603168
ERROR(final_not_on_accessors,none,
31613169
"'final' cannot be applied to accessors, it must be put on the "
31623170
"%select{var|let|subscript}0", (unsigned))
@@ -5615,6 +5623,14 @@ ERROR(availability_macro_in_inlinable, none,
56155623
"availability macro cannot be used in inlinable %0",
56165624
(DescriptiveDeclKind))
56175625

5626+
ERROR(attr_requires_decl_availability_for_platform,none,
5627+
"'%0' requires that %1 have explicit availability for %2",
5628+
(DeclAttribute, DeclName, StringRef))
5629+
5630+
ERROR(attr_requires_availability_for_platform,none,
5631+
"'%0' requires explicit availability for %1",
5632+
(DeclAttribute, StringRef))
5633+
56185634
// This doesn't display as an availability diagnostic, but it's
56195635
// implemented there and fires when these subscripts are marked
56205636
// unavailable, so it seems appropriate to put it here.
@@ -6164,6 +6180,10 @@ ERROR(differentiable_programming_attr_used_without_required_module, none,
61646180
"'@%0' attribute used without importing module %1",
61656181
(StringRef, Identifier))
61666182

6183+
//------------------------------------------------------------------------------
6184+
// MARK: OSLog
6185+
//------------------------------------------------------------------------------
6186+
61676187
ERROR(oslog_arg_must_be_bool_literal, none,
61686188
"argument must be a bool literal", ())
61696189
ERROR(oslog_arg_must_be_integer_literal, none,
@@ -6271,5 +6291,13 @@ ERROR(cannot_convert_default_value_type_to_argument_type, none,
62716291
"cannot convert default value of type %0 to expected argument type %1 for parameter #%2",
62726292
(Type, Type, unsigned))
62736293

6294+
//------------------------------------------------------------------------------
6295+
// MARK: Back deployment
6296+
//------------------------------------------------------------------------------
6297+
6298+
ERROR(attr_incompatible_with_back_deploy,none,
6299+
"'%0' cannot be applied to a back deployed %1",
6300+
(DeclAttribute, DescriptiveDeclKind))
6301+
62746302
#define UNDEFINE_DIAGNOSTIC_MACROS
62756303
#include "DefineDiagnosticMacros.h"

include/swift/AST/SILOptions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ class SILOptions {
172172
/// Emit a mapping of profile counters for use in coverage.
173173
bool EmitProfileCoverageMapping = false;
174174

175+
bool emitTBD = false;
176+
175177
/// Should we use a pass pipeline passed in via a json file? Null by default.
176178
llvm::StringRef ExternalPassPipelineFilename;
177179

include/swift/IDE/DotExprCompletion.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,17 @@ class DotExprTypeCheckCompletionCallback : public TypeCheckCompletionCallback {
3333
bool IsImplicitSingleExpressionReturn;
3434
};
3535

36-
DeclContext *DC;
3736
CodeCompletionExpr *CompletionExpr;
3837
SmallVector<Result, 4> Results;
3938
llvm::DenseMap<std::pair<Type, Decl *>, size_t> BaseToSolutionIdx;
40-
bool GotCallback = false;
4139

4240
public:
43-
DotExprTypeCheckCompletionCallback(DeclContext *DC,
44-
CodeCompletionExpr *CompletionExpr)
45-
: DC(DC), CompletionExpr(CompletionExpr) {}
46-
47-
/// True if at least one solution was passed via the \c sawSolution
48-
/// callback.
49-
bool gotCallback() const { return GotCallback; }
41+
DotExprTypeCheckCompletionCallback(CodeCompletionExpr *CompletionExpr)
42+
: CompletionExpr(CompletionExpr) {}
5043

5144
/// Typecheck the code completion expression in isolation, calling
5245
/// \c sawSolution for each solution formed.
53-
void fallbackTypeCheck();
46+
void fallbackTypeCheck(DeclContext *DC) override;
5447

5548
void sawSolution(const constraints::Solution &solution) override;
5649

include/swift/IDE/UnresolvedMemberCompletion.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,12 @@ class UnresolvedMemberTypeCheckCompletionCallback
3333
CodeCompletionExpr *CompletionExpr;
3434
SmallVector<ExprResult, 4> ExprResults;
3535
SmallVector<Type, 1> EnumPatternTypes;
36-
bool GotCallback = false;
3736

3837
public:
3938
UnresolvedMemberTypeCheckCompletionCallback(
4039
CodeCompletionExpr *CompletionExpr)
4140
: CompletionExpr(CompletionExpr) {}
4241

43-
/// True if at least one solution was passed via the \c sawSolution
44-
/// callback.
45-
bool gotCallback() const { return GotCallback; }
46-
47-
/// Typecheck the code completion expression in its outermost expression
48-
/// context, calling \c sawSolution for each solution formed.
49-
void fallbackTypeCheck(DeclContext *DC);
50-
5142
void sawSolution(const constraints::Solution &solution) override;
5243

5344
void deliverResults(DeclContext *DC, SourceLoc DotLoc,

include/swift/Sema/CodeCompletionTypeChecking.h

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,24 @@ namespace swift {
3636
}
3737

3838
class TypeCheckCompletionCallback {
39+
bool GotCallback = false;
40+
3941
public:
42+
virtual ~TypeCheckCompletionCallback() {}
43+
4044
/// Called for each solution produced while type-checking an expression
4145
/// that the code completion expression participates in.
42-
virtual void sawSolution(const constraints::Solution &solution) = 0;
43-
virtual ~TypeCheckCompletionCallback() {}
46+
virtual void sawSolution(const constraints::Solution &solution) {
47+
GotCallback = true;
48+
};
49+
50+
/// True if at least one solution was passed via the \c sawSolution
51+
/// callback.
52+
bool gotCallback() const { return GotCallback; }
53+
54+
/// Typecheck the code completion expression in its outermost expression
55+
/// context, calling \c sawSolution for each solution formed.
56+
virtual void fallbackTypeCheck(DeclContext *DC);
4457
};
4558
}
4659

0 commit comments

Comments
 (0)