Skip to content
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

Properly handle typeof this.xxx in isTypeParameterPossiblyReferenced #54208

Merged
merged 3 commits into from May 20, 2023

Conversation

ahejlsberg
Copy link
Member

This PR fixes a defect in the logic introduced by #50070. Specifically, that logic wasn't properly handling type queries of the form typeof this.xxx.

Fixes #54167.

@typescript-bot typescript-bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels May 10, 2023
return some(firstIdentifierSymbol.declarations, idDecl => isNodeDescendantOf(idDecl, tpScope)) ||
some((node as TypeQueryNode).typeArguments, containsReference);
if (!isThisIdentifier(firstIdentifier)) { // Don't attempt to analyze typeof this.xxx
const firstIdentifierSymbol = getResolvedSymbol(firstIdentifier);
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity, where/why do things go wrong if firstIdentifier is this? Is it in this call to getResolvedSymbol?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it goes wrong because this is never actually a symbol you can look up. In expressions, this isn't even an identifier, it's encoded as a ThisExpression AST node. However, a type query stores the dotted name as an EntityName, and in those this is just an identifier.

@sandersn sandersn added this to Not started in PR Backlog May 19, 2023
@ahejlsberg
Copy link
Member Author

@typescript-bot test this
@typescript-bot user test this inline
@typescript-bot run dt
@typescript-bot perf test faster
@typescript-bot test top100

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2023

Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at e67193d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2023

Heya @ahejlsberg, I've started to run the extended test suite on this PR at e67193d. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2023

Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at e67193d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2023

Heya @ahejlsberg, I've started to run the diff-based user code test suite on this PR at e67193d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 19, 2023

Heya @ahejlsberg, I've started to run the diff-based top-repos suite on this PR at e67193d. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user test suite comparing main and refs/pull/54208/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"
  • 1 instance of "Package install failed"

Otherwise...

Everything looks good!

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..54208

Metric main 54208 Delta Best Worst p-value
Angular - node (v16.17.1, x64)
Memory used 365,135k (± 0.01%) 365,097k (± 0.02%) ~ 365,017k 365,220k p=0.230 n=6
Parse Time 3.56s (± 0.42%) 3.55s (± 0.41%) ~ 3.53s 3.57s p=0.564 n=6
Bind Time 1.18s (± 0.35%) 1.18s (± 0.54%) ~ 1.17s 1.19s p=0.673 n=6
Check Time 9.56s (± 0.38%) 9.61s (± 0.54%) ~ 9.53s 9.68s p=0.092 n=6
Emit Time 7.90s (± 0.42%) 7.94s (± 0.73%) ~ 7.88s 8.05s p=0.145 n=6
Total Time 22.19s (± 0.21%) 22.28s (± 0.29%) +0.09s (+ 0.40%) 22.19s 22.39s p=0.036 n=6
Compiler-Unions - node (v16.17.1, x64)
Memory used 192,939k (± 0.03%) 192,901k (± 0.02%) ~ 192,868k 192,948k p=0.298 n=6
Parse Time 1.59s (± 0.94%) 1.59s (± 1.66%) ~ 1.56s 1.63s p=0.513 n=6
Bind Time 0.82s (± 0.63%) 0.83s (± 0.99%) ~ 0.82s 0.84s p=0.523 n=6
Check Time 10.17s (± 0.83%) 10.19s (± 0.72%) ~ 10.13s 10.29s p=0.810 n=6
Emit Time 3.00s (± 1.22%) 2.98s (± 0.81%) ~ 2.94s 3.01s p=0.373 n=6
Total Time 15.59s (± 0.45%) 15.59s (± 0.52%) ~ 15.51s 15.70s p=0.810 n=6
Monaco - node (v16.17.1, x64)
Memory used 345,876k (± 0.00%) 345,877k (± 0.00%) ~ 345,860k 345,895k p=1.000 n=6
Parse Time 2.72s (± 0.30%) 2.73s (± 0.38%) ~ 2.71s 2.74s p=0.865 n=6
Bind Time 1.08s (± 0.38%) 1.09s (± 0.47%) ~ 1.08s 1.09s p=0.112 n=6
Check Time 7.82s (± 0.32%) 7.81s (± 0.47%) ~ 7.77s 7.86s p=0.809 n=6
Emit Time 4.43s (± 0.53%) 4.46s (± 0.62%) ~ 4.44s 4.51s p=0.191 n=6
Total Time 16.06s (± 0.21%) 16.08s (± 0.32%) ~ 16.04s 16.18s p=0.936 n=6
TFS - node (v16.17.1, x64)
Memory used 299,962k (± 0.00%) 299,954k (± 0.01%) ~ 299,929k 299,988k p=0.630 n=6
Parse Time 2.16s (± 0.49%) 2.16s (± 0.38%) ~ 2.15s 2.17s p=0.865 n=6
Bind Time 1.24s (± 0.61%) 1.24s (± 1.22%) ~ 1.22s 1.25s p=1.000 n=6
Check Time 7.29s (± 0.18%) 7.28s (± 0.50%) ~ 7.22s 7.33s p=0.460 n=6
Emit Time 4.33s (± 0.74%) 4.34s (± 1.26%) ~ 4.27s 4.42s p=0.936 n=6
Total Time 15.01s (± 0.28%) 15.02s (± 0.50%) ~ 14.94s 15.11s p=1.000 n=6
material-ui - node (v16.17.1, x64)
Memory used 480,938k (± 0.01%) 480,936k (± 0.00%) ~ 480,910k 480,966k p=0.936 n=6
Parse Time 3.25s (± 0.19%) 3.25s (± 0.63%) ~ 3.24s 3.29s p=0.498 n=6
Bind Time 0.94s (± 0.43%) 0.94s (± 0.00%) ~ 0.94s 0.94s p=0.405 n=6
Check Time 17.86s (± 0.62%) 17.92s (± 1.47%) ~ 17.68s 18.37s p=0.810 n=6
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) ~ 0.00s 0.00s p=1.000 n=6
Total Time 22.05s (± 0.53%) 22.12s (± 1.20%) ~ 21.86s 22.56s p=0.872 n=6
xstate - node (v16.17.1, x64)
Memory used 560,498k (± 0.02%) 560,495k (± 0.02%) ~ 560,391k 560,685k p=0.810 n=6
Parse Time 4.01s (± 0.53%) 3.99s (± 0.25%) ~ 3.98s 4.00s p=0.164 n=6
Bind Time 1.76s (± 0.23%) 1.76s (± 0.43%) ~ 1.75s 1.77s p=0.389 n=6
Check Time 3.06s (± 1.04%) 3.08s (± 0.86%) ~ 3.05s 3.11s p=0.295 n=6
Emit Time 0.09s (± 0.00%) 0.09s (± 4.62%) ~ 0.08s 0.09s p=0.405 n=6
Total Time 8.92s (± 0.46%) 8.93s (± 0.36%) ~ 8.90s 8.98s p=1.000 n=6
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-148-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 54208 6
Baseline main 6

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top-repos suite comparing main and refs/pull/54208/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, the results of running the DT tests are ready.
Everything looks the same!
You can check the log here.

@sandersn sandersn moved this from Not started to Needs merge in PR Backlog May 20, 2023
@ahejlsberg ahejlsberg merged commit 6f7704e into main May 20, 2023
20 checks passed
PR Backlog automation moved this from Needs merge to Done May 20, 2023
@ahejlsberg ahejlsberg deleted the fix54167 branch May 20, 2023 13:37
@DanielRosenwasser
Copy link
Member

@typescript-bot cherry-pick this to release-5.1

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 26, 2023

Heya @DanielRosenwasser, I've started to run the task to cherry-pick this into release-5.1 on this PR at e67193d. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @DanielRosenwasser, I've opened #54413 for you.

typescript-bot pushed a commit to typescript-bot/TypeScript that referenced this pull request May 26, 2023
Component commits:
d3529bd Properly handle 'typeof this.xxx' in isTypeParameterPossiblyReferenced

fda0a8f Add regression test

e67193d Merge branch 'main' into fix54167
DanielRosenwasser pushed a commit that referenced this pull request May 29, 2023
…e-5.1 (#54413)

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Milestone Bug PRs that fix a bug with a specific milestone
Projects
PR Backlog
  
Done
Development

Successfully merging this pull request may close these issues.

typeof this => this throw "Cannot find name 'this'.(2304)" for no reason
4 participants