File tree Expand file tree Collapse file tree 4 files changed +10
-13
lines changed Expand file tree Collapse file tree 4 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -1228,10 +1228,6 @@ ExplicitSafety Decl::getExplicitSafety() const {
1228
1228
if (auto extSafety = getExplicitSafetyFromAttrs (ext))
1229
1229
return *extSafety;
1230
1230
}
1231
-
1232
- if (auto enclosingNominal = enclosingDC->getSelfNominalTypeDecl ())
1233
- if (auto nominalSafety = getExplicitSafetyFromAttrs (enclosingNominal))
1234
- return *nominalSafety;
1235
1231
}
1236
1232
1237
1233
// If an extension extends an unsafe nominal type, it's unsafe.
@@ -1241,11 +1237,12 @@ ExplicitSafety Decl::getExplicitSafety() const {
1241
1237
return ExplicitSafety::Unsafe;
1242
1238
}
1243
1239
1244
- // If this is a pattern binding declaration, check whether the first
1245
- // variable is @unsafe .
1240
+ // If this is a pattern binding declaration, check whether there is a
1241
+ // safety-related attribute on the first variable we find .
1246
1242
if (auto patternBinding = dyn_cast<PatternBindingDecl>(this )) {
1247
- if (auto var = patternBinding->getSingleVar ())
1248
- return var->getExplicitSafety ();
1243
+ for (auto index : range (patternBinding->getNumPatternEntries ()))
1244
+ if (auto var = patternBinding->getAnchoringVarDecl (index))
1245
+ return var->getExplicitSafety ();
1249
1246
}
1250
1247
1251
1248
return ExplicitSafety::Unspecified;
Original file line number Diff line number Diff line change @@ -252,11 +252,11 @@ func testUnsafeLHS() {
252
252
253
253
@safe
254
254
struct UnsafeWrapTest {
255
- @ unsafe var pointer : UnsafeMutablePointer < Int > ?
255
+ var pointer : UnsafeMutablePointer < Int > ?
256
256
257
257
func test( ) {
258
258
if let pointer { // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{19-19= = unsafe pointer}}
259
- // expected-note@-1{{reference to unsafe property 'pointer'}}
259
+ // expected-note@-1{{reference to property 'pointer' involves unsafe type 'UnsafeMutablePointer<Int> '}}
260
260
_ = unsafe pointer
261
261
}
262
262
}
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class NotSafeSubclass: NotSafe {
38
38
39
39
ns. stillUnsafe ( ) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
40
40
// expected-note@-1{{reference to parameter 'ns' involves unsafe type 'NotSafe'}}
41
- // expected-note@-2{{reference to unsafe instance method 'stillUnsafe()'}}
41
+ // expected-note@-2{{reference to instance method 'stillUnsafe()' involves unsafe type 'NotSafe '}}
42
42
}
43
43
44
44
@safe func testImpliedSafetySubclass( ns: NotSafeSubclass ) {
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ extension ConformsToMultiP: MultiP {
49
49
// expected-note@-1{{unsafe type 'UnsafeSuper' cannot satisfy safe associated type 'Ptr'}}
50
50
@unsafe func f( ) -> UnsafeSuper {
51
51
. init( ) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe'}}
52
- // expected-note@-1{{reference to unsafe initializer 'init()'}}
52
+ // expected-note@-1{{reference to initializer 'init()' involves unsafe type 'UnsafeSuper '}}
53
53
}
54
54
}
55
55
@@ -156,7 +156,7 @@ func testMe(
156
156
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{7-7=unsafe }}
157
157
_ = unsafeVar // expected-note{{reference to unsafe var 'unsafeVar'}}
158
158
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{3-3=unsafe }}
159
- unsafeSuper. f ( ) // expected-note{{reference to unsafe instance method 'f()'}}
159
+ unsafeSuper. f ( ) // expected-note{{reference to instance method 'f()' involves unsafe type 'UnsafeSuper '}}
160
160
// expected-note@-1{{reference to parameter 'unsafeSuper' involves unsafe type 'UnsafeSuper'}}
161
161
162
162
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{7-7=unsafe }}
You can’t perform that action at this time.
0 commit comments