feat(runtime): add memoization to genericType()

This is an initial implementation (lacking unit tests).

The rationale is that we need `genericType(Foo, Bar) === genericType(Foo, Bar)` for the Dependency injection in Angular.

Before this PR it was not possible to detect when two generic types match (as they are not ===).


You should be able to import Map from runtime polyfills. We do that in a
few places as already.
On Nov 21, 2014 1:03 AM, "Victor Berchet" <notifications@github.com> wrote:

> In src/runtime/type-assertions.js:
>
> >      }
> > +
> > +    return typeMap[key];
> > +  }
> > +
> > +  function getTypeKey(type) {
> > +    if (type instanceof PrimitiveType) return type.name;
> > +    if (type instanceof GenericType) return type.uid;
> > +    return type;
>
> This was the subject of my question above (Is this code fine if key is a
> ctor ? (getTypeKey(Klass) -> ctor))
>
> I actually tried to use a Map first but it would not compile, apparently
> adding export var Map = window.Map; fixes the compilation issue.
>
> I fine with either alternative, uid should be more efficient than the
> polyfill for browsers that don't have native support.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/google/traceur-compiler/pull/1523/files#r20704493>.
>