Skip to content

Commit 75d0ff5

Browse files
authored
---
yaml --- r: 349290 b: refs/heads/master-next c: 91e4c0e h: refs/heads/master
1 parent b650372 commit 75d0ff5

Some content is hidden

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

51 files changed

+1299
-936
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: cf526b4adaa5b6ec8ceb6074ec948ada9507dd64
3+
refs/heads/master-next: 91e4c0e9234fc9f6d177955190f5e1261ac555fa
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/docs/CToSwiftNameTranslation.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -370,19 +370,6 @@ extension Counter {
370370
}
371371
```
372372

373-
The getter/setter syntax also allows for subscripts by using the base name `subscript`.
374-
375-
```objc
376-
__attribute__((swift_name("getter:LinkedListOfInts.subscript(self:_:)")))
377-
int LinkedListGetAtIndex(const LinkedListOfInts *head, int index);
378-
```
379-
380-
```swift
381-
extension LinkedListOfInts {
382-
subscript(_ index: Int32) -> Int32 { get }
383-
}
384-
```
385-
386373
Finally, functions can be imported as initializers as well by using the base name `init`. These are considered "factory" initializers and are never inherited or overridable. They must not have a `self` parameter.
387374

388375
```objc

branches/master-next/include/swift/AST/Decl.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,11 @@ class ExtensionDecl final : public GenericContext, public Decl,
16781678
TypeRepr *ExtendedTypeRepr;
16791679

16801680
/// The nominal type being extended.
1681-
NominalTypeDecl *ExtendedNominal = nullptr;
1681+
///
1682+
/// The bit indicates whether binding has been attempted. The pointer can be
1683+
/// null if either no binding was attempted or if binding could not find the
1684+
/// extended nominal.
1685+
llvm::PointerIntPair<NominalTypeDecl *, 1, bool> ExtendedNominal;
16821686

16831687
MutableArrayRef<TypeLoc> Inherited;
16841688

@@ -1738,6 +1742,12 @@ class ExtensionDecl final : public GenericContext, public Decl,
17381742
SourceRange getBraces() const { return Braces; }
17391743
void setBraces(SourceRange braces) { Braces = braces; }
17401744

1745+
bool hasBeenBound() const { return ExtendedNominal.getInt(); }
1746+
1747+
void setExtendedNominal(NominalTypeDecl *n) {
1748+
ExtendedNominal.setPointerAndInt(n, true);
1749+
}
1750+
17411751
/// Retrieve the type being extended.
17421752
///
17431753
/// Only use this entry point when the complete type, as spelled in the source,
@@ -1746,8 +1756,21 @@ class ExtensionDecl final : public GenericContext, public Decl,
17461756
Type getExtendedType() const;
17471757

17481758
/// Retrieve the nominal type declaration that is being extended.
1759+
/// Will trip an assertion if the declaration has not already been computed.
1760+
/// In order to fail fast when type checking work is attempted
1761+
/// before extension binding has taken place.
1762+
17491763
NominalTypeDecl *getExtendedNominal() const;
17501764

1765+
/// Compute the nominal type declaration that is being extended.
1766+
NominalTypeDecl *computeExtendedNominal() const;
1767+
1768+
/// \c hasBeenBound means nothing if this extension can never been bound
1769+
/// because it is not at the top level.
1770+
bool canNeverBeBound() const;
1771+
1772+
bool hasValidParent() const;
1773+
17511774
/// Determine whether this extension has already been bound to a nominal
17521775
/// type declaration.
17531776
bool alreadyBoundToNominal() const { return NextExtension.getInt(); }

branches/master-next/include/swift/AST/DeclContext.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
470470
/// AnyObject dynamic lookup.
471471
bool mayContainMembersAccessedByDynamicLookup() const;
472472

473+
/// Extensions are only allowed at the level in a file
474+
/// FIXME: do this for Protocols, too someday
475+
bool canBeParentOfExtension() const;
476+
473477
/// Returns true if lookups within this context could affect downstream files.
474478
///
475479
/// \param functionsAreNonCascading If true, functions are considered non-

branches/master-next/include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,9 +3647,6 @@ ERROR(sugar_type_not_found,none,
36473647
"broken standard library: cannot find "
36483648
"%select{Array|Optional|ImplicitlyUnwrappedOptional|Dictionary|"
36493649
"Error}0 type", (unsigned))
3650-
ERROR(pointer_type_not_found,none,
3651-
"broken standard library: cannot find "
3652-
"%select{UnsafePointer|UnsafeMutablePointer}0 type", (unsigned))
36533650
ERROR(optional_intrinsics_not_found,none,
36543651
"broken standard library: cannot find intrinsic operations on "
36553652
"Optional<T>", ())

