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 {
12281228 if (auto extSafety = getExplicitSafetyFromAttrs (ext))
12291229 return *extSafety;
12301230 }
1231-
1232- if (auto enclosingNominal = enclosingDC->getSelfNominalTypeDecl ())
1233- if (auto nominalSafety = getExplicitSafetyFromAttrs (enclosingNominal))
1234- return *nominalSafety;
12351231 }
12361232
12371233 // If an extension extends an unsafe nominal type, it's unsafe.
@@ -1241,11 +1237,12 @@ ExplicitSafety Decl::getExplicitSafety() const {
12411237 return ExplicitSafety::Unsafe;
12421238 }
12431239
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 .
12461242 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 ();
12491246 }
12501247
12511248 return ExplicitSafety::Unspecified;
Original file line number Diff line number Diff line change @@ -252,11 +252,11 @@ func testUnsafeLHS() {
252252
253253@safe
254254struct UnsafeWrapTest {
255- @ unsafe var pointer : UnsafeMutablePointer < Int > ?
255+ var pointer : UnsafeMutablePointer < Int > ?
256256
257257 func test( ) {
258258 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> '}}
260260 _ = unsafe pointer
261261 }
262262 }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ class NotSafeSubclass: NotSafe {
3838
3939 ns. stillUnsafe ( ) // expected-warning{{expression uses unsafe constructs but is not marked with 'unsafe' [StrictMemorySafety]}}
4040 // 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 '}}
4242}
4343
4444@safe func testImpliedSafetySubclass( ns: NotSafeSubclass ) {
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ extension ConformsToMultiP: MultiP {
4949 // expected-note@-1{{unsafe type 'UnsafeSuper' cannot satisfy safe associated type 'Ptr'}}
5050 @unsafe func f( ) -> UnsafeSuper {
5151 . 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 '}}
5353 }
5454}
5555
@@ -156,7 +156,7 @@ func testMe(
156156 // expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{7-7=unsafe }}
157157 _ = unsafeVar // expected-note{{reference to unsafe var 'unsafeVar'}}
158158 // 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 '}}
160160 // expected-note@-1{{reference to parameter 'unsafeSuper' involves unsafe type 'UnsafeSuper'}}
161161
162162 // 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