feat(di): drop support for injecting types with generics in Dart

BREAKING CHANGE:
In Dart we used to support injecting types with generics. As this feature is hard to implement with the upcoming codegen we are dropping it.

Merge cl/115454020 in G3 with this change.
Closes #7262
This commit is contained in:
Tobias Bosch
2016-02-24 09:45:10 -08:00
parent f72f137261
commit c9a3df970b
9 changed files with 1 additions and 144 deletions

View File

@ -31,7 +31,7 @@ export {
ResolvedProvider,
provide
} from './di/provider';
export {Key, TypeLiteral} from './di/key';
export {Key} from './di/key';
export {
NoProviderError,
AbstractProviderError,

View File

@ -1,10 +1,7 @@
import {stringify, CONST, Type, isBlank} from 'angular2/src/facade/lang';
import {BaseException, WrappedException} from 'angular2/src/facade/exceptions';
import {TypeLiteral} from './type_literal';
import {resolveForwardRef} from './forward_ref';
export {TypeLiteral} from './type_literal';
/**
* A unique object used for retrieving items from the {@link Injector}.
*
@ -53,13 +50,6 @@ export class KeyRegistry {
get(token: Object): Key {
if (token instanceof Key) return token;
// TODO: workaround for https://github.com/Microsoft/TypeScript/issues/3123
var theToken = token;
if (token instanceof TypeLiteral) {
theToken = token.type;
}
token = theToken;
if (this._allKeys.has(token)) {
return this._allKeys.get(token);
}

View File

@ -1,26 +0,0 @@
library angular2.di.type_literal;
/**
* Use type literals as DI keys corresponding to generic types.
*
* Example:
*
* ```
* Injector.resolveAndCreate([
* bind(new TypeLiteral<List<int>>()).toValue([1, 2, 3])
* ]);
*
* class Foo {
* // Delend on `List<int>` normally.
* Foo(List<int> list) { ... }
* }
* ```
*
* This capability might be added to the language one day. See:
*
* https://code.google.com/p/dart/issues/detail?id=11923
*/
class TypeLiteral<T> {
const TypeLiteral();
Type get type => T;
}

View File

@ -1,7 +0,0 @@
/**
* Type literals is a Dart-only feature. This is here only so we can x-compile
* to multiple languages.
*/
export class TypeLiteral {
get type(): any { throw new Error("Type literals are only supported in Dart"); }
}