Skip to content

Commit 00b4340

Browse files
committed
---
yaml --- r: 349403 b: refs/heads/master-next c: e1c0cc9 h: refs/heads/master i: 349401: 76587a7 349399: 1e8c33b
1 parent 854ce9a commit 00b4340

File tree

5 files changed

+52
-43
lines changed

5 files changed

+52
-43
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: 97f3c39c46d969c8dbf21dbdeb3e9e12d5e9cb96
3+
refs/heads/master-next: e1c0cc93bb00b0066b51498436551d9405b535b4
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/include/swift/AST/Expr.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,11 +3843,12 @@ class DynamicTypeExpr : public Expr {
38433843
/// node (say, an \c OpenExistentialExpr) and can only be used within the
38443844
/// subexpressions of that AST node.
38453845
class OpaqueValueExpr : public Expr {
3846-
SourceLoc Loc;
3846+
SourceRange Range;
38473847

38483848
public:
3849-
explicit OpaqueValueExpr(SourceLoc Loc, Type Ty, bool isPlaceholder = false)
3850-
: Expr(ExprKind::OpaqueValue, /*Implicit=*/true, Ty), Loc(Loc) {
3849+
explicit OpaqueValueExpr(SourceRange Range, Type Ty,
3850+
bool isPlaceholder = false)
3851+
: Expr(ExprKind::OpaqueValue, /*Implicit=*/true, Ty), Range(Range) {
38513852
Bits.OpaqueValueExpr.IsPlaceholder = isPlaceholder;
38523853
}
38533854

@@ -3856,8 +3857,8 @@ class OpaqueValueExpr : public Expr {
38563857
/// value to be specified later.
38573858
bool isPlaceholder() const { return Bits.OpaqueValueExpr.IsPlaceholder; }
38583859

3859-
SourceRange getSourceRange() const { return Loc; }
3860-
3860+
SourceRange getSourceRange() const { return Range; }
3861+
38613862
static bool classof(const Expr *E) {
38623863
return E->getKind() == ExprKind::OpaqueValue;
38633864
}

branches/master-next/lib/Sema/CSApply.cpp

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,8 @@ namespace {
668668
opaqueType = LValueType::get(opaqueType);
669669

670670
ASTContext &ctx = tc.Context;
671-
auto archetypeVal = new (ctx) OpaqueValueExpr(base->getLoc(), opaqueType);
671+
auto archetypeVal =
672+
new (ctx) OpaqueValueExpr(base->getSourceRange(), opaqueType);
672673
cs.cacheType(archetypeVal);
673674

674675
// Record the opened existential.
@@ -2169,8 +2170,8 @@ namespace {
21692170

21702171
// This OpaqueValueExpr represents the result of builderInit above in
21712172
// silgen.
2172-
OpaqueValueExpr *interpolationExpr =
2173-
new (tc.Context) OpaqueValueExpr(expr->getLoc(), interpolationType);
2173+
OpaqueValueExpr *interpolationExpr = new (tc.Context)
2174+
OpaqueValueExpr(expr->getSourceRange(), interpolationType);
21742175
cs.setType(interpolationExpr, interpolationType);
21752176
expr->setInterpolationExpr(interpolationExpr);
21762177

@@ -5046,8 +5047,8 @@ Expr *ExprRewriter::coerceTupleToTuple(Expr *expr,
50465047
SmallVector<OpaqueValueExpr *, 4> destructured;
50475048
for (unsigned i = 0, e = sources.size(); i != e; ++i) {
50485049
auto fromEltType = fromTuple->getElementType(i);
5049-
auto *opaqueElt = new (tc.Context) OpaqueValueExpr(expr->getLoc(),
5050-
fromEltType);
5050+
auto *opaqueElt =
5051+
new (tc.Context) OpaqueValueExpr(expr->getSourceRange(), fromEltType);
50515052
cs.cacheType(opaqueElt);
50525053
destructured.push_back(opaqueElt);
50535054
}
@@ -5141,10 +5142,8 @@ Expr *ExprRewriter::coerceSuperclass(Expr *expr, Type toType,
51415142
// concrete superclass.
51425143
auto fromArchetype = OpenedArchetypeType::getAny(fromType);
51435144

5144-
auto *archetypeVal =
5145-
cs.cacheType(
5146-
new (tc.Context) OpaqueValueExpr(expr->getLoc(),
5147-
fromArchetype));
5145+
auto *archetypeVal = cs.cacheType(new (tc.Context) OpaqueValueExpr(
5146+
expr->getSourceRange(), fromArchetype));
51485147

51495148
auto *result = coerceSuperclass(archetypeVal, toType, locator);
51505149

@@ -5207,12 +5206,10 @@ Expr *ExprRewriter::coerceExistential(Expr *expr, Type toType,
52075206
// For existential-to-existential coercions, open the source existential.
52085207
if (fromType->isAnyExistentialType()) {
52095208
fromType = OpenedArchetypeType::getAny(fromType);
5210-
5211-
auto *archetypeVal =
5212-
cs.cacheType(
5213-
new (ctx) OpaqueValueExpr(expr->getLoc(),
5214-
fromType));
5215-
5209+
5210+
auto *archetypeVal = cs.cacheType(
5211+
new (ctx) OpaqueValueExpr(expr->getSourceRange(), fromType));
5212+
52165213
auto *result = cs.cacheType(ErasureExpr::create(ctx, archetypeVal, toType,
52175214
conformances));
52185215
return cs.cacheType(
@@ -5897,10 +5894,8 @@ maybeDiagnoseUnsupportedFunctionConversion(ConstraintSystem &cs, Expr *expr,
58975894

58985895
/// Build the conversion of an element in a collection upcast.
58995896
static Expr *buildElementConversion(ExprRewriter &rewriter,
5900-
SourceLoc srcLoc,
5901-
Type srcType,
5902-
Type destType,
5903-
bool bridged,
5897+
SourceRange srcRange, Type srcType,
5898+
Type destType, bool bridged,
59045899
ConstraintLocatorBuilder locator,
59055900
Expr *element) {
59065901
auto &cs = rewriter.getConstraintSystem();
@@ -5920,12 +5915,9 @@ static Expr *buildElementConversion(ExprRewriter &rewriter,
59205915
}
59215916

59225917
static CollectionUpcastConversionExpr::ConversionPair
5923-
buildOpaqueElementConversion(ExprRewriter &rewriter,
5924-
SourceLoc srcLoc,
5925-
Type srcCollectionType,
5926-
Type destCollectionType,
5927-
bool bridged,
5928-
ConstraintLocatorBuilder locator,
5918+
buildOpaqueElementConversion(ExprRewriter &rewriter, SourceRange srcRange,
5919+
Type srcCollectionType, Type destCollectionType,
5920+
bool bridged, ConstraintLocatorBuilder locator,
59295921
unsigned typeArgIndex) {
59305922
// We don't need this stuff unless we've got generalized casts.
59315923
Type srcType = srcCollectionType->castTo<BoundGenericType>()
@@ -5937,14 +5929,13 @@ buildOpaqueElementConversion(ExprRewriter &rewriter,
59375929
auto &cs = rewriter.getConstraintSystem();
59385930
ASTContext &ctx = cs.getASTContext();
59395931
auto opaque =
5940-
rewriter.cs.cacheType(new (ctx) OpaqueValueExpr(srcLoc, srcType));
5932+
rewriter.cs.cacheType(new (ctx) OpaqueValueExpr(srcRange, srcType));
59415933

5942-
Expr *conversion =
5943-
buildElementConversion(rewriter, srcLoc, srcType, destType, bridged,
5944-
locator.withPathElement(
5945-
ConstraintLocator::PathElement::getGenericArgument(
5946-
typeArgIndex)),
5947-
opaque);
5934+
Expr *conversion = buildElementConversion(
5935+
rewriter, srcRange, srcType, destType, bridged,
5936+
locator.withPathElement(
5937+
ConstraintLocator::PathElement::getGenericArgument(typeArgIndex)),
5938+
opaque);
59485939

59495940
return { opaque, conversion };
59505941
}
@@ -6999,9 +6990,9 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
69996990
bodyFnTy->withExtInfo(bodyFnTy->getExtInfo().withNoEscape()));
70006991
body = coerceToType(body, bodyFnTy, locator);
70016992
assert(body && "can't make nonescaping?!");
7002-
6993+
70036994
auto escapable = new (tc.Context)
7004-
OpaqueValueExpr(apply->getFn()->getLoc(), Type());
6995+
OpaqueValueExpr(apply->getFn()->getSourceRange(), Type());
70056996
cs.setType(escapable, escapableParams[0].getOldType());
70066997

70076998
auto getType = [&](const Expr *E) -> Type {
@@ -7058,8 +7049,8 @@ Expr *ExprRewriter::finishApply(ApplyExpr *apply, Type openedType,
70587049
->getOpenedExistentialType()
70597050
->isEqual(existentialInstanceTy));
70607051

7061-
auto opaqueValue = new (tc.Context)
7062-
OpaqueValueExpr(apply->getLoc(), openedTy);
7052+
auto opaqueValue =
7053+
new (tc.Context) OpaqueValueExpr(apply->getSourceRange(), openedTy);
70637054
cs.setType(opaqueValue, openedTy);
70647055

70657056
auto getType = [&](const Expr *E) -> Type {

branches/master-next/lib/Sema/TypeCheckStorage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
24062406
// Form the initialization of the backing property from a value of the
24072407
// original property's type.
24082408
OpaqueValueExpr *origValue =
2409-
new (ctx) OpaqueValueExpr(var->getLoc(), var->getType(),
2409+
new (ctx) OpaqueValueExpr(var->getSourceRange(), var->getType(),
24102410
/*isPlaceholder=*/true);
24112411
Expr *initializer = buildPropertyWrapperInitialValueCall(
24122412
var, storageType, origValue,

branches/master-next/test/decl/func/throwing_functions_without_try.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,20 @@ func baz2() -> Int {
5151
x = try foo() // expected-error{{errors thrown from here are not handled}}
5252
return x
5353
}
54+
55+
// SR-11016
56+
57+
protocol SR_11016_P {
58+
func bar() throws
59+
}
60+
61+
class SR_11016_C {
62+
var foo: SR_11016_P?
63+
64+
func someMethod() throws {
65+
foo?.bar() // expected-error {{call can throw but is not marked with 'try'}}
66+
// expected-note @-1 {{did you mean to use 'try'?}}{{5-5=try }}
67+
// expected-note @-2 {{did you mean to handle error as optional value?}}{{5-5=try? }}
68+
// expected-note @-3 {{did you mean to disable error propagation?}}{{5-5=try! }}
69+
}
70+
}

0 commit comments

Comments
 (0)