Closed
Description
We'd like to have code like:
class Foo {
const Foo(this.value);
final int value;
}
class FooDelegate implements Foo {
final Foo _foo;
const FooDelegate(int value) : _foo = Foo(value); // Line 10
@override
int get value => _foo.value;
}
but this fails with:
error • Invalid constant value. • const_delegate.dart:10:41 • invalid_constant
We could remove const
from the FooDelegate
constructor, but without it FooDelegate
is no longer perfectly substitutable for Foo
(const foo = FooDelegate(1);
would fail).
It would be nice if there were some way for a const
constructor to const
-construct members if possible.