branches/master-next/include/swift/AST/Types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,12 @@ class alignas(1 << TypeAlignInBits) TypeBase {
706706
PointerTypeKind Ignore;
707707
return getAnyPointerElementType(Ignore);
708708
}
709+
710+
/// Returns a type representing a pointer to \c this.
711+
///
712+
/// \p kind must not be a raw pointer kind, since that would discard the
713+
/// current type.
714+
Type wrapInPointer(PointerTypeKind kind);
709715

710716
/// Determine whether the given type is "specialized", meaning that
711717
/// it involves generic types for which generic arguments have been provided.

branches/master-next/include/swift/Basic/ExternalUnion.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -433,27 +433,27 @@ struct MembersHelper<> {
433433

434434
LLVM_ATTRIBUTE_ALWAYS_INLINE
435435
static void copyConstruct(void *self, int index, const void *other) {
436-
llvm_unreachable("bad index");
436+
assert(false && "bad index");
437437
}
438438

439439
LLVM_ATTRIBUTE_ALWAYS_INLINE
440440
static void moveConstruct(void *self, int index, void *other) {
441-
llvm_unreachable("bad index");
441+
assert(false && "bad index");
442442
}
443443

444444
LLVM_ATTRIBUTE_ALWAYS_INLINE
445445
static void copyAssignSame(int index, void *self, const void *other) {
446-
llvm_unreachable("bad index");
446+
assert(false && "bad index");
447447
}
448448

449449
LLVM_ATTRIBUTE_ALWAYS_INLINE
450450
static void moveAssignSame(int index, void *self, void *other) {
451-
llvm_unreachable("bad index");
451+
assert(false && "bad index");
452452
}
453453

454454
LLVM_ATTRIBUTE_ALWAYS_INLINE
455455
static void destruct(int index, void *self) {
456-
llvm_unreachable("bad index");
456+
assert(false && "bad index");
457457
}
458458
};
459459

branches/master-next/include/swift/Parse/ParsedRawSyntaxNode.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ class ParsedRawSyntaxNode {
109109
}
110110

