Skip to content

Commit b9ba416

Browse files
committed
Merge branch 'master' of github.com:swiftwasm/swift into maxd/master-merge
# Conflicts: # test/lit.cfg
2 parents 627df41 + 1f85c04 commit b9ba416

File tree

66 files changed

+1600
-266
lines changed

Some content is hidden

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

66 files changed

+1600
-266
lines changed

include/swift/AST/Decl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5232,6 +5232,12 @@ class VarDecl : public AbstractStorageDecl {
52325232
Optional<PropertyWrapperMutability>
52335233
getPropertyWrapperMutability() const;
52345234

5235+
/// Returns whether this property is the backing storage property or a storage
5236+
/// wrapper for wrapper instance's projectedValue. If this property is
5237+
/// neither, then it returns `None`.
5238+
Optional<PropertyWrapperSynthesizedPropertyKind>
5239+
getPropertyWrapperSynthesizedPropertyKind() const;
5240+
52355241
/// Retrieve the backing storage property for a property that has an
52365242
/// attached property wrapper.
52375243
///

include/swift/AST/DiagnosticsSema.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,12 +760,20 @@ ERROR(invalid_redecl,none,"invalid redeclaration of %0", (DeclName))
760760
ERROR(invalid_redecl_init,none,
761761
"invalid redeclaration of synthesized %select{|memberwise }1%0",
762762
(DeclName, bool))
763+
ERROR(invalid_redecl_implicit,none,
764+
"invalid redeclaration of synthesized "
765+
"%select{%0|implementation for protocol requirement}1 %2",
766+
(DescriptiveDeclKind, bool, DeclName))
763767
WARNING(invalid_redecl_swift5_warning,none,
764768
"redeclaration of %0 is deprecated and will be an error in Swift 5",
765769
(DeclName))
766770

767771
NOTE(invalid_redecl_prev,none,
768772
"%0 previously declared here", (DeclName))
773+
NOTE(invalid_redecl_implicit_wrapper,none,
774+
"%0 synthesized for property wrapper "
775+
"%select{projected value|backing storage}1",
776+
(DeclName, bool))
769777

770778
ERROR(ambiguous_type_base,none,
771779
"%0 is ambiguous for type lookup in this context", (DeclNameRef))

include/swift/AST/GenericSignature.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ class alignas(1 << TypeAlignInBits) GenericSignatureImpl final
329329
/// Determine whether the given dependent type is equal to a concrete type.
330330
bool isConcreteType(Type type) const;
331331

332-
/// Return the concrete type that the given dependent type is constrained to,
332+
/// Return the concrete type that the given type parameter is constrained to,
333333
/// or the null Type if it is not the subject of a concrete same-type
334334
/// constraint.
335335
Type getConcreteType(Type type) const;
336336

337-
/// Return the layout constraint that the given dependent type is constrained
337+
/// Return the layout constraint that the given type parameter is constrained
338338
/// to, or the null LayoutConstraint if it is not the subject of layout
339339
/// constraint.
340340
LayoutConstraint getLayoutConstraint(Type type) const;

include/swift/Parse/ParseSILSupport.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ namespace swift {
2020

2121
/// Interface between the Parse and ParseSIL libraries, to avoid circular
2222
/// dependencies.
23-
class SILParserTUStateBase {
23+
class SILParserStateBase {
2424
virtual void anchor();
2525
protected:
26-
SILParserTUStateBase() = default;
27-
virtual ~SILParserTUStateBase() = default;
26+
SILParserStateBase() = default;
27+
virtual ~SILParserStateBase() = default;
2828
public:
2929
virtual bool parseDeclSIL(Parser &P) = 0;
3030
virtual bool parseDeclSILStage(Parser &P) = 0;

include/swift/Parse/Parser.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace swift {
5050
class Lexer;
5151
class ParsedTypeSyntax;
5252
class PersistentParserState;
53-
class SILParserTUStateBase;
53+
class SILParserStateBase;
5454
class ScopeInfo;
5555
class SourceManager;
5656
class TupleType;
@@ -114,7 +114,7 @@ class Parser {
114114
DiagnosticEngine &Diags;
115115
SourceFile &SF;
116116
Lexer *L;
117-
SILParserTUStateBase *SIL; // Non-null when parsing SIL decls.
117+
SILParserStateBase *SIL; // Non-null when parsing SIL decls.
118118
PersistentParserState *State;
119119
std::unique_ptr<PersistentParserState> OwnedState;
120120
DeclContext *CurDeclContext;
@@ -396,14 +396,13 @@ class Parser {
396396

397397
public:
398398
Parser(unsigned BufferID, SourceFile &SF, DiagnosticEngine* LexerDiags,
399-
SILParserTUStateBase *SIL,
400-
PersistentParserState *PersistentState,
399+
SILParserStateBase *SIL, PersistentParserState *PersistentState,
401400
std::shared_ptr<SyntaxParseActions> SPActions = nullptr);
402-
Parser(unsigned BufferID, SourceFile &SF, SILParserTUStateBase *SIL,
401+
Parser(unsigned BufferID, SourceFile &SF, SILParserStateBase *SIL,
403402
PersistentParserState *PersistentState = nullptr,
404403
std::shared_ptr<SyntaxParseActions> SPActions = nullptr);
405404
Parser(std::unique_ptr<Lexer> Lex, SourceFile &SF,
406-
SILParserTUStateBase *SIL = nullptr,
405+
SILParserStateBase *SIL = nullptr,
407406
PersistentParserState *PersistentState = nullptr,
408407
std::shared_ptr<SyntaxParseActions> SPActions = nullptr);
409408
~Parser();

include/swift/Subsystems.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ namespace swift {
5858
class SerializationOptions;
5959
class SILOptions;
6060
class SILModule;
61-
class SILParserTUState;
6261
class SourceFile;
6362
enum class SourceFileKind;
6463
class SourceManager;
@@ -74,17 +73,6 @@ namespace swift {
7473
class TypeConverter;
7574
}
7675

77-
/// Used to optionally maintain SIL parsing context for the parser.
78-
///
79-
/// When not parsing SIL, this has no overhead.
80-
class SILParserState {
81-
public:
82-
std::unique_ptr<SILParserTUState> Impl;
83-
84-
explicit SILParserState(SILModule *M);
85-
~SILParserState();
86-
};
87-
8876
/// @{
8977

9078
/// \returns true if the declaration should be verified. This can return

lib/AST/Decl.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5970,6 +5970,17 @@ VarDecl::getPropertyWrapperMutability() const {
59705970
None);
59715971
}
59725972

5973+
Optional<PropertyWrapperSynthesizedPropertyKind>
5974+
VarDecl::getPropertyWrapperSynthesizedPropertyKind() const {
5975+
if (getOriginalWrappedProperty(
5976+
PropertyWrapperSynthesizedPropertyKind::Backing))
5977+
return PropertyWrapperSynthesizedPropertyKind::Backing;
5978+
if (getOriginalWrappedProperty(
5979+
PropertyWrapperSynthesizedPropertyKind::StorageWrapper))
5980+
return PropertyWrapperSynthesizedPropertyKind::StorageWrapper;
5981+
return None;
5982+
}
5983+
59735984
VarDecl *VarDecl::getPropertyWrapperBackingProperty() const {
59745985
return getPropertyWrapperBackingPropertyInfo().backingVar;
59755986
}
@@ -6494,9 +6505,13 @@ ParamDecl::getDefaultValueStringRepresentation(
64946505
return getASTContext().SourceMgr.extractText(charRange);
64956506
}
64966507

6497-
// If there is no parent initializer, we used the default initializer.
6498-
auto parentInit = original->getParentInitializer();
6499-
if (!parentInit) {
6508+
// If there is no initial wrapped value, we used the default initializer.
6509+
Expr *wrappedValue = nullptr;
6510+
if (auto *parentInit = original->getParentInitializer())
6511+
if (auto *placeholder = findWrappedValuePlaceholder(parentInit))
6512+
wrappedValue = placeholder->getOriginalWrappedValue();
6513+
6514+
if (!wrappedValue) {
65006515
if (auto type = original->getPropertyWrapperBackingPropertyType()) {
65016516
if (auto nominal = type->getAnyNominal()) {
65026517
scratch.clear();
@@ -6511,9 +6526,8 @@ ParamDecl::getDefaultValueStringRepresentation(
65116526
return ".init()";
65126527
}
65136528

6514-
auto init =
6515-
findWrappedValuePlaceholder(parentInit)->getOriginalWrappedValue();
6516-
return extractInlinableText(getASTContext().SourceMgr, init, scratch);
6529+
auto &sourceMgr = getASTContext().SourceMgr;
6530+
return extractInlinableText(sourceMgr, wrappedValue, scratch);
65176531
}
65186532
}
65196533

lib/AST/GenericSignature.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ Type GenericSignatureImpl::getSuperclassBound(Type type) const {
428428
/// required to conform.
429429
GenericSignature::RequiredProtocols
430430
GenericSignatureImpl::getRequiredProtocols(Type type) const {
431-
if (!type->isTypeParameter()) return { };
431+
assert(type->isTypeParameter() && "Expected a type parameter");
432432

433433
auto &builder = *getGenericSignatureBuilder();
434434
auto equivClass =
@@ -479,11 +479,11 @@ bool GenericSignatureImpl::isConcreteType(Type type) const {
479479
return bool(getConcreteType(type));
480480
}
481481

482-
/// Return the concrete type that the given dependent type is constrained to,
482+
/// Return the concrete type that the given type parameter is constrained to,
483483
/// or the null Type if it is not the subject of a concrete same-type
484484
/// constraint.
485485
Type GenericSignatureImpl::getConcreteType(Type type) const {
486-
if (!type->isTypeParameter()) return Type();
486+
assert(type->isTypeParameter() && "Expected a type parameter");
487487

488488
auto &builder = *getGenericSignatureBuilder();
489489
auto equivClass =
@@ -496,7 +496,8 @@ Type GenericSignatureImpl::getConcreteType(Type type) const {
496496
}
497497

498498
LayoutConstraint GenericSignatureImpl::getLayoutConstraint(Type type) const {
499-
if (!type->isTypeParameter()) return LayoutConstraint();
499+
assert(type->isTypeParameter() &&
500+
"Only type parameters can have layout constraints");
500501

501502
auto &builder = *getGenericSignatureBuilder();
502503
auto equivClass =

lib/AST/SubstitutionMap.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ Type SubstitutionMap::lookupSubstitution(CanSubstitutableType type) const {
271271

272272
// The generic parameter may have been made concrete by the generic signature,
273273
// substitute into the concrete type.
274-
if (auto concreteType = genericSig->getConcreteType(genericParam)){
274+
if (auto concreteType = genericSig->getConcreteType(genericParam)) {
275275
// Set the replacement type to an error, to block infinite recursion.
276276
replacementType = ErrorType::get(concreteType);
277277

lib/IDE/ExprContextAnalysis.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -656,21 +656,22 @@ class ExprContextAnalyzer {
656656
if (memberDC && ty->hasTypeParameter())
657657
ty = memberDC->mapTypeIntoContext(ty);
658658

659+
bool canSkip =
660+
paramList && (paramList->get(Pos)->isDefaultArgument() ||
661+
paramList->get(Pos)->isVariadic());
662+
659663
if (paramType.hasLabel() && MayNeedName) {
660-
bool isDefaulted = paramList &&
661-
paramList->get(Pos)->isDefaultArgument();
662664
if (seenArgs.insert({paramType.getLabel(), ty.getPointer()}).second)
663-
recordPossibleParam(&paramType, !isDefaulted);
664-
if (isDefaulted)
665-
continue;
665+
recordPossibleParam(&paramType, !canSkip);
666666
} else {
667667
auto argTy = ty;
668668
if (paramType.isInOut())
669669
argTy = InOutType::get(argTy);
670670
if (seenTypes.insert(argTy.getPointer()).second)
671671
recordPossibleType(argTy);
672672
}
673-
break;
673+
if (!canSkip)
674+
break;
674675
}
675676
// If the argument position is out of expeceted number, indicate that
676677
// with optional nullptr param.
@@ -980,11 +981,13 @@ class ExprContextAnalyzer {
980981
case ExprKind::Binary:
981982
case ExprKind::PrefixUnary:
982983
case ExprKind::Assign:
983-
case ExprKind::Array:
984984
case ExprKind::Dictionary:
985985
case ExprKind::If:
986986
case ExprKind::UnresolvedMember:
987987
return true;
988+
case ExprKind::Array:
989+
return (!Parent.getAsExpr() ||
990+
!isa<VarargExpansionExpr>(Parent.getAsExpr()));
988991
case ExprKind::Tuple: {
989992
auto ParentE = Parent.getAsExpr();
990993
return !ParentE ||

0 commit comments

Comments
 (0)