Files
swift-mirror/test/Sema/self_cannot_be_found.swift
Serena 99116c9bcc Change error diagnosed for when self isn't available in scope (#59140)
Diagnose different error for when `self` cannot be found in scope

Co-authored-by: Hamish Knight <hamish_github@mediocremail.com>
2022-06-03 06:24:51 +03:00

22 lines
616 B
Swift

// RUN: %target-typecheck-verify-swift
let _ = self // expected-error {{cannot find 'self' in scope; did you mean to use it in a type or extension context?}}
let s = self.b // // expected-error {{cannot find 'self' in scope; did you mean to use it in a type or extension context?}}
let w = self.method() // expected-error {{cannot find 'self' in scope; did you mean to use it in a type or extension context?}}
struct aStruct {
let b = "a"
func testFunc() {
print(self.b)
}
var c: String {
self.b
}
}
let _ = aStruct.self
let initialized = aStruct().self
_ = initialized.b