Skip to content

Commit fcc22a1

Browse files
authored
Merge pull request #1210 from swiftwasm/maxd/master-merge
Resolve conflicts with master
2 parents 265111f + 6718018 commit fcc22a1

File tree

929 files changed

+11505
-5238
lines changed

Some content is hidden

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

929 files changed

+11505
-5238
lines changed

include/swift/AST/ASTNode.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace swift {
3030
class Stmt;
3131
class Decl;
3232
class Pattern;
33-
class TypeLoc;
33+
class TypeRepr;
3434
class DeclContext;
3535
class SourceLoc;
3636
class SourceRange;
@@ -41,7 +41,7 @@ namespace swift {
4141
enum class StmtKind;
4242

4343
struct ASTNode : public llvm::PointerUnion<Expr *, Stmt *, Decl *, Pattern *,
44-
TypeLoc *> {
44+
TypeRepr *> {
4545
// Inherit the constructors from PointerUnion.
4646
using PointerUnion::PointerUnion;
4747

include/swift/AST/Attr.h

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "swift/AST/PlatformKind.h"
3737
#include "swift/AST/Requirement.h"
3838
#include "swift/AST/TrailingCallArguments.h"
39-
#include "swift/AST/TypeLoc.h"
4039
#include "llvm/ADT/SmallVector.h"
4140
#include "llvm/ADT/StringRef.h"
4241
#include "llvm/Support/ErrorHandling.h"
@@ -56,6 +55,7 @@ class LazyConformanceLoader;
5655
class LazyMemberLoader;
5756
class PatternBindingInitializer;
5857
class TrailingWhereClause;
58+
class TypeExpr;
5959

6060
/// TypeAttributes - These are attributes that may be applied to types.
6161
class TypeAttributes {
@@ -1110,47 +1110,41 @@ class DynamicReplacementAttr final
11101110

11111111
/// The \c @_typeEraser(TypeEraserType) attribute.
11121112
class TypeEraserAttr final : public DeclAttribute {
1113-
TypeLoc TypeEraserLoc;
1113+
TypeExpr *TypeEraserExpr;
11141114
LazyMemberLoader *Resolver;
11151115
uint64_t ResolverContextData;
11161116

11171117
friend class ResolveTypeEraserTypeRequest;
11181118

1119-
TypeEraserAttr(SourceLoc atLoc, SourceRange range, TypeLoc typeEraserLoc,
1119+
TypeEraserAttr(SourceLoc atLoc, SourceRange range, TypeExpr *typeEraserExpr,
11201120
LazyMemberLoader *Resolver, uint64_t Data)
11211121
: DeclAttribute(DAK_TypeEraser, atLoc, range, /*Implicit=*/false),
1122-
TypeEraserLoc(typeEraserLoc),
1122+
TypeEraserExpr(typeEraserExpr),
11231123
Resolver(Resolver), ResolverContextData(Data) {}
11241124

11251125
public:
11261126
static TypeEraserAttr *create(ASTContext &ctx,
11271127
SourceLoc atLoc, SourceRange range,
1128-
TypeLoc typeEraserLoc);
1128+
TypeExpr *typeEraserRepr);
11291129

11301130
static TypeEraserAttr *create(ASTContext &ctx,
11311131
LazyMemberLoader *Resolver,
11321132
uint64_t Data);
11331133

11341134
/// Retrieve the parsed type repr for this attribute, if it
11351135
/// was parsed. Else returns \c nullptr.
1136-
TypeRepr *getParsedTypeEraserTypeRepr() const {
1137-
return TypeEraserLoc.getTypeRepr();
1138-
}
1136+
TypeRepr *getParsedTypeEraserTypeRepr() const;
11391137

11401138
/// Retrieve the parsed location for this attribute, if it was parsed.
1141-
SourceLoc getLoc() const {
1142-
return TypeEraserLoc.getLoc();
1143-
}
1139+
SourceLoc getLoc() const;
11441140

11451141
/// Retrieve the resolved type of this attribute if it has been resolved by a
11461142
/// successful call to \c getResolvedType(). Otherwise,
11471143
/// returns \c Type()
11481144
///
11491145
/// This entrypoint is only suitable for syntactic clients like the
11501146
/// AST printer. Semantic clients should use \c getResolvedType() instead.
1151-
Type getTypeWithoutResolving() const {
1152-
return TypeEraserLoc.getType();
1153-
}
1147+
Type getTypeWithoutResolving() const;
11541148

11551149
/// Returns \c true if the type eraser type has a valid implementation of the
11561150
/// erasing initializer for the given protocol.
@@ -1464,25 +1458,26 @@ class SpecializeAttr : public DeclAttribute {
14641458
/// The @_implements attribute, which treats a decl as the implementation for
14651459
/// some named protocol requirement (but otherwise not-visible by that name).
14661460
class ImplementsAttr : public DeclAttribute {
1467-
1468-
TypeLoc ProtocolType;
1461+
TypeExpr *ProtocolType;
14691462
DeclName MemberName;
14701463
DeclNameLoc MemberNameLoc;
14711464

14721465
public:
14731466
ImplementsAttr(SourceLoc atLoc, SourceRange Range,
1474-
TypeLoc ProtocolType,
1467+
TypeExpr *ProtocolType,
14751468
DeclName MemberName,
14761469
DeclNameLoc MemberNameLoc);
14771470

14781471
static ImplementsAttr *create(ASTContext &Ctx, SourceLoc atLoc,
14791472
SourceRange Range,
1480-
TypeLoc ProtocolType,
1473+
TypeExpr *ProtocolType,
14811474
DeclName MemberName,
14821475
DeclNameLoc MemberNameLoc);
14831476

1484-
TypeLoc getProtocolType() const;
1485-
TypeLoc &getProtocolType();
1477+
void setProtocolType(Type ty);
1478+
Type getProtocolType() const;
1479+
TypeRepr *getProtocolTypeRepr() const;
1480+
14861481
DeclName getMemberName() const { return MemberName; }
14871482
DeclNameLoc getMemberNameLoc() const { return MemberNameLoc; }
14881483

@@ -1595,27 +1590,27 @@ class ClangImporterSynthesizedTypeAttr : public DeclAttribute {
15951590
/// Defines a custom attribute.
15961591
class CustomAttr final : public DeclAttribute,
15971592
public TrailingCallArguments<CustomAttr> {
1598-
TypeLoc type;
1593+
TypeExpr *typeExpr;
15991594
Expr *arg;
16001595
PatternBindingInitializer *initContext;
16011596
Expr *semanticInit = nullptr;
16021597

16031598
unsigned hasArgLabelLocs : 1;
16041599
unsigned numArgLabels : 16;
16051600

1606-
CustomAttr(SourceLoc atLoc, SourceRange range, TypeLoc type,
1601+
CustomAttr(SourceLoc atLoc, SourceRange range, TypeExpr *type,
16071602
PatternBindingInitializer *initContext, Expr *arg,
16081603
ArrayRef<Identifier> argLabels, ArrayRef<SourceLoc> argLabelLocs,
16091604
bool implicit);
16101605

16111606
public:
1612-
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeLoc type,
1607+
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeExpr *type,
16131608
bool implicit = false) {
16141609
return create(ctx, atLoc, type, false, nullptr, SourceLoc(), { }, { }, { },
16151610
SourceLoc(), implicit);
16161611
}
16171612

1618-
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeLoc type,
1613+
static CustomAttr *create(ASTContext &ctx, SourceLoc atLoc, TypeExpr *type,
16191614
bool hasInitializer,
16201615
PatternBindingInitializer *initContext,
16211616
SourceLoc lParenLoc,
@@ -1628,8 +1623,8 @@ class CustomAttr final : public DeclAttribute,
16281623
unsigned getNumArguments() const { return numArgLabels; }
16291624
bool hasArgumentLabelLocs() const { return hasArgLabelLocs; }
16301625

1631-
TypeLoc &getTypeLoc() { return type; }
1632-
const TypeLoc &getTypeLoc() const { return type; }
1626+
TypeRepr *getTypeRepr() const;
1627+
Type getType() const;
16331628

16341629
Expr *getArg() const { return arg; }
16351630
void setArg(Expr *newArg) { arg = newArg; }
@@ -1642,6 +1637,14 @@ class CustomAttr final : public DeclAttribute,
16421637
static bool classof(const DeclAttribute *DA) {
16431638
return DA->getKind() == DAK_Custom;
16441639
}
1640+
1641+
private:
1642+
friend class CustomAttrNominalRequest;
1643+
void resetTypeInformation(TypeExpr *repr);
1644+
1645+
private:
1646+
friend class CustomAttrTypeRequest;
1647+
void setType(Type ty);
16451648
};
16461649

16471650
/// Relates a property to its projection value property, as described by a property wrapper. For

include/swift/AST/AutoDiff.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,8 @@ IndexSubset *getLoweredParameterIndices(IndexSubset *astParameterIndices,
521521
///
522522
/// Returns the "constrained" derivative/transpose generic signature given:
523523
/// - An original SIL function type.
524-
/// - Differentiability parameter indices.
525-
/// - A possibly "unconstrained" derivative generic signature.
524+
/// - Differentiability/linearity parameter indices.
525+
/// - A possibly "unconstrained" derivative/transpose generic signature.
526526
GenericSignature getConstrainedDerivativeGenericSignature(
527527
SILFunctionType *originalFnTy, IndexSubset *diffParamIndices,
528528
GenericSignature derivativeGenSig, LookupConformanceFn lookupConformance,

include/swift/AST/Decl.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2715,6 +2715,7 @@ class ValueDecl : public Decl {
27152715
/// Is this declaration marked with 'dynamic'?
27162716
bool isDynamic() const;
27172717

2718+
private:
27182719
bool isObjCDynamic() const {
27192720
return isObjC() && isDynamic();
27202721
}
@@ -2723,6 +2724,37 @@ class ValueDecl : public Decl {
27232724
return !isObjC() && isDynamic();
27242725
}
27252726

2727+
bool isObjCDynamicInGenericClass() const;
2728+
2729+
public:
2730+
/// Should we use Objective-C method dispatch for this decl.
2731+
bool shouldUseObjCDispatch() const {
2732+
return isObjCDynamic();
2733+
}
2734+
2735+
/// Should we use native dynamic function replacement dispatch for this decl.
2736+
bool shouldUseNativeDynamicDispatch() const {
2737+
return isNativeDynamic();
2738+
}
2739+
2740+
/// Should we use Objective-C category based function replacement for this
2741+
/// decl.
2742+
/// This is all `@objc dynamic` methods except for such methods in native
2743+
/// generic classes. We can't use a category for generic classes so we use
2744+
/// native replacement instead (this behavior is only enabled with
2745+
/// -enable-implicit-dynamic).
2746+
bool shouldUseObjCMethodReplacement() const;
2747+
2748+
/// Should we use native dynamic function replacement mechanism for this decl.
2749+
/// This is all native dynamic methods except for `@objc dynamic` methods in
2750+
/// generic classes (see above).
2751+
bool shouldUseNativeMethodReplacement() const;
2752+
2753+
/// Is this a native dynamic function replacement based replacement.
2754+
/// This is all @_dynamicReplacement(for:) of native functions and @objc
2755+
/// dynamic methods on generic classes (see above).
2756+
bool isNativeMethodReplacement() const;
2757+
27262758
bool isEffectiveLinkageMoreVisibleThan(ValueDecl *other) const {
27272759
return (std::min(getEffectiveAccess(), AccessLevel::Public) >
27282760
std::min(other->getEffectiveAccess(), AccessLevel::Public));

include/swift/AST/DiagnosticsCommon.def

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ NOTE(circular_type_resolution_note,none,
159159
// MARK: Cross-import overlay loading diagnostics
160160
//------------------------------------------------------------------------------
161161
ERROR(cannot_load_swiftoverlay_file, none,
162-
"cannot load cross-import overlay for %0 and %1: %2 (declared by '%3')",
163-
(Identifier, Identifier, StringRef, StringRef))
162+
"cannot load cross-import overlay for '%0' and '%1': %2 (declared by '%3')",
163+
(StringRef, StringRef, StringRef, StringRef))
164164
ERROR(cannot_list_swiftcrossimport_dir, none,
165-
"cannot list cross-import overlays for %0: %1 (declared in '%2')",
166-
(Identifier, StringRef, StringRef))
165+
"cannot list cross-import overlays for '%0': %1 (declared in '%2')",
166+
(StringRef, StringRef, StringRef))
167167
WARNING(cross_imported_by_both_modules, none,
168168
"modules %0 and %1 both declare module %2 as a cross-import overlay, "
169169
"which may cause paradoxical behavior when looking up names in them; "

include/swift/AST/DiagnosticsSema.def

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ ERROR(could_not_find_enum_case,none,
9494

9595
NOTE(did_you_mean_raw_type,none,
9696
"did you mean to specify a raw type on the enum declaration?", ())
97+
98+
NOTE(did_you_mean_generic_param_as_conformance,none,
99+
"did you mean to declare %0 as a protocol conformance for %1?", (DeclName, Type))
97100

98101
NOTE(any_as_anyobject_fixit, none,
99102
"cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members", ())
@@ -5075,8 +5078,8 @@ ERROR(function_builder_infer_ambig, none,
50755078
NOTE(function_builder_infer_add_return, none,
50765079
"add an explicit 'return' statement to not use a function builder", ())
50775080
NOTE(function_builder_infer_pick_specific, none,
5078-
"apply function builder %0 (inferred from protocol %1)",
5079-
(Type, DeclName))
5081+
"apply function builder %0 (inferred from %select{protocol|dynamic replacement of}1 %2)",
5082+
(Type, unsigned, DeclName))
50805083

50815084
//------------------------------------------------------------------------------
50825085
// MARK: Tuple Shuffle Diagnostics

0 commit comments

Comments
 (0)