mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SE-0458: Disambiguate postfix expressions vs. unsafe expressions more generally
Handle call-vs-tuple and subscript-vs-collection-expr disambiguation using the same "no trivia" rule that we used to disambiguite "unsafe.x" (which we treat as a member access) from "unsafe .x" (which we treat as an unsafe expression with a leading-dot member access). Fixes rdar://146459104.
This commit is contained in:
@@ -183,6 +183,8 @@ func acceptBools(_: Bool, _: Bool) { }
|
||||
|
||||
func acceptBoolsUnsafeLabel(unsafe _: Bool, _: Bool) { }
|
||||
|
||||
func unsafe(_: Int) { }
|
||||
|
||||
func unsafeFun() {
|
||||
var unsafe = true
|
||||
unsafe = false
|
||||
@@ -200,6 +202,20 @@ func unsafeFun() {
|
||||
if unsafe { }
|
||||
}
|
||||
|
||||
func moreUnsafeFunc(unsafe: [Int]) {
|
||||
let _: [Int] = unsafe []
|
||||
// expected-warning@-1{{no unsafe operations occur within 'unsafe' expression}}
|
||||
|
||||
_ = unsafe[1]
|
||||
}
|
||||
|
||||
func yetMoreUnsafeFunc(unsafe: () -> Void) {
|
||||
unsafe()
|
||||
|
||||
_ = unsafe ()
|
||||
// expected-warning@-1{{no unsafe operations occur within 'unsafe' expression}}
|
||||
}
|
||||
|
||||
// @safe suppresses unsafe-type-related diagnostics on an entity
|
||||
struct MyArray<Element> {
|
||||
@safe func withUnsafeBufferPointer<R, E>(
|
||||
|
||||
Reference in New Issue
Block a user