-
Notifications
You must be signed in to change notification settings - Fork 13k
Defer checking call and new expressions with context sensitive arguments #62381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Andarist
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
Andarist:context-sensitive-call-new-args
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
229 changes: 229 additions & 0 deletions
229
tests/baselines/reference/contextSensitiveCallNewArguments1.symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
//// [tests/cases/compiler/contextSensitiveCallNewArguments1.ts] //// | ||
|
||
=== contextSensitiveCallNewArguments1.ts === | ||
// https://github.com/microsoft/TypeScript/issues/62380 | ||
|
||
class Foo<T> { | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>T : Symbol(T, Decl(contextSensitiveCallNewArguments1.ts, 2, 10)) | ||
|
||
constructor(public inner: T) {} | ||
>inner : Symbol(Foo.inner, Decl(contextSensitiveCallNewArguments1.ts, 3, 14)) | ||
>T : Symbol(T, Decl(contextSensitiveCallNewArguments1.ts, 2, 10)) | ||
} | ||
|
||
class BarClass<T> { | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>T : Symbol(T, Decl(contextSensitiveCallNewArguments1.ts, 6, 15)) | ||
|
||
constructor(public accessor: (state: T) => boolean) {} | ||
>accessor : Symbol(BarClass.accessor, Decl(contextSensitiveCallNewArguments1.ts, 7, 14)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 7, 32)) | ||
>T : Symbol(T, Decl(contextSensitiveCallNewArguments1.ts, 6, 15)) | ||
} | ||
|
||
{ | ||
class Container<C, F> { | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 10, 1)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 11, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 11, 20)) | ||
|
||
constructor( | ||
public ctx: C, | ||
>ctx : Symbol(Container.ctx, Decl(contextSensitiveCallNewArguments1.ts, 12, 16)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 11, 18)) | ||
|
||
public fooFactory: (ctx: C) => F, | ||
>fooFactory : Symbol(Container.fooFactory, Decl(contextSensitiveCallNewArguments1.ts, 13, 20)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 14, 26)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 11, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 11, 20)) | ||
|
||
public bars: BarClass<F>[], | ||
>bars : Symbol(Container.bars, Decl(contextSensitiveCallNewArguments1.ts, 14, 39)) | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 11, 20)) | ||
|
||
) {} | ||
} | ||
|
||
const container = new Container(42, (ctx) => new Foo({ answer: ctx }), [ | ||
>container : Symbol(container, Decl(contextSensitiveCallNewArguments1.ts, 19, 7)) | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 10, 1)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 19, 39)) | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>answer : Symbol(answer, Decl(contextSensitiveCallNewArguments1.ts, 19, 56)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 19, 39)) | ||
|
||
new BarClass((state) => true), | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 20, 18)) | ||
|
||
]); | ||
} | ||
|
||
{ | ||
class Container<C, F> { | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 24, 1)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 25, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 25, 20)) | ||
|
||
constructor( | ||
public ctx: C, | ||
>ctx : Symbol(Container.ctx, Decl(contextSensitiveCallNewArguments1.ts, 26, 16)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 25, 18)) | ||
|
||
public fooFactory: (ctx: C) => F, | ||
>fooFactory : Symbol(Container.fooFactory, Decl(contextSensitiveCallNewArguments1.ts, 27, 20)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 28, 26)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 25, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 25, 20)) | ||
|
||
public bar: BarClass<F>, | ||
>bar : Symbol(Container.bar, Decl(contextSensitiveCallNewArguments1.ts, 28, 39)) | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 25, 20)) | ||
|
||
) {} | ||
} | ||
|
||
const containerWithoutAnnotation = new Container( | ||
>containerWithoutAnnotation : Symbol(containerWithoutAnnotation, Decl(contextSensitiveCallNewArguments1.ts, 33, 7)) | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 24, 1)) | ||
|
||
42, | ||
(ctx) => new Foo({ answer: ctx }), | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 35, 5)) | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>answer : Symbol(answer, Decl(contextSensitiveCallNewArguments1.ts, 35, 22)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 35, 5)) | ||
|
||
new BarClass((state) => true), | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 36, 18)) | ||
|
||
); | ||
|
||
const containerWithAnnotation = new Container( | ||
>containerWithAnnotation : Symbol(containerWithAnnotation, Decl(contextSensitiveCallNewArguments1.ts, 39, 7)) | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 24, 1)) | ||
|
||
42, | ||
(ctx: number) => new Foo({ answer: ctx }), | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 41, 5)) | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>answer : Symbol(answer, Decl(contextSensitiveCallNewArguments1.ts, 41, 30)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 41, 5)) | ||
|
||
new BarClass((state) => true), | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 42, 18)) | ||
|
||
); | ||
} | ||
|
||
{ | ||
class Container<C, F> { | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 46, 1)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 47, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 47, 20)) | ||
|
||
constructor( | ||
public ctx: C, | ||
>ctx : Symbol(Container.ctx, Decl(contextSensitiveCallNewArguments1.ts, 48, 16)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 47, 18)) | ||
|
||
public fooFactory: (ctx: C) => F, | ||
>fooFactory : Symbol(Container.fooFactory, Decl(contextSensitiveCallNewArguments1.ts, 49, 20)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 50, 26)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 47, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 47, 20)) | ||
|
||
public barFactory: () => BarClass<F>, | ||
>barFactory : Symbol(Container.barFactory, Decl(contextSensitiveCallNewArguments1.ts, 50, 39)) | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 47, 20)) | ||
|
||
) {} | ||
} | ||
|
||
const container = new Container( | ||
>container : Symbol(container, Decl(contextSensitiveCallNewArguments1.ts, 55, 7)) | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 46, 1)) | ||
|
||
42, | ||
(ctx) => new Foo({ answer: ctx }), | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 57, 5)) | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>answer : Symbol(answer, Decl(contextSensitiveCallNewArguments1.ts, 57, 22)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 57, 5)) | ||
|
||
() => new BarClass((state) => true), | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 58, 24)) | ||
|
||
); | ||
} | ||
|
||
{ | ||
class Container<C, F> { | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 62, 1)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 63, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 63, 20)) | ||
|
||
constructor( | ||
public ctx: C, | ||
>ctx : Symbol(Container.ctx, Decl(contextSensitiveCallNewArguments1.ts, 64, 16)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 63, 18)) | ||
|
||
public fooFactory: (ctx: C) => F, | ||
>fooFactory : Symbol(Container.fooFactory, Decl(contextSensitiveCallNewArguments1.ts, 65, 20)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 66, 26)) | ||
>C : Symbol(C, Decl(contextSensitiveCallNewArguments1.ts, 63, 18)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 63, 20)) | ||
|
||
public barFactory: (dummy: never) => BarClass<F>, | ||
>barFactory : Symbol(Container.barFactory, Decl(contextSensitiveCallNewArguments1.ts, 66, 39)) | ||
>dummy : Symbol(dummy, Decl(contextSensitiveCallNewArguments1.ts, 67, 26)) | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>F : Symbol(F, Decl(contextSensitiveCallNewArguments1.ts, 63, 20)) | ||
|
||
) {} | ||
} | ||
|
||
const containerWithDummy = new Container( | ||
>containerWithDummy : Symbol(containerWithDummy, Decl(contextSensitiveCallNewArguments1.ts, 71, 7)) | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 62, 1)) | ||
|
||
42, | ||
(ctx) => new Foo({ answer: ctx }), | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 73, 5)) | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>answer : Symbol(answer, Decl(contextSensitiveCallNewArguments1.ts, 73, 22)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 73, 5)) | ||
|
||
(dummy) => new BarClass((state) => true), | ||
>dummy : Symbol(dummy, Decl(contextSensitiveCallNewArguments1.ts, 74, 5)) | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 74, 29)) | ||
|
||
); | ||
|
||
const containerWithWrongArity = new Container( | ||
>containerWithWrongArity : Symbol(containerWithWrongArity, Decl(contextSensitiveCallNewArguments1.ts, 77, 7)) | ||
>Container : Symbol(Container, Decl(contextSensitiveCallNewArguments1.ts, 62, 1)) | ||
|
||
42, | ||
(ctx) => new Foo({ answer: ctx }), | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 79, 5)) | ||
>Foo : Symbol(Foo, Decl(contextSensitiveCallNewArguments1.ts, 0, 0)) | ||
>answer : Symbol(answer, Decl(contextSensitiveCallNewArguments1.ts, 79, 22)) | ||
>ctx : Symbol(ctx, Decl(contextSensitiveCallNewArguments1.ts, 79, 5)) | ||
|
||
() => new BarClass((state) => true), | ||
>BarClass : Symbol(BarClass, Decl(contextSensitiveCallNewArguments1.ts, 4, 1)) | ||
>state : Symbol(state, Decl(contextSensitiveCallNewArguments1.ts, 80, 24)) | ||
|
||
); | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is put together quickly - as an experiment. I didn't think through how those new codepaths that call
skippedGenericFunction
and returnresolvingSignature
might affect existing code.The existing test suite doesn't immediately show this is a terrible idea though. It would be nice if an extended test suite could be ran for this experiment. cc @jakebailey
EDIT:// actually... the self-check fails here so it's probably not worth running the extended test suite at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakebailey could you run tests here now? I kinda fully expect this PR to be garbage and break things but I'd like to get some test cases from the compiler usage in the wild that could be included in the in-repo test suite