mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add Self to the name scope for a class. (#3736)
Rather than just adding `Self` to the lexical scope, add it to the class's name scope so that it is visible in later lexical scopes for the same class -- in particular, for out-of-line definitions of members. Also switch some tests in `check/testdata/class` over to making idiomatic use of `Self` both inside a class and out-of-line, now that it works more consistently. Note that this does not permit using `Class.Self`, but only because we don't yet support keyword names after `.` at all. If that changed, one could use `Class.Self` to redundantly refer to `Class`. Whether we allow that is left to a future decision.
This commit is contained in:
@@ -61,6 +61,7 @@ fn G() -> C {
|
||||
// CHECK:STDOUT: %.loc18_28: <unbound element of class C> = field_decl b, element1 [template]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%C
|
||||
// CHECK:STDOUT: .a = %.loc18_16
|
||||
// CHECK:STDOUT: .b = %.loc18_28
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
@@ -53,6 +53,7 @@ fn G() -> i32 {
|
||||
// CHECK:STDOUT: %.loc9: <unbound element of class C> = field_decl b, element1 [template]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%C
|
||||
// CHECK:STDOUT: .a = %.loc8
|
||||
// CHECK:STDOUT: .b = %.loc9
|
||||
// CHECK:STDOUT: }
|
||||
|
||||
Reference in New Issue
Block a user