Skip to content

Commit b2aaa61

Browse files
committed
Fix range of coerce-expr when casting a returned CFString to String
foo().getCFString() as String This cast creates an implicit call expression where the function for the call is an implicit declref. Instead of choosing "getCFString" as the location of the declref, we should choose "foo", since otherwise the overall source range for the call and the coercion will be missing foo(). Unfortunately there is no good way to test source ranges right now, but this fixes e.g. the range in the following diagnostic: struct S { func getCFString() -> CFString { fatalError("") } } _ = S().getCFString() as String + 1 ~~~~~~~~~~~~~~~~~~~~~~~ ^ ~ // before ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~ // now rdar://problem/26301228
1 parent 522e0c9 commit b2aaa61

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/Sema/CSApply.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ namespace {
14391439

14401440
ConcreteDeclRef fnSpecRef(tc.Context, fn, Subs);
14411441
Expr *fnRef = new (tc.Context) DeclRefExpr(fnSpecRef,
1442-
DeclNameLoc(object->getLoc()),
1442+
DeclNameLoc(object->getStartLoc()),
14431443
/*Implicit=*/true);
14441444
TypeSubstitutionMap subMap;
14451445
auto genericParam = fnGenericParams[0];

0 commit comments

Comments
 (0)