-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explorer: missing support for class base
, abstract
, and extends
#1881
Comments
haha,I agree you. |
Provides a first implementation iteration towards class prefix and extension, along with user-friendly error regarding missing implementation for #1881 **Explorer behavior** For class prefix `base` and `abstract`: ``` Class prefixes `base` and `abstract` are not supported yet ``` For extension with `extends`: ``` Class extension with `extends` is not supported yet ``` **Motivation** * Provides user-friendly error for these unsupported features * First implementation increment in supporting class prefix and extension.
Support class extension with `extends` Relates to #1881 Add support for: * Class extension with `extends` * Using base class methods and members
We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the |
Relates to #1881 - Add support for `.base` field in structs for [parent class initialization](https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/classes.md#constructors) - Disabling base class initialization without `.base` - Support class constructors (`Create() -> Self`) for base classes - Direct access to base class(es) attributes with `object.var` remains unaffected Changes: - Add `TypeChecker::FieldTypesWithBase` to help assessing if a struct with `base` fields can be converted to a class - Add a new `base_type()` attribute+getter to `NominalClassDeclaration` to as a first step to allow resolving parametrized classes - Add a new `base` attribute+getter to `NominalClassValue` that contains the base class `NominalClassValue`. It is currently used mainly to get and set members of a class object. - Add `Interpreter::ConvertClassWithBase` to build `NominalClassValue` from a init struct, that contains `.base` fields with either `NominalClassValue` or `StructValue` - Add `FindClassField` to find a field in a class or its base classes - Remove superfluous `ClassDeclaration::base()` in favor of `ClassDeclaration::base_type()` Limitations; - Though some work is done in that direction, parametrized base class where time is not know at the declaration site are not supported. Namely the example below does not compile ``` base class A(T:! Type) {} class B(T:! Type) extends A(T) {} ``` But this one is functional already ``` base class A(T:! Type) {} class B extends A(i32) {} ``` Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Relates to #1881 Features: * Add basic support for `abstract` class * Allow extending an abstract class * Prevent direct instantiation of an abstract class Changes: * Check that class extensibility for `VariableDefinition` is not `Abstract` * Add corresponding set of lit tests
Features: * Adds support for [subtyping](https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/classes.md#subtyping) for local variables, and function parameters Changes: * Update function parameter `Deduce` to handle subtyping * Update `InstantiateType` to support `PointerType` * Update `Convert` to support convertion from child class to a base class Relates to #1881 Co-authored-by: Jon Ross-Perkins <jperkins@google.com> Co-authored-by: Geoff Romer <gromer@google.com>
@jonmeow if we focus this issue on "Inheritance" (outside of virtual methods, etc., as in the wiki), I think we can consider this one "done" to the degree we might want to support it in explorer. |
Features: * Add `virtual` virtual override keyword for functions * Support `virtual` class methods using dynamic dispatch Changes: * Add `vtable` in `NominalClassType`, * Add `NominalClassValue**` in class values pointing to descendant-most class * Resolve virtual methods during member lookup Limitations: * Does not include yet `impl`, `abstract` virtual override keywords, or the complete logic for virtual function declaration Depends on #2460 Relates to #1881 Relates to #2493
Closing this one, based on the current Explorer implementation level 🥳 |
The explorer generates a non-specific syntax error when trying to use class prefix or extends.
The text was updated successfully, but these errors were encountered: