Skip to content

Fix generic return type inference #31680

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

Merged
merged 4 commits into from
May 30, 2019
Merged

Conversation

ahejlsberg
Copy link
Member

Fixes #31443.

@weswigham
Copy link
Member

@typescript-bot run dt
@typescript-bot test this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 30, 2019

Heya @weswigham, I've started to run the extended test suite on this PR at c3ef035. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 30, 2019

Heya @weswigham, I've started to run the parallelized Definitely Typed test suite on this PR at c3ef035. You can monitor the build here. It should now contribute to this PR's status checks.

context.returnMapper = getMapperFromContext(cloneInferredPartOfContext(context));
const returnContext = createInferenceContext(signature.typeParameters!, signature, context.flags);
const returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
Copy link
Member

Choose a reason for hiding this comment

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

The extra invocation of inference here probably warrants a comment as to why it's needed, especially seeing as its removal affects only the one test just added. 😄

@weswigham
Copy link
Member

@typescript-bot test this again - afaik none of the auth tokens need to be refreshed for months, so maybe it was just a hiccup in the auth service?

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 30, 2019

Heya @weswigham, I've started to run the extended test suite on this PR at c3ef035. You can monitor the build here. It should now contribute to this PR's status checks.

@ahejlsberg
Copy link
Member Author

@typescript-bot perf test

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 30, 2019

Heya @ahejlsberg, I've started to run the perf test suite on this PR at c3ef035. You can monitor the build here. It should now contribute to this PR's status checks.

Update: The results are in!

@weswigham
Copy link
Member

@typescript-bot test this but now I've refreshed the credentials so if you don't work I'll know something's wrong.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 30, 2019

Heya @weswigham, I've started to run the extended test suite on this PR at c3ef035. You can monitor the build here. It should now contribute to this PR's status checks.

@typescript-bot
Copy link
Collaborator

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

Comparison Report - master..31680