111111
ParsedRawSyntaxNode(syntax::SyntaxKind k, tok tokKind,
112-
CharSourceRange r, OpaqueSyntaxNode n)
112+
CharSourceRange r, OpaqueSyntaxNode n,
113+
bool IsMissing = false)
113114
: RecordedData{n, r},
114115
SynKind(uint16_t(k)), TokKind(uint16_t(tokKind)),
115-
DK(DataKind::Recorded) {
116+
DK(DataKind::Recorded),
117+
IsMissing(IsMissing) {
116118
assert(getKind() == k && "Syntax kind with too large value!");
117119
assert(getTokenKind() == tokKind && "Token kind with too large value!");
118120
}
@@ -197,12 +199,14 @@ class ParsedRawSyntaxNode {
197199
return copy;
198200
}
199201

200-
CharSourceRange getDeferredRange() const {
202+
CharSourceRange getDeferredRange(bool includeTrivia) const {
201203
switch (DK) {
202204
case DataKind::DeferredLayout:
203-
return getDeferredLayoutRange();
205+
return getDeferredLayoutRange(includeTrivia);
204206
case DataKind::DeferredToken:
205-
return getDeferredTokenRange();
207+
return includeTrivia
208+
? getDeferredTokenRangeWithTrivia()
209+
: getDeferredTokenRange();
206210
default:
207211
llvm_unreachable("node not deferred");
208212
}
@@ -227,18 +231,19 @@ class ParsedRawSyntaxNode {
227231

228232
// Deferred Layout Data ====================================================//
229233

230-
CharSourceRange getDeferredLayoutRange() const {
234+
CharSourceRange getDeferredLayoutRange(bool includeTrivia) const {
231235
assert(DK == DataKind::DeferredLayout);
232-
assert(!DeferredLayout.Children.empty());
233-
auto getLastNonNullChild = [this]() -> const ParsedRawSyntaxNode & {
234-
for (auto &Child : llvm::reverse(getDeferredChildren()))
235-
if (!Child.isNull())
236-
return Child;
237-
llvm_unreachable("layout node without non-null children");
236+
auto HasValidRange = [includeTrivia](const ParsedRawSyntaxNode &Child) {
237+
return !Child.isNull() && !Child.isMissing() &&
238+
Child.getDeferredRange(includeTrivia).isValid();
238239
};
239-
auto firstRange = DeferredLayout.Children.front().getDeferredRange();
240-
auto lastRange = getLastNonNullChild().getDeferredRange();
241-
firstRange.widen(lastRange);
240+
auto first = llvm::find_if(getDeferredChildren(), HasValidRange);
241+
if (first == getDeferredChildren().end())
242+
return CharSourceRange();
243+
auto last = llvm::find_if(llvm::reverse(getDeferredChildren()),
244+
HasValidRange);
245+
auto firstRange = first->getDeferredRange(includeTrivia);
246+
firstRange.widen(last->getDeferredRange(includeTrivia));
242247
return firstRange;
243248
}
244249
ArrayRef<ParsedRawSyntaxNode> getDeferredChildren() const {

branches/master-next/include/swift/Parse/ParsedRawSyntaxRecorder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ class ParsedRawSyntaxRecorder {
7373
/// Used for incremental re-parsing.
7474
ParsedRawSyntaxNode lookupNode(size_t lexerOffset, SourceLoc loc,
7575
syntax::SyntaxKind kind);
76+
77+
#ifndef NDEBUG
78+
static void verifyElementRanges(ArrayRef<ParsedRawSyntaxNode> elements);
79+
#endif
7680
};
7781

7882
} // end namespace swift

branches/master-next/include/swift/Parse/ParsedSyntaxBuilders.h.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public:
6262
% end
6363

6464
Parsed${node.name} build();
65-
Parsed${node.name} makeDeferred();
6665

6766
private:
67+
Parsed${node.name} makeDeferred();
6868
Parsed${node.name} record();
6969
void finishLayout(bool deferred);
7070
};

branches/master-next/include/swift/Parse/ParsedSyntaxRecorder.h.gyb

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,22 @@ struct ParsedSyntaxRecorder {
4343
% end
4444
% child_params = ', '.join(child_params)
4545
private:
46-
static Parsed${node.name} record${node.syntax_kind}(${child_params},
46+
static Parsed${node.name} record${node.syntax_kind}(MutableArrayRef<ParsedRawSyntaxNode> layout,
4747
ParsedRawSyntaxRecorder &rec);
48-
public:
49-
static Parsed${node.name} defer${node.syntax_kind}(${child_params},
48+
static Parsed${node.name} defer${node.syntax_kind}(MutableArrayRef<ParsedRawSyntaxNode> layout,
5049
SyntaxParsingContext &SPCtx);
50+
public:
5151
static Parsed${node.name} make${node.syntax_kind}(${child_params},
5252
SyntaxParsingContext &SPCtx);
5353
% elif node.is_syntax_collection():
5454
private:
5555
static Parsed${node.name} record${node.syntax_kind}(
56-
MutableArrayRef<Parsed${node.collection_element_type}> elts,
56+
MutableArrayRef<ParsedRawSyntaxNode> layout,
5757
ParsedRawSyntaxRecorder &rec);
58-
59-
public:
6058
static Parsed${node.name} defer${node.syntax_kind}(
61-
MutableArrayRef<Parsed${node.collection_element_type}> elts,
59+
MutableArrayRef<ParsedRawSyntaxNode> layout,
6260
SyntaxParsingContext &SPCtx);
61+
public:
6362
static Parsed${node.name} make${node.syntax_kind}(
6463
MutableArrayRef<Parsed${node.collection_element_type}> elts,
6564
SyntaxParsingContext &SPCtx);
@@ -69,14 +68,12 @@ public:
6968
% elif node.is_unknown():
7069
private:
7170
static Parsed${node.name} record${node.syntax_kind}(
72-
MutableArrayRef<ParsedSyntax> elts,
71+
MutableArrayRef<ParsedRawSyntaxNode> layout,
7372
ParsedRawSyntaxRecorder &rec);
74-
75-
public:
7673
static Parsed${node.name} defer${node.syntax_kind}(
77-
MutableArrayRef<ParsedSyntax> elts,
74+
MutableArrayRef<ParsedRawSyntaxNode> layout,
7875
SyntaxParsingContext &SPCtx);
79-
76+
public:
8077
static Parsed${node.name} make${node.syntax_kind}(
8178
MutableArrayRef<ParsedSyntax> elts,
8279
SyntaxParsingContext &SPCtx);

0 commit comments

Comments
 (0)