Skip to content

Commit 7f390e2

Browse files
committed
---
yaml --- r: 348841 b: refs/heads/master c: e334e5d h: refs/heads/master i: 348839: 3d70871
1 parent 70b42d7 commit 7f390e2

Some content is hidden

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

45 files changed

+295
-395
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: e90359597919c07a71a519a1c79e1c31fcae82cc
2+
refs/heads/master: e334e5d66f38e83703d8c1d3282ffde6d69b6bd4
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SWIFT_TYPEID_NAMED(InfixOperatorDecl *, InfixOperatorDecl)
3333
SWIFT_TYPEID_NAMED(IterableDeclContext *, IterableDeclContext)
3434
SWIFT_TYPEID_NAMED(ModuleDecl *, ModuleDecl)
3535
SWIFT_TYPEID_NAMED(NominalTypeDecl *, NominalTypeDecl)
36+
SWIFT_TYPEID_NAMED(OpaqueTypeDecl *, OpaqueTypeDecl)
3637
SWIFT_TYPEID_NAMED(OperatorDecl *, OperatorDecl)
3738
SWIFT_TYPEID_NAMED(Optional<PropertyWrapperMutability>,
3839
PropertyWrapperMutability)

trunk/include/swift/AST/ASTTypeIDs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class IterableDeclContext;
3434
class ModuleDecl;
3535
class NominalTypeDecl;
3636
class OperatorDecl;
37+
class OpaqueTypeDecl;
3738
class PrecedenceGroupDecl;
3839
struct PropertyWrapperBackingPropertyInfo;
3940
struct PropertyWrapperTypeInfo;

trunk/include/swift/AST/Decl.h

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,12 +2764,6 @@ class ValueDecl : public Decl {
27642764
/// Get the representative for this value's opaque result type, if it has one.
27652765
OpaqueReturnTypeRepr *getOpaqueResultTypeRepr() const;
27662766

2767-
/// Set the opaque return type decl for this decl.
2768-
///
2769-
/// `this` must be of a decl type that supports opaque return types, and
2770-
/// must not have previously had an opaque result type set.
2771-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *D);
2772-
27732767
/// Retrieve the attribute associating this declaration with a
27742768
/// function builder, if there is one.
27752769
CustomAttr *getAttachedFunctionBuilder() const;
@@ -4530,8 +4524,6 @@ class AbstractStorageDecl : public ValueDecl {
45304524
Bits.AbstractStorageDecl.IsStatic = IsStatic;
45314525
}
45324526

4533-
OpaqueTypeDecl *OpaqueReturn = nullptr;
4534-
45354527
public:
45364528