Metric master 31680 Delta Best Worst
Angular - node (v12.1.0, x64)
Memory used 315,030k (± 0.03%) 314,970k (± 0.02%) -60k (- 0.02%) 314,798k 315,055k
Parse Time 1.38s (± 0.48%) 1.38s (± 0.61%) -0.00s (- 0.29%) 1.36s 1.40s
Bind Time 0.73s (± 0.61%) 0.73s (± 0.65%) -0.00s (- 0.14%) 0.72s 0.74s
Check Time 4.10s (± 0.59%) 4.04s (± 0.37%) -0.07s (- 1.66%) 4.00s 4.08s
Emit Time 5.14s (± 1.22%) 5.12s (± 1.11%) -0.02s (- 0.41%) 5.05s 5.30s
Total Time 11.35s (± 0.68%) 11.26s (± 0.54%) -0.09s (- 0.78%) 11.17s 11.45s
Monaco - node (v12.1.0, x64)
Memory used 343,839k (± 0.02%) 343,770k (± 0.01%) -69k (- 0.02%) 343,669k 343,908k
Parse Time 1.18s (± 0.75%) 1.17s (± 0.44%) -0.01s (- 1.10%) 1.16s 1.18s
Bind Time 0.67s (± 0.96%) 0.67s (± 0.44%) -0.00s (- 0.00%) 0.67s 0.68s
Check Time 4.18s (± 0.74%) 4.16s (± 0.61%) -0.02s (- 0.57%) 4.11s 4.22s
Emit Time 2.78s (± 0.64%) 2.77s (± 0.66%) -0.02s (- 0.57%) 2.73s 2.81s
Total Time 8.82s (± 0.53%) 8.76s (± 0.38%) -0.06s (- 0.65%) 8.69s 8.85s
TFS - node (v12.1.0, x64)
Memory used 300,832k (± 0.02%) 300,776k (± 0.01%) -56k (- 0.02%) 300,691k 300,857k
Parse Time 0.91s (± 1.12%) 0.90s (± 0.86%) -0.01s (- 0.88%) 0.89s 0.92s
Bind Time 0.61s (± 0.78%) 0.62s (± 0.89%) +0.01s (+ 1.47%) 0.61s 0.63s
Check Time 3.77s (± 0.59%) 3.72s (± 0.44%) -0.05s (- 1.19%) 3.67s 3.75s
Emit Time 2.86s (± 0.46%) 2.85s (± 0.84%) -0.01s (- 0.52%) 2.79s 2.89s
Total Time 8.15s (± 0.33%) 8.09s (± 0.28%) -0.06s (- 0.67%) 8.04s 8.13s
Angular - node (v8.9.0, x64)
Memory used 332,965k (± 0.01%) 332,926k (± 0.02%) -39k (- 0.01%) 332,772k 333,032k
Parse Time 1.78s (± 0.43%) 1.78s (± 0.47%) -0.00s (- 0.00%) 1.75s 1.79s
Bind Time 0.79s (± 0.76%) 0.79s (± 0.89%) +0.00s (+ 0.38%) 0.78s 0.81s
Check Time 4.75s (± 1.34%) 4.85s (± 1.04%) +0.10s (+ 2.06%) 4.69s 4.96s
Emit Time 5.80s (± 2.34%) 5.69s (± 1.52%) -0.11s (- 1.91%) 5.56s 5.88s
Total Time 13.11s (± 0.75%) 13.10s (± 0.74%) -0.01s (- 0.08%) 12.96s 13.41s
Monaco - node (v8.9.0, x64)
Memory used 360,852k (± 0.02%) 360,867k (± 0.02%) +16k (+ 0.00%) 360,745k 361,124k
Parse Time 1.44s (± 0.57%) 1.44s (± 0.66%) 0.00s ( 0.00%) 1.42s 1.45s
Bind Time 0.89s (± 2.07%) 0.91s (± 1.48%) +0.02s (+ 2.02%) 0.88s 0.93s
Check Time 5.11s (± 1.72%) 4.94s (± 1.69%) -0.17s (- 3.35%) 4.86s 5.19s
Emit Time 3.01s (± 6.54%) 3.30s (± 5.18%) +0.28s (+ 9.32%) 2.83s 3.46s
Total Time 10.45s (± 1.33%) 10.58s (± 0.97%) +0.13s (+ 1.25%) 10.29s 10.71s
TFS - node (v8.9.0, x64)
Memory used 316,381k (± 0.01%) 316,322k (± 0.01%) -59k (- 0.02%) 316,251k 316,413k
Parse Time 1.14s (± 0.43%) 1.13s (± 0.53%) -0.00s (- 0.09%) 1.13s 1.15s
Bind Time 0.66s (± 0.87%) 0.66s (± 0.71%) -0.00s (- 0.00%) 0.65s 0.67s
Check Time 4.35s (± 0.47%) 4.30s (± 0.30%) -0.05s (- 1.13%) 4.28s 4.33s
Emit Time 3.12s (± 0.40%) 3.13s (± 0.66%) +0.01s (+ 0.19%) 3.05s 3.15s
Total Time 9.27s (± 0.33%) 9.22s (± 0.34%) -0.05s (- 0.50%) 9.12s 9.27s
Angular - node (v8.9.0, x86)
Memory used 188,653k (± 0.02%) 188,590k (± 0.03%) -63k (- 0.03%) 188,457k 188,684k
Parse Time 1.72s (± 1.00%) 1.72s (± 0.70%) -0.00s (- 0.17%) 1.70s 1.75s
Bind Time 0.93s (± 0.51%) 0.92s (± 0.67%) -0.01s (- 1.18%) 0.91s 0.93s
Check Time 4.43s (± 0.60%) 4.39s (± 0.73%) -0.04s (- 1.01%) 4.31s 4.46s
Emit Time 5.69s (± 1.31%) 5.59s (± 1.57%) -0.09s (- 1.60%) 5.42s 5.86s
Total Time 12.77s (± 0.70%) 12.62s (± 0.81%) -0.15s (- 1.19%) 12.43s 12.89s
Monaco - node (v8.9.0, x86)
Memory used 201,358k (± 0.02%) 201,355k (± 0.02%) -3k (- 0.00%) 201,218k 201,426k
Parse Time 1.49s (± 1.04%) 1.49s (± 0.37%) -0.00s (- 0.33%) 1.48s 1.50s
Bind Time 0.72s (± 1.90%) 0.71s (± 1.16%) -0.00s (- 0.42%) 0.70s 0.74s
Check Time 4.76s (± 0.52%) 4.73s (± 0.75%) -0.03s (- 0.57%) 4.68s 4.82s
Emit Time 3.09s (± 0.66%) 3.07s (± 0.60%) -0.02s (- 0.52%) 3.02s 3.10s
Total Time 10.06s (± 0.37%) 10.01s (± 0.42%) -0.05s (- 0.51%) 9.93s 10.10s
TFS - node (v8.9.0, x86)
Memory used 177,462k (± 0.02%) 177,449k (± 0.03%) -14k (- 0.01%) 177,389k 177,612k
Parse Time 1.19s (± 0.54%) 1.19s (± 0.93%) -0.00s (- 0.42%) 1.16s 1.22s
Bind Time 0.64s (± 0.77%) 0.63s (± 1.06%) -0.00s (- 0.47%) 0.62s 0.65s
Check Time 4.17s (± 0.86%) 4.13s (± 0.42%) -0.04s (- 1.06%) 4.08s 4.17s
Emit Time 2.77s (± 0.75%) 2.74s (± 1.06%) -0.03s (- 1.15%) 2.68s 2.79s
Total Time 8.77s (± 0.60%) 8.69s (± 0.30%) -0.08s (- 0.90%) 8.62s 8.76s
Angular - node (v9.0.0, x64)
Memory used 332,985k (± 0.01%) 332,835k (± 0.02%) -150k (- 0.04%) 332,719k 332,940k
Parse Time 1.62s (± 0.52%) 1.61s (± 0.44%) -0.01s (- 0.74%) 1.60s 1.63s
Bind Time 0.75s (± 0.78%) 0.74s (± 0.63%) -0.01s (- 0.94%) 0.73s 0.75s
Check Time 4.46s (± 1.14%) 4.40s (± 0.79%) -0.06s (- 1.28%) 4.35s 4.47s
Emit Time 5.74s (± 2.55%) 5.61s (± 0.70%) -0.13s (- 2.26%) 5.54s 5.73s
Total Time 12.57s (± 1.50%) 12.37s (± 0.53%) -0.20s (- 1.60%) 12.27s 12.54s
Monaco - node (v9.0.0, x64)
Memory used 360,740k (± 0.02%) 360,507k (± 0.03%) -233k (- 0.06%) 360,334k 360,754k
Parse Time 1.28s (± 0.41%) 1.28s (± 0.64%) -0.00s (- 0.08%) 1.26s 1.30s
Bind Time 0.85s (± 0.53%) 0.85s (± 0.47%) +0.00s (+ 0.12%) 0.84s 0.86s
Check Time 4.81s (± 0.57%) 4.77s (± 0.29%) -0.04s (- 0.77%) 4.73s 4.80s
Emit Time 3.28s (± 0.63%) 3.26s (± 0.37%) -0.02s (- 0.58%) 3.23s 3.29s
Total Time 10.23s (± 0.46%) 10.17s (± 0.21%) -0.06s (- 0.62%) 10.12s 10.21s
TFS - node (v9.0.0, x64)
Memory used 316,165k (± 0.01%) 316,142k (± 0.02%) -24k (- 0.01%) 315,996k 316,249k
Parse Time 1.01s (± 0.81%) 1.01s (± 0.84%) -0.00s (- 0.10%) 0.99s 1.03s
Bind Time 0.61s (± 0.59%) 0.61s (± 0.77%) -0.00s (- 0.65%) 0.60s 0.62s
Check Time 4.35s (± 1.75%) 4.34s (± 2.14%) -0.00s (- 0.02%) 4.20s 4.54s
Emit Time 3.04s (± 3.36%) 2.95s (± 3.35%) -0.09s (- 2.89%) 2.78s 3.12s
Total Time 9.02s (± 0.59%) 8.92s (± 0.46%) -0.10s (- 1.11%) 8.78s 8.98s
Angular - node (v9.0.0, x86)
Memory used 188,906k (± 0.02%) 188,699k (± 0.03%) -207k (- 0.11%) 188,578k 188,874k
Parse Time 1.54s (± 0.61%) 1.52s (± 0.50%) -0.01s (- 0.78%) 1.51s 1.54s
Bind Time 0.87s (± 1.08%) 0.86s (± 0.65%) -0.01s (- 1.38%) 0.85s 0.87s
Check Time 4.12s (± 0.33%) 4.08s (± 0.30%) -0.04s (- 0.97%) 4.05s 4.10s
Emit Time 5.38s (± 0.77%) 5.32s (± 0.49%) -0.06s (- 1.06%) 5.26s 5.38s
Total Time 11.91s (± 0.37%) 11.79s (± 0.33%) -0.12s (- 1.02%) 11.68s 11.87s
Monaco - node (v9.0.0, x86)
Memory used 201,419k (± 0.03%) 201,354k (± 0.03%) -66k (- 0.03%) 201,181k 201,486k
Parse Time 1.31s (± 0.79%) 1.30s (± 0.70%) -0.01s (- 0.99%) 1.28s 1.32s
Bind Time 0.65s (± 2.01%) 0.64s (± 0.78%) -0.01s (- 1.55%) 0.63s 0.65s
Check Time 4.58s (± 0.52%) 4.56s (± 0.41%) -0.03s (- 0.55%) 4.52s 4.60s
Emit Time 3.01s (± 0.62%) 3.01s (± 0.35%) +0.00s (+ 0.17%) 2.99s 3.04s
Total Time 9.55s (± 0.37%) 9.51s (± 0.23%) -0.04s (- 0.45%) 9.46s 9.54s
TFS - node (v9.0.0, x86)
Memory used 177,517k (± 0.03%) 177,462k (± 0.02%) -55k (- 0.03%) 177,400k 177,563k
Parse Time 1.02s (± 0.65%) 1.02s (± 0.74%) +0.00s (+ 0.10%) 1.01s 1.04s
Bind Time 0.58s (± 1.03%) 0.58s (± 2.04%) +0.01s (+ 1.04%) 0.57s 0.62s
Check Time 4.01s (± 0.88%) 4.00s (± 0.40%) -0.01s (- 0.20%) 3.98s 4.04s
Emit Time 2.69s (± 0.95%) 2.70s (± 1.21%) +0.02s (+ 0.56%) 2.65s 2.81s
Total Time 8.30s (± 0.58%) 8.31s (± 0.56%) +0.01s (+ 0.13%) 8.24s 8.47s
System
Machine Namets-ci-ubuntu
Platformlinux 4.4.0-142-generic
Architecturex64
Available Memory16 GB
Available Memory1 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v12.1.0, x64)
  • node (v8.9.0, x64)
  • node (v8.9.0, x86)
  • node (v9.0.0, x64)
  • node (v9.0.0, x86)
