Skip to content

Commit 76f0260

Browse files
committed
---
yaml --- r: 282623 b: refs/heads/master c: be0140f h: refs/heads/master i: 282621: 2b0729a 282619: 10fbd59 282615: 055be3d 282607: d64f26a 282591: 16dbfde 282559: 4d5177e 282495: 7a122f1 282367: 898a9ab 282111: 4b32730 281599: 3555f76 280575: 1e421aa 278527: e4902cf
1 parent fda82db commit 76f0260

File tree

11 files changed

+88
-73
lines changed

11 files changed

+88
-73
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 40757497242cb0fafc7aa1409ead4c716d21eba7
2+
refs/heads/master: be0140fe56ed00b5e9512a82750944a74e7c93ed
33
refs/heads/master-next: 820766c166ae1ee499715d69f06953249c74f1de
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ ERROR(opaque_type_invalid_constraint,none,
15021502
"an 'opaque' type must specify only 'Any', 'AnyObject', protocols, "
15031503
"and/or a base class", ())
15041504
ERROR(inferred_opaque_type,none,
1505-
"property definition has inferred type %0, involving the '__opaque' "
1505+
"property definition has inferred type %0, involving the 'some' "
15061506
"return type of another declaration", (Type))
15071507

15081508
// Extensions

trunk/include/swift/Parse/Token.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ class Token {
166166
getRawText().equals("__owned"))
167167
return false;
168168

169-
// ...or __opaque
170-
if (getRawText().equals("__opaque"))
171-
return false;
169+
/* // ...or some
170+
if (getRawText().equals("some"))
171+
return false;*/
172172

173173
return true;
174174
}

trunk/lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4143,7 +4143,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
41434143

