From d843cc53fb6f7a7c19c2ca31da9fc0f5fd73a025 Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Fri, 21 Feb 2025 13:52:45 -0800 Subject: [PATCH] Small rephrasing of 'partial' interaction with final classes (#5000) I believe this reflects the intent, but the phrasing of "even if `MyBaseClass` is not" implies that `MyBaseClass` _can_ be final in `partial MyBaseClass`. Also, make clear it's allowed on `abstract` classes, not only `base` (this seems explicitly intended from the `MyAbstractClass` example around line 1482). --- docs/design/classes.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/docs/design/classes.md b/docs/design/classes.md index f3e94b1b5b08..84e67b994aba 100644 --- a/docs/design/classes.md +++ b/docs/design/classes.md @@ -1409,15 +1409,14 @@ The partial class type for a base class type like `MyBaseType` is written `partial MyBaseClass` to `MyBaseClass`. It changes the value by filling in the hidden vptr slot. If `MyBaseClass` is abstract, then attempting that conversion is an error. -- `partial MyBaseClass` is considered final, even if `MyBaseClass` is not. - This is despite the fact that from a data layout perspective, - `partial MyDerivedClass` will have `partial MyBaseClass` as a prefix if - `MyDerivedClass` extends `MyBaseClass`. The type `partial MyBaseClass` - specifically means "exactly this and no more." This means we don't need to - look at the hidden vptr slot, and we can instantiate it even if it doesn't - have a virtual [destructor](#destructors). -- The keyword `partial` may only be applied to a base class. For final - classes, there is no need for a second type. +- `partial MyBaseClass` is considered final. This is despite the fact that + from a data layout perspective, `partial MyDerivedClass` will have + `partial MyBaseClass` as a prefix if `MyDerivedClass` extends `MyBaseClass`. + The type `partial MyBaseClass` specifically means "exactly this and no + more." This means we don't need to look at the hidden vptr slot, and we can + instantiate it even if it doesn't have a virtual [destructor](#destructors). +- The keyword `partial` is only valid for a `base` or `abstract` class. For + final classes, there is no need for a second type. ##### Usage