Scenarios
  • Angular - node (v12.1.0, x64)
  • Angular - node (v8.9.0, x64)
  • Angular - node (v8.9.0, x86)
  • Angular - node (v9.0.0, x64)
  • Angular - node (v9.0.0, x86)
  • Monaco - node (v12.1.0, x64)
  • Monaco - node (v8.9.0, x64)
  • Monaco - node (v8.9.0, x86)
  • Monaco - node (v9.0.0, x64)
  • Monaco - node (v9.0.0, x86)
  • TFS - node (v12.1.0, x64)
  • TFS - node (v8.9.0, x64)
  • TFS - node (v8.9.0, x86)
  • TFS - node (v9.0.0, x64)
  • TFS - node (v9.0.0, x86)
Benchmark Name Iterations
Current 31680 10
Baseline master 10

@weswigham
Copy link
Member

Monaco - node (v8.9.0, x64)/Emit Time was outside of the allowed range (9.32% worse than baseline).‌

@rbuckton this one platform/solution combination is consistently an outlier - do we know what's up with it yet? Its emit times (and only emit) are always mega high variance, comparatively speaking.

@ahejlsberg ahejlsberg merged commit 7dc1f40 into master May 30, 2019
@ahejlsberg ahejlsberg deleted the fixGenericReturnTypeInference branch May 30, 2019 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression of incorrect literal inference in generic function in 3.4
3 participants