google / google/built_value.dart

is it possible to achieve abstract class inheritance?

Open
#1,149 1 comment 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
question
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

Hello, I'm attempting to achieve inheritance of an abstract type in parent class with built_value,

```
@BuiltValue(instantiable: false)
abstract class Animal {
String get name;
}

abstract class Dog implements Built, Animal {
@override
String get name;
}

@BuiltValue(instantiable: false)
abstract class Zoo {
bool get value;
Animal get animal;
}

abstract class BigZoo implements Built< BigZoo, BigZoo Builder>, Zoo {

@override
Dog get animal;

@override
bool get value => false;
}

```

The generation produces a not valid override error for the animal property, but none for the boolean property,

`'BigZoo.animal' ('AnimalBuilder Function()') isn't a valid override of 'ZooBuilder.animal' ('AnimalBuilder Function()')`

Is there some other way to achieve this type of inheritance to avoid type checking hell?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.