Skip to content

isValidMethodAccess: Instantiate signature this type if necessary#21722

Merged
1 commit merged into
masterfrom
completionsMethodWithThisParameter_instantiate
Mar 6, 2018
Merged

isValidMethodAccess: Instantiate signature this type if necessary#21722
1 commit merged into
masterfrom
completionsMethodWithThisParameter_instantiate

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Feb 7, 2018

Fixes #21711

@ghost ghost requested a review from sandersn February 7, 2018 16:14
Comment thread src/compiler/checker.ts Outdated

function createInferenceContext(signature: Signature, flags: InferenceFlags, compareTypes?: TypeComparer, baseInferences?: InferenceInfo[]): InferenceContext {
const inferences = baseInferences ? map(baseInferences, cloneInferenceInfo) : map(signature.typeParameters, createInferenceInfo);
const inferences = baseInferences ? baseInferences.map(cloneInferenceInfo) : signature.typeParameters.map(createInferenceInfo);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Looks like this function should never be called if signature.typeParameters is undefined, since we expect inferences to always be defined elsewhere.

@ghost ghost force-pushed the completionsMethodWithThisParameter_instantiate branch from 952e29b to bc54e99 Compare March 5, 2018 22:20
Comment thread src/compiler/checker.ts
return signatureThisType;
}
const context = createInferenceContext(sig.typeParameters, sig, InferenceFlags.None);
inferTypes(context.inferences, actualThisType, signatureThisType);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's a little weird to do limited inference here, but maybe it makes sense because this is called solely for completions? The inference and instantiation will happen later, and lead to an error, in normal compilation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Since the call expression doesn't actually exist (we're just considering adding the completion, all that exists so far is obj.), this won't have a corresponding normal compilation.

@ghost ghost merged commit a138985 into master Mar 6, 2018
@ghost ghost deleted the completionsMethodWithThisParameter_instantiate branch March 6, 2018 18:18
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
This pull request was closed.
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.

1 participant