Skip to content

Commit 92998f7

Browse files
committed
Don't attempt to apply solution from salvage.
Match the behavior of typeCheckExpressionImpl which simply calls solve and applySolution but never salvage.
1 parent 717e5e4 commit 92998f7

File tree

3 files changed

+26
-29
lines changed

3 files changed

+26
-29
lines changed

Diff for: lib/Sema/TypeCheckStmt.cpp

+2-11
Original file line numberDiff line numberDiff line change
@@ -1997,17 +1997,8 @@ bool TypeChecker::typeCheckFunctionBodyUntil(FuncDecl *FD,
19971997
// In either case, we should assume that the intent was to implicitly
19981998
// return the single expression and diagnose accordingly, per the first
19991999
// call to solve.
2000-
auto HadSalvageError = cs.salvage(viable, E);
2001-
if (!HadSalvageError) {
2002-
auto &solution = viable[0];
2003-
E = cs.applySolution(solution, E, resultType, /*discardedExpr=*/false,
2004-
/*skipClosures*/false);
2005-
if (E != FD->getSingleExpressionBody())
2006-
FD->setSingleExpressionBody(E);
2007-
setAutoClosureDiscriminators(FD, BS);
2008-
FD->setBody(BS);
2009-
}
2010-
return HadSalvageError;
2000+
cs.salvage(viable, E);
2001+
return true;
20112002
}
20122003
}
20132004
}

Diff for: test/Parse/omit_return.swift

+4-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
// RUN: %target-swift-frontend %s -typecheck -verify
22

3-
import Foundation
4-
53
// MARK: - Helpers
64

75

@@ -50,10 +48,6 @@ struct DynamicStruct {
5048
subscript(dynamicMember input: String) -> String { return input }
5149
}
5250

53-
class DynamicSubscriptClass {
54-
@objc subscript (i : Int) -> String { "howdy" }
55-
}
56-
5751
struct MyOwnArray<Element> : ExpressibleByArrayLiteral {
5852
init(arrayLiteral elements: Element...) {}
5953
}
@@ -413,10 +407,6 @@ func ff_implicitDynamicMember(_ s: DynamicStruct) -> String {
413407
s.foo
414408
}
415409

416-
func ff_implicitDynamicSubscript(_ c: DynamicSubscriptClass) -> String {
417-
c[13]
418-
}
419-
420410
func ff_implicitParenExpr() -> Int {
421411
(3 + 5)
422412
}
@@ -546,14 +536,6 @@ func ff_implicitAssignExpr(newValue: Int) -> Void {
546536
__ff_implicitAssignExpr = newValue
547537
}
548538

549-
func ff_implicitObjcSelectorExpr() -> Selector {
550-
#selector(NSArray.object(at:))
551-
}
552-
553-
func ff_implicitKeyPathExpr() -> String {
554-
#keyPath(NSArray.count)
555-
}
556-
557539
func ff_implicitMemberAccessInit() -> Initable {
558540
.init()
559541
}
@@ -1733,6 +1715,10 @@ class CImplicitIdentityExpr { func gimme() -> CImplicitIdentityExpr { self } }
17331715

17341716
class CImplicitDotSelfExpr { func gimme() -> CImplicitDotSelfExpr { self.self } }
17351717

1718+
func badIs<T>(_ value: Any, anInstanceOf type: T.Type) -> Bool {
1719+
value is type // expected-error {{use of undeclared type 'type'}}
1720+
}
1721+
17361722

17371723

17381724
// Autoclosure Discriminators

Diff for: test/Parse/omit_return_foundation.swift

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-frontend %s -typecheck -verify
2+
3+
import Foundation
4+
5+
class DynamicSubscriptClass {
6+
@objc subscript (i : Int) -> String { "howdy" }
7+
}
8+
9+
func ff_implicitDynamicSubscript(_ c: DynamicSubscriptClass) -> String {
10+
c[13]
11+
}
12+
13+
func ff_implicitObjcSelectorExpr() -> Selector {
14+
#selector(NSArray.object(at:))
15+
}
16+
17+
func ff_implicitKeyPathExpr() -> String {
18+
#keyPath(NSArray.count)
19+
}
20+

0 commit comments

Comments
 (0)