41444144
void visitOpaqueTypeArchetypeType(OpaqueTypeArchetypeType *T) {
41454145
// TODO(opaque): present opaque types with user-facing syntax
4146-
Printer << "(__opaque " << T->getOpaqueDecl()->getNamingDecl()->printRef();
4146+
Printer << "(some " << T->getOpaqueDecl()->getNamingDecl()->printRef();
41474147
if (!T->getSubstitutions().empty()) {
41484148
Printer << '<';
41494149
auto replacements = T->getSubstitutions().getReplacementTypes();

trunk/lib/Demangling/NodePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2260,7 +2260,7 @@ NodePointer NodePrinter::print(NodePointer Node, bool asPrefixContext) {
22602260
Printer << ")";
22612261
return nullptr;
22622262
case Node::Kind::OpaqueReturnType:
2263-
Printer << "__opaque";
2263+
Printer << "some";
22642264
return nullptr;
22652265
case Node::Kind::OpaqueReturnTypeOf:
22662266
Printer << "<<opaque return type of ";

trunk/lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2307,7 +2307,7 @@ bool Parser::parseDeclModifierList(DeclAttributes &Attributes,
23072307
/// 'inout' attribute-list-clause attribute-list
23082308
/// '__shared' attribute-list-clause attribute-list
23092309
/// '__owned' attribute-list-clause attribute-list
2310-
/// '__opaque' attribute-list-clause attribute-list
2310+
/// 'some' attribute-list-clause attribute-list
23112311
/// attribute-list-clause:
23122312
/// '@' attribute
23132313
/// '@' attribute attribute-list-clause

trunk/lib/Parse/ParseType.cpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ ParserResult<TypeRepr> Parser::parseTypeIdentifier() {
670670
/// parseTypeSimpleOrComposition
671671
///
672672
/// type-composition:
673-
/// '__opaque'? type-simple
673+
/// 'some'? type-simple
674674
/// type-composition '&' type-simple
675675
ParserResult<TypeRepr>
676676
Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
@@ -681,7 +681,7 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
681681
SourceLoc opaqueLoc;
682682
if (Context.LangOpts.EnableOpaqueResultTypes
683683
&& Tok.is(tok::identifier)
684-
&& Tok.getRawText() == "__opaque") {
684+
&& Tok.getRawText() == "some") {
685685
opaqueLoc = consumeToken();
686686
}
687687

@@ -741,10 +741,10 @@ Parser::parseTypeSimpleOrComposition(Diag<> MessageID,
741741
consumeToken(); // consume '&'
742742
}
743743

744-
// Diagnose invalid `__opaque` after an ampersand.
744+
// Diagnose invalid `some` after an ampersand.
745745
if (Context.LangOpts.EnableOpaqueResultTypes
746746
&& Tok.is(tok::identifier)
747-
&& Tok.getRawText() == "__opaque") {
747+
&& Tok.getRawText() == "some") {
748748
auto badLoc = consumeToken();
749749

750750
// TODO: Fixit to move to beginning of composition.
@@ -894,7 +894,7 @@ ParserResult<TypeRepr> Parser::parseOldStyleProtocolComposition() {
894894
/// type-tuple-body:
895895
/// type-tuple-element (',' type-tuple-element)* '...'?
896896
/// type-tuple-element:
897-
/// identifier ':' type
897+
/// identifier? identifier ':' type
898898
/// type
899899
ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
900900
SyntaxParsingContext TypeContext(SyntaxContext, SyntaxKind::TupleType);
@@ -928,16 +928,20 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
928928
Backtracking.emplace(*this);
929929
ObsoletedInOutLoc = consumeToken(tok::kw_inout);
930930
}
931+
932+
// If the label is "some", this could end up being an opaque type
933+
// description if there's `some <identifier>` without a following colon,
934+
// so we may need to backtrack as well.
935+
if (Tok.getText().equals("some")) {
936+
Backtracking.emplace(*this);
937+
}
931938

932939
// If the tuple element starts with a potential argument label followed by a
933940
// ':' or another potential argument label, then the identifier is an
934941
// element tag, and it is followed by a type annotation.
935-
if (Tok.canBeArgumentLabel() &&
936-
(peekToken().is(tok::colon) || peekToken().canBeArgumentLabel())) {
937-
if (Backtracking)
938-
// Found obsoleted 'inout' use.
939-
Backtracking->cancelBacktrack();
940-
942+
if (Tok.canBeArgumentLabel()
943+
&& (peekToken().is(tok::colon)
944+
|| peekToken().canBeArgumentLabel())) {
941945
// Consume a name.
942946
element.NameLoc = consumeArgumentLabel(element.Name);
943947

@@ -946,8 +950,19 @@ ParserResult<TupleTypeRepr> Parser::parseTypeTupleBody() {
946950
element.SecondNameLoc = consumeArgumentLabel(element.SecondName);
947951

948952
// Consume the ':'.
949-
if (!consumeIf(tok::colon, element.ColonLoc))
950-
diagnose(Tok, diag::expected_parameter_colon);
953+
if (consumeIf(tok::colon, element.ColonLoc)) {
954+
// If we succeed, then we successfully parsed a label.
955+
if (Backtracking)
956+
Backtracking->cancelBacktrack();
957+
// Otherwise, if we can't backtrack to parse this as a type,
958+
// this is a syntax error.
959+
} else {
960+
if (!Backtracking) {
961+
diagnose(Tok, diag::expected_parameter_colon);
962+
}
963+
element.NameLoc = SourceLoc();
964+
element.SecondNameLoc = SourceLoc();
965+
}
951966

952967
} else if (Backtracking) {
953968
// If we don't have labels, 'inout' is not a obsoleted use.

trunk/test/IRGen/opaque_result_type.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension String: P {
3636
// -- conformance to O
3737
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type1OHpyHC
3838
// CHECK-SAME: }>
39-
func poo() -> __opaque O {
39+
func poo() -> some O {
4040
return 0
4141
}
4242
}
@@ -52,7 +52,7 @@ public class C: P, Q {
5252
// -- conformance to O
5353
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type1OHpyHC
5454
// CHECK-SAME: }>
55-
func poo() -> __opaque O {
55+
func poo() -> some O {
5656
return 0
5757
}
5858

@@ -68,7 +68,7 @@ public class C: P, Q {
6868
// -- conformance to O2
6969
// CHECK-SAME: @"get_witness_table S2i18opaque_result_type2O2HpyHC
7070
// CHECK-SAME: }>
71-
func qoo() -> __opaque O & O2 {
71+
func qoo() -> some O & O2 {
7272
return 0
7373
}
7474
}
@@ -83,7 +83,7 @@ public class C: P, Q {
8383
// -- conformance to P
8484
// CHECK-SAME: @"get_witness_table S2S18opaque_result_type1PHpyHC
8585
// CHECK-SAME: }>
86-
func foo(x: String) -> __opaque P {
86+
func foo(x: String) -> some P {
8787
return x
8888
}
8989

@@ -97,7 +97,7 @@ func foo(x: String) -> __opaque P {
9797
// -- conformance to Q
9898
// CHECK-SAME: @"get_witness_table 18opaque_result_type1CCAcA1QHPyHC
9999
// CHECK-SAME: }>
100-
func bar(y: C) -> __opaque Q {
100+
func bar(y: C) -> some Q {
101101
return y
102102
}
103103

@@ -113,7 +113,7 @@ func bar(y: C) -> __opaque Q {
113113
// -- conformance to Q
114114
// CHECK-SAME: @"get_witness_table 18opaque_result_type1PRzAA1QRzlxAaC
115115
// CHECK-SAME: }>
116-
func baz<T: P & Q>(z: T) -> __opaque P & Q {
116+
func baz<T: P & Q>(z: T) -> some P & Q {
117117
return z
118118
}
119119

trunk/test/SILGen/opaque_result_type.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,37 @@ struct AddrOnly: P { var field: P }
99
class C: Q {}
1010

1111
// CHECK-LABEL: sil hidden {{.*}}11valueToAddr1xQr
12-
func valueToAddr(x: String) -> __opaque P {
12+
func valueToAddr(x: String) -> some P {
1313
// CHECK: [[UNDERLYING:%.*]] = unchecked_addr_cast %0
1414
// CHECK: [[VALUE_COPY:%.*]] = copy_value %1
1515
// CHECK: store [[VALUE_COPY]] to [init] [[UNDERLYING]]
1616
return x
1717
}
1818

1919
// CHECK-LABEL: sil hidden {{.*}}10addrToAddr1xQr
20-
func addrToAddr(x: AddrOnly) -> __opaque P {
20+
func addrToAddr(x: AddrOnly) -> some P {
2121
// CHECK: [[UNDERLYING:%.*]] = unchecked_addr_cast %0
2222
// CHECK: copy_addr %1 to [initialization] [[UNDERLYING]]
2323
return x
2424
}
2525

2626
// CHECK-LABEL: sil hidden {{.*}}13genericAddrToE01xQr
27-
func genericAddrToAddr<T: P>(x: T) -> __opaque P {
27+
func genericAddrToAddr<T: P>(x: T) -> some P {
2828
// CHECK: [[UNDERLYING:%.*]] = unchecked_addr_cast %0
2929
// CHECK: copy_addr %1 to [initialization] [[UNDERLYING]]
3030
return x
3131
}
3232

3333
// CHECK-LABEL: sil hidden {{.*}}12valueToValue1xQr
34-
func valueToValue(x: C) -> __opaque Q {
34+
func valueToValue(x: C) -> some Q {
3535
// CHECK: [[VALUE_COPY:%.*]] = copy_value %0
3636
// CHECK: [[CAST_TO_OPAQUE:%.*]] = unchecked_ref_cast [[VALUE_COPY]]
3737
// CHECK: return [[CAST_TO_OPAQUE]]
3838
return x
3939
}
4040

4141
// CHECK-LABEL: sil hidden {{.*}}13reabstraction1xQr
42-
func reabstraction(x: @escaping () -> ()) -> __opaque Any {
42+
func reabstraction(x: @escaping () -> ()) -> some Any {
4343
// CHECK [[UNDERLYING:%.*]] = unchecked_addr_cast %0 : ${{.*}} to $*@callee_guaranteed () -> @out ()
4444
// CHECK: [[VALUE_COPY:%.*]] = copy_value %1
4545
// CHECK: [[VALUE_REABSTRACT:%.*]] = partial_apply [callee_guaranteed] {{%.*}}([[VALUE_COPY]])

trunk/test/Serialization/Inputs/OpaqueCrossFileB.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ public struct FooImpl: Foo {
44
public init() {}
55
}
66

7-
public func anyFoo() -> __opaque Foo {
7+
public func anyFoo() -> some Foo {
88
return FooImpl()
99
}

0 commit comments

Comments
 (0)