Closed
Description
/**
* @constructor
* @template K, V
*/
var Multimap = function() {
/** @type {!Map.<K, !Set.<!V>>} */
this._map = new Map();
};
Multimap.prototype = {
/**
* @param {K} key // <------ error here, 'K' not found
* @param {V} value // <---- and here
*/
set: function(key, value) {
var set = this._map.get(key);
if (!set) {
set = new Set();
this._map.set(key, set);
}
set.add(value);
}
}
Expected behavior:
K
and V
are resolved to the declaration on var Multimap = function ...
.
Actual behavior:
Cannot find name 'K'. and Cannot find name 'V'.
The js-specific code in resolveEntityName needs to understand prototype assignment the same way that it does prototype property assignment. This works fine:
/**
* @param {K} key // <------ error here, 'K' not found
* @param {V} value // <---- and here
*/
Multimap.prototype.set = function {
}