File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -1017,13 +1017,17 @@ void TypeChecker::checkIgnoredExpr(Expr *E) {
1017
1017
return ;
1018
1018
}
1019
1019
1020
- // Drill through noop expressions we don't care about, like ParanExprs .
1020
+ // Drill through noop expressions we don't care about.
1021
1021
auto valueE = E;
1022
1022
while (1 ) {
1023
1023
valueE = valueE->getValueProvidingExpr ();
1024
1024
1025
1025
if (auto *OEE = dyn_cast<OpenExistentialExpr>(valueE))
1026
1026
valueE = OEE->getSubExpr ();
1027
+ else if (auto *CRCE = dyn_cast<CovariantReturnConversionExpr>(valueE))
1028
+ valueE = CRCE->getSubExpr ();
1029
+ else if (auto *EE = dyn_cast<ErasureExpr>(valueE))
1030
+ valueE = EE->getSubExpr ();
1027
1031
else
1028
1032
break ;
1029
1033
}
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ class MyDocument : NSDocument {
16
16
17
17
func test( _ url: URL , controller: NSDocumentController ) {
18
18
try ! NSDocument ( contentsOf: url, ofType: " " ) // expected-warning{{result of 'NSDocument' initializer is unused}}
19
- try ! MyDocument ( contentsOf: url, ofType: " " ) // expected-warning {{expression of type 'MyDocument' is unused}}
19
+ try ! MyDocument ( contentsOf: url, ofType: " " ) // expected-warning{{result of 'NSDocument' initializer is unused}}
20
20
21
21
try ! controller. makeDocument ( withContentsOf: url, ofType: " " )
22
22
}
Original file line number Diff line number Diff line change @@ -41,9 +41,16 @@ class C1 {
41
41
func f1( ) -> Int { }
42
42
43
43
func f2( ) -> Int { }
44
+
45
+ @discardableResult
46
+ func me( ) -> Self { return self }
47
+
48
+ func reallyMe( ) -> Self { return self }
44
49
}
45
50
46
- func testFunctionsInClass( c1 : C1 ) {
51
+ class C2 : C1 { }
52
+
53
+ func testFunctionsInClass( c1 : C1 , c2: C2 ) {
47
54
C1 . f1Static ( ) // okay
48
55
C1 . f2Static ( ) // expected-warning {{result of call to 'f2Static()' is unused}}
49
56
_ = C1 . f2Static ( ) // okay
@@ -60,6 +67,15 @@ func testFunctionsInClass(c1 : C1) {
60
67
c1. f1 ( ) // okay
61
68
c1. f2 ( ) // expected-warning {{result of call to 'f2()' is unused}}
62
69
_ = c1. f2 ( ) // okay
70
+
71
+ c1. me ( ) // okay
72
+ c2. me ( ) // okay
73
+
74
+ c1. reallyMe ( ) // expected-warning {{result of call to 'reallyMe()' is unused}}
75
+ c2. reallyMe ( ) // expected-warning {{result of call to 'reallyMe()' is unused}}
76
+
77
+ _ = c1. reallyMe ( ) // okay
78
+ _ = c2. reallyMe ( ) // okay
63
79
}
64
80
65
81
struct S1 {
@@ -92,6 +108,18 @@ func testFunctionsInStruct(s1 : S1) {
92
108
_ = s1. f2 ( ) // okay
93
109
}
94
110
111
+ protocol P1 {
112
+ @discardableResult
113
+ func me( ) -> Self
114
+
115
+ func reallyMe( ) -> Self
116
+ }
117
+
118
+ func testFunctionsInExistential( p1 : P1 ) {
119
+ p1. me ( ) // okay
120
+ p1. reallyMe ( ) // expected-warning {{result of call to 'reallyMe()' is unused}}
121
+ _ = p1. reallyMe ( ) // okay
122
+ }
95
123
96
124
let x = 4
97
125
" Hello \( x+ 1 ) world " // expected-warning {{expression of type 'String' is unused}}
You can’t perform that action at this time.
0 commit comments