45374529
/// Should this declaration be treated as if annotated with transparent
@@ -4789,14 +4781,6 @@ class AbstractStorageDecl : public ValueDecl {
47894781

47904782
bool hasAnyDynamicReplacementAccessors() const;
47914783

4792-
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
4793-
return OpaqueReturn;
4794-
}
4795-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
4796-
assert(!OpaqueReturn && "already has opaque type decl");
4797-
OpaqueReturn = decl;
4798-
}
4799-
48004784
// Implement isa/cast/dyncast/etc.
48014785
static bool classof(const Decl *D) {
48024786
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&
@@ -5982,8 +5966,6 @@ class FuncDecl : public AbstractFunctionDecl {
59825966

59835967
TypeLoc FnRetType;
59845968

5985-
OpaqueTypeDecl *OpaqueReturn = nullptr;
5986-
59875969
protected:
59885970
FuncDecl(DeclKind Kind,
59895971
SourceLoc StaticLoc, StaticSpellingKind StaticSpelling,
@@ -6129,15 +6111,7 @@ class FuncDecl : public AbstractFunctionDecl {
61296111
}
61306112

61316113
OperatorDecl *getOperatorDecl() const;
6132-
6133-
OpaqueTypeDecl *getOpaqueResultTypeDecl() const {
6134-
return OpaqueReturn;
6135-
}
6136-
void setOpaqueResultTypeDecl(OpaqueTypeDecl *decl) {
6137-
assert(!OpaqueReturn && "already has opaque type decl");
6138-
OpaqueReturn = decl;
6139-
}
6140-
6114+
61416115
/// Returns true if the function is forced to be statically dispatched.
61426116
bool hasForcedStaticDispatch() const {
61436117
return Bits.FuncDecl.ForcedStaticDispatch;

trunk/include/swift/AST/TypeCheckRequests.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ class GenericSignatureRequest :
11881188
void cacheResult(GenericSignature value) const;
11891189
};
11901190

1191-
/// Compute the interface type of the underlying definition type of a typealias declaration.
1191+
/// Compute the underlying interface type of a typealias.
11921192
class UnderlyingTypeRequest :
11931193
public SimpleRequest<UnderlyingTypeRequest,
11941194
Type(TypeAliasDecl *),
@@ -1211,6 +1211,7 @@ class UnderlyingTypeRequest :
12111211
void diagnoseCycle(DiagnosticEngine &diags) const;
12121212
};
12131213

1214+
/// Looks up the precedence group of an operator declaration.
12141215
class OperatorPrecedenceGroupRequest
12151216
: public SimpleRequest<OperatorPrecedenceGroupRequest,
12161217
PrecedenceGroupDecl *(InfixOperatorDecl *),
@@ -1272,6 +1273,25 @@ class IsABICompatibleOverrideRequest
12721273
bool isCached() const { return true; }
12731274
};
12741275

1276+
/// Builds an opaque result type for a declaration.
1277+
class OpaqueResultTypeRequest
1278+
: public SimpleRequest<OpaqueResultTypeRequest,
1279+
OpaqueTypeDecl *(ValueDecl *),
1280+
CacheKind::Cached> {
1281+
public:
1282+
using SimpleRequest::SimpleRequest;
1283+
1284+
private:
1285+
friend SimpleRequest;
1286+
1287+
llvm::Expected<OpaqueTypeDecl *>
1288+
evaluate(Evaluator &evaluator, ValueDecl *VD) const;
1289+
1290+
public:
1291+
// Caching.
1292+
bool isCached() const { return true; }
1293+
};
1294+
12751295
// Allow AnyValue to compare two Type values, even though Type doesn't
12761296
// support ==.
12771297
template<>

trunk/include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ SWIFT_REQUEST(TypeChecker, MangleLocalTypeDeclRequest,
8888
SWIFT_REQUEST(TypeChecker, OpaqueReadOwnershipRequest,
8989
OpaqueReadOwnership(AbstractStorageDecl *), SeparatelyCached,
9090
NoLocationInfo)
91+
SWIFT_REQUEST(TypeChecker, OpaqueResultTypeRequest,
92+
OpaqueTypeDecl *(ValueDecl *),
93+
Cached, NoLocationInfo)
9194
SWIFT_REQUEST(TypeChecker, OperatorPrecedenceGroupRequest,
9295
PrecedenceGroupDecl *(PrecedenceGroupDecl *),
9396
Cached, NoLocationInfo)

trunk/include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,6 @@ namespace swift {
325325
/// set to true.
326326
bool ExperimentalDependenciesIncludeIntrafileOnes = false;
327327

328-
/// Whether to enable experimental differentiable programming features:
329-
/// `@differentiable` declaration attribute, etc.
330-
bool EnableExperimentalDifferentiableProgramming = false;
331-
332328
/// Sets the target we are building for and updates platform conditions
333329
/// to match.
334330
///

trunk/include/swift/Option/Options.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,6 @@ def disable_bridging_pch : Flag<["-"], "disable-bridging-pch">,
424424
Flags<[HelpHidden]>,
425425
HelpText<"Disable automatic generation of bridging PCH files">;
426426

427-
// Experimental feature options
428-
def enable_experimental_differentiable_programming : Flag<["-"], "enable-experimental-differentiable-programming">,
429-
Flags<[FrontendOption]>,
430-
HelpText<"Enable experimental differentiable programming features">;
431-
432427
// Diagnostic control options
433428
def suppress_warnings : Flag<["-"], "suppress-warnings">,
434429
Flags<[FrontendOption]>,

trunk/include/swift/Parse/Parser.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -895,9 +895,9 @@ class Parser {
895895
bool parseMatchingToken(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
896896
SourceLoc OtherLoc);
897897

898-
ParsedSyntaxResult<ParsedTokenSyntax>
899-
parseMatchingTokenSyntax(tok K, Diag<> ErrorDiag, SourceLoc OtherLoc,
900-
bool silenceDiag = false);
898+
llvm::Optional<ParsedTokenSyntax>
899+
parseMatchingTokenSyntax(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
900+
SourceLoc OtherLoc);
901901

902902
/// Returns the proper location for a missing right brace, parenthesis, etc.
903903
SourceLoc getLocForMissingMatchingToken() const;
@@ -919,6 +919,7 @@ class Parser {
919919
llvm::function_ref<ParserStatus()> callback);
920920
ParserStatus parseListSyntax(tok RightK, SourceLoc LeftLoc,
921921
llvm::Optional<ParsedTokenSyntax> &LastComma,
922+
SourceLoc &RightLoc,
922923
llvm::Optional<ParsedTokenSyntax> &Right,
923924
llvm::SmallVectorImpl<ParsedSyntax>& Junk,
924925
bool AllowSepAfterLast, Diag<> ErrorDiag,

trunk/lib/AST/Decl.cpp

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2580,7 +2580,22 @@ void ValueDecl::setOverriddenDecls(ArrayRef<ValueDecl *> overridden) {
25802580
OpaqueReturnTypeRepr *ValueDecl::getOpaqueResultTypeRepr() const {
25812581
TypeLoc returnLoc;
25822582
if (auto *VD = dyn_cast<VarDecl>(this)) {
2583-
returnLoc = VD->getTypeLoc();
2583+
if (auto *P = VD->getParentPattern()) {
2584+
while (auto *PP = dyn_cast<ParenPattern>(P))
2585+
P = PP->getSubPattern();
2586+
2587+
if (auto *TP = dyn_cast<TypedPattern>(P)) {
2588+
P = P->getSemanticsProvidingPattern();
2589+
if (auto *NP = dyn_cast<NamedPattern>(P)) {
2590+
assert(NP->getDecl() == VD);
2591+
(void) NP;
2592+
2593+
returnLoc = TP->getTypeLoc();
2594+
}
2595+
}
2596+
} else {
2597+
returnLoc = VD->getTypeLoc();
2598+
}
25842599
} else if (auto *FD = dyn_cast<FuncDecl>(this)) {
25852600
returnLoc = FD->getBodyResultTypeLoc();
25862601
} else if (auto *SD = dyn_cast<SubscriptDecl>(this)) {
@@ -2591,23 +2606,12 @@ OpaqueReturnTypeRepr *ValueDecl::getOpaqueResultTypeRepr() const {
25912606
}
25922607

25932608
OpaqueTypeDecl *ValueDecl::getOpaqueResultTypeDecl() const {
2594-
if (auto func = dyn_cast<FuncDecl>(this)) {
2595-
return func->getOpaqueResultTypeDecl();
2596-
} else if (auto storage = dyn_cast<AbstractStorageDecl>(this)) {
2597-
return storage->getOpaqueResultTypeDecl();
2598-
} else {
2609+
if (getOpaqueResultTypeRepr() == nullptr)
25992610
return nullptr;
2600-
}
2601-
}
26022611

2603-
void ValueDecl::setOpaqueResultTypeDecl(OpaqueTypeDecl *D) {
2604-
if (auto func = dyn_cast<FuncDecl>(this)) {
2605-
func->setOpaqueResultTypeDecl(D);
2606-
} else if (auto storage = dyn_cast<AbstractStorageDecl>(this)){
2607-
storage->setOpaqueResultTypeDecl(D);
2608-
} else {
2609-
llvm_unreachable("decl does not support opaque result types");
2610-
}
2612+
return evaluateOrDefault(getASTContext().evaluator,
2613+
OpaqueResultTypeRequest{const_cast<ValueDecl *>(this)},
2614+
nullptr);
26112615
}
26122616

26132617
bool ValueDecl::isObjC() const {

trunk/lib/Parse/ASTGen.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -976,9 +976,6 @@ GenericParamList *ASTGen::generate(const GenericParameterClauseSyntax &clause,
976976
params.reserve(clause.getGenericParameterList().getNumChildren());
977977

978978
for (auto elem : clause.getGenericParameterList()) {
979-
auto nameTok = elem.getName();
980-
if (nameTok.isMissing())
981-
break;
982979

983980
DeclAttributes attrs = generateDeclAttributes(elem, Loc, false);
984981
Identifier name = Context.getIdentifier(elem.getName().getIdentifierText());

trunk/lib/Parse/ParseDecl.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,9 +1632,6 @@ ParserStatus Parser::parseDeclAttribute(DeclAttributes &Attributes, SourceLoc At
16321632
}
16331633
consumeToken(tok::code_complete);
16341634
return makeParserCodeCompletionStatus();
1635-
} else {
1636-
// Synthesize an r_brace syntax node if the token is absent
1637-
SyntaxContext->synthesize(tok::identifier, AtLoc.getAdvancedLoc(1));
16381635
}
16391636

16401637
diagnose(Tok, diag::expected_attribute_name);
@@ -2002,11 +1999,13 @@ ParsedSyntaxResult<ParsedAttributeSyntax> Parser::parseTypeAttributeSyntax() {
20021999
}
20032000

20042001
// Parse ')'.
2002+
SourceLoc RParenLoc;
20052003
auto RParen = parseMatchingTokenSyntax(
2006-
tok::r_paren, diag::convention_attribute_expected_rparen, LParenLoc);
2007-
if (RParen.isError())
2004+
tok::r_paren, RParenLoc, diag::convention_attribute_expected_rparen,
2005+
LParenLoc);
2006+
if (!RParen)
20082007
return makeParserError();
2009-
builder.useRightParen(RParen.get());
2008+
builder.useRightParen(std::move(*RParen));
20102009

20112010
return makeParserSuccess();
20122011
}();
@@ -2034,11 +2033,13 @@ ParsedSyntaxResult<ParsedAttributeSyntax> Parser::parseTypeAttributeSyntax() {
20342033
builder.useArgument(consumeTokenSyntax(tok::string_literal));
20352034

20362035
// Parse ')'.
2036+
SourceLoc RParenLoc;
20372037
auto RParen = parseMatchingTokenSyntax(
2038-
tok::r_paren, diag::opened_attribute_expected_rparen, LParenLoc);
2039-
if (RParen.isError())
2038+
tok::r_paren, RParenLoc, diag::opened_attribute_expected_rparen,
2039+
LParenLoc);
2040+
if (!RParen)
20402041
return makeParserError();
2041-
builder.useRightParen(RParen.get());
2042+
builder.useRightParen(std::move(*RParen));
20422043

20432044
return makeParserSuccess();
20442045
}();
@@ -2084,11 +2085,12 @@ ParsedSyntaxResult<ParsedAttributeSyntax> Parser::parseTypeAttributeSyntax() {
20842085
builder.useArgument(argBuilder.build());
20852086

20862087
// Parse ')'.
2088+
SourceLoc RParenLoc;
20872089
auto RParen = parseMatchingTokenSyntax(
2088-
tok::r_paren, diag::expected_rparen_expr_list, LParenLoc);
2089-
if (RParen.isError())
2090+
tok::r_paren, RParenLoc, diag::expected_rparen_expr_list, LParenLoc);
2091+
if (!RParen)
20902092
return makeParserError();
2091-
builder.useRightParen(RParen.get());
2093+
builder.useRightParen(std::move(*RParen));
20922094

20932095
return makeParserSuccess();
20942096
}();

trunk/lib/Parse/ParseGeneric.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ Parser::parseGenericParameterClauseSyntax() {
7474

7575
// Parse attributes.
7676
// TODO: Implement syntax attribute parsing.
77-
Optional<ParsedAttributeListSyntax> attrs;
7877
if (Tok.is(tok::at_sign)) {
7978
SyntaxParsingContext TmpCtxt(SyntaxContext);
8079
TmpCtxt.setTransparent();
@@ -84,23 +83,18 @@ Parser::parseGenericParameterClauseSyntax() {
8483
parseDeclAttributeList(attrsAST);
8584
if (!attrsAST.isEmpty())
8685
Generator.addDeclAttributes(attrsAST, AttrsLoc);
87-
attrs = SyntaxContext->popIf<ParsedAttributeListSyntax>();
86+
auto attrs = SyntaxContext->popIf<ParsedAttributeListSyntax>();
87+
if (attrs)
88+
paramBuilder.useAttributes(std::move(*attrs));
8889
}
8990

9091
// Parse the name of the parameter.
9192
auto ident = Context.getIdentifier(Tok.getText());
9293
auto name = parseIdentifierSyntax(diag::expected_generics_parameter_name);
9394
if (!name) {
94-
if (attrs) {
95-
paramBuilder.useAttributes(std::move(*attrs));
96-
builder.addGenericParameterListMember(paramBuilder.build());
97-
}
9895
status.setIsParseError();
9996
break;
10097
}
101-
102-
if (attrs)
103-
paramBuilder.useAttributes(std::move(*attrs));
10498
paramBuilder.useName(std::move(*name));
10599

106100
// Parse the ':' followed by a type.

0 commit comments

Comments
 (0)