Skip to content

Fix javascript signature instantiation#18440

Merged
sandersn merged 3 commits into
masterfrom
fix-javascript-signature-instantiation
Sep 19, 2017
Merged

Fix javascript signature instantiation#18440
sandersn merged 3 commits into
masterfrom
fix-javascript-signature-instantiation

Conversation

@sandersn
Copy link
Copy Markdown
Member

Fixes #18254

getSignatureInstantation takes a parameter that tells whether the signature comes from Javascript and therefore is allowed to pass fewer than the required number of type arguments. (Defaults are chosen if this is the case.)

Previously, getInstantiatedConstructorsForTypeArguments forgot to provide this argument, and constructors with insufficient type arguments would cause a crash because getSignatureInstantiation would not know to fill in the missing type arguments.

getSignatureInstantation takes a parameter that tells whether the
signature comes from Javascript and therefore is allowed to pass fewer
than the required number of type arguments. (Defaults are chosen if this
is the case.)

Previously, getInstantiatedConstructorsForTypeArguments forgot to
provide this argument, and constructors with insufficient type arguments
would cause a crash because getSignatureInstantiation would not know to
fill in the missing type arguments.
Comment thread src/compiler/checker.ts Outdated
* @param minTypeArgumentCount The minimum number of required type arguments.
*/
function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, location?: Node) {
function fillMissingTypeArguments(typeArguments: Type[] | undefined, typeParameters: TypeParameter[] | undefined, minTypeArgumentCount: number, isJavaScript?: boolean) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to just make isJavascript required (same for other one)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that required parameters are generally better; I'm not convinced that they're an improvement for fillMissingTypeArguments. There are 7 calls, 2 of which are so deep in instantiation that they have to call isInJavascriptFile on a node that may or may not be relevant. One of the 6 calls to getSignatureInstantiation is like this too.

I pushed the change so we can look at it and decide if it's worthwhile.

This is a bit wordy, but will probably prevent bugs similar to #18254 in
the future.
@sandersn sandersn merged commit cc678a5 into master Sep 19, 2017
@ghost ghost deleted the fix-javascript-signature-instantiation branch September 19, 2017 16:11
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants