allow generic type constants #23221
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
closed-duplicate
Closed in favor of an existing report
type-enhancement
A request for a change that isn't a bug
to reproduce
print(List); // works
print(List<int>); // parse error. boo!
print(<int>[].runtimeType) // works, but ugly: had to create an instance.
this makes dependency injection ugly (using angular/di.dart):
abstract class Producer<T> {
T get();
}
bind(Producer, toValue: prometheus); // works, but useless: Producer is too general
var dataProducer = new DataProducerImpl();
bind(Producer<Data>, toValue: dataProducer); // parse error :-(
bind(dataProducer.runtimeType, toValue: dataProducer); // ugly, and doesn't work anyway due to bug in di
bind(new TypeLiteral<Producer<Data>>().type, toValue: new DataProducerImpl()); // works, but even uglier and hard to discover this feature
expected
if List can be used as an object, seems like List<int> should be allowed too.
then it would be possible to implement di so that
bind(Producer<Data>, toValue: dataProducer) works as expected.
this might be related to bug 12921, but the conversation there is all over the place,
so i honestly can't tell.
Dart VM version: 1.10.0-dev.0.2 (Thu Apr 2 20:17:30 2015) on "linux_x64"
The text was updated successfully, but these errors were encountered: