forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore awaited self tail calls when collecting the return type of an …
…async function (microsoft#56020)
- Loading branch information
Showing
13 changed files
with
499 additions
and
81 deletions.
There are no files selected for viewing
This file contains 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
25 changes: 25 additions & 0 deletions
25
tests/baselines/reference/parenthesizedJSDocCastAtReturnStatement.symbols
This file contains 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,25 @@ | ||
//// [tests/cases/compiler/parenthesizedJSDocCastAtReturnStatement.ts] //// | ||
|
||
=== index.js === | ||
/** @type {Map<string, string | Set<string>>} */ | ||
const cache = new Map() | ||
>cache : Symbol(cache, Decl(index.js, 1, 5)) | ||
>Map : Symbol(Map, Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.collection.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
|
||
/** | ||
* @param {string} key | ||
* @returns {() => string} | ||
*/ | ||
const getStringGetter = (key) => { | ||
>getStringGetter : Symbol(getStringGetter, Decl(index.js, 7, 5)) | ||
>key : Symbol(key, Decl(index.js, 7, 25)) | ||
|
||
return () => { | ||
return /** @type {string} */ (cache.get(key)) | ||
>cache.get : Symbol(Map.get, Decl(lib.es2015.collection.d.ts, --, --)) | ||
>cache : Symbol(cache, Decl(index.js, 1, 5)) | ||
>get : Symbol(Map.get, Decl(lib.es2015.collection.d.ts, --, --)) | ||
>key : Symbol(key, Decl(index.js, 7, 25)) | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
tests/baselines/reference/parenthesizedJSDocCastAtReturnStatement.types
This file contains 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,31 @@ | ||
//// [tests/cases/compiler/parenthesizedJSDocCastAtReturnStatement.ts] //// | ||
|
||
=== index.js === | ||
/** @type {Map<string, string | Set<string>>} */ | ||
const cache = new Map() | ||
>cache : Map<string, string | Set<string>> | ||
>new Map() : Map<any, any> | ||
>Map : MapConstructor | ||
|
||
/** | ||
* @param {string} key | ||
* @returns {() => string} | ||
*/ | ||
const getStringGetter = (key) => { | ||
>getStringGetter : (key: string) => () => string | ||
>(key) => { return () => { return /** @type {string} */ (cache.get(key)) }} : (key: string) => () => string | ||
>key : string | ||
|
||
return () => { | ||
>() => { return /** @type {string} */ (cache.get(key)) } : () => string | ||
|
||
return /** @type {string} */ (cache.get(key)) | ||
>(cache.get(key)) : string | ||
>cache.get(key) : string | Set<string> | undefined | ||
>cache.get : (key: string) => string | Set<string> | undefined | ||
>cache : Map<string, string | Set<string>> | ||
>get : (key: string) => string | Set<string> | undefined | ||
>key : string | ||
} | ||
} | ||
|
67 changes: 0 additions & 67 deletions
67
tests/baselines/reference/simpleRecursionWithBaseCase.symbols
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
67 changes: 67 additions & 0 deletions
67
tests/baselines/reference/simpleRecursionWithBaseCase1.symbols
This file contains 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,67 @@ | ||
//// [tests/cases/compiler/simpleRecursionWithBaseCase1.ts] //// | ||
|
||
=== simpleRecursionWithBaseCase1.ts === | ||
function fn1(n: number) { | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase1.ts, 0, 0)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 0, 13)) | ||
|
||
if (n === 0) { | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 0, 13)) | ||
|
||
return 3; | ||
} else { | ||
return fn1(n - 1); | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase1.ts, 0, 0)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 0, 13)) | ||
} | ||
} | ||
const num: number = fn1(); | ||
>num : Symbol(num, Decl(simpleRecursionWithBaseCase1.ts, 7, 5)) | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase1.ts, 0, 0)) | ||
|
||
function fn2(n: number) { | ||
>fn2 : Symbol(fn2, Decl(simpleRecursionWithBaseCase1.ts, 7, 26)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 9, 13)) | ||
|
||
return fn2(n); | ||
>fn2 : Symbol(fn2, Decl(simpleRecursionWithBaseCase1.ts, 7, 26)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 9, 13)) | ||
} | ||
const nev: never = fn2(); | ||
>nev : Symbol(nev, Decl(simpleRecursionWithBaseCase1.ts, 12, 5)) | ||
>fn2 : Symbol(fn2, Decl(simpleRecursionWithBaseCase1.ts, 7, 26)) | ||
|
||
function fn3(n: number) { | ||
>fn3 : Symbol(fn3, Decl(simpleRecursionWithBaseCase1.ts, 12, 25)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 14, 13)) | ||
|
||
if (n === 0) { | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 14, 13)) | ||
|
||
return 3; | ||
} else { | ||
return fn1("hello world"); | ||
>fn1 : Symbol(fn1, Decl(simpleRecursionWithBaseCase1.ts, 0, 0)) | ||
} | ||
} | ||
|
||
function fn4(n: number) { | ||
>fn4 : Symbol(fn4, Decl(simpleRecursionWithBaseCase1.ts, 20, 1)) | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 22, 13)) | ||
|
||
if (n === 0) { | ||
>n : Symbol(n, Decl(simpleRecursionWithBaseCase1.ts, 22, 13)) | ||
|
||
return 3; | ||
} else { | ||
return notfoundsymbol("hello world"); | ||
} | ||
} | ||
|
||
function fn5() { | ||
>fn5 : Symbol(fn5, Decl(simpleRecursionWithBaseCase1.ts, 28, 1)) | ||
|
||
return [fn5][0](); | ||
>fn5 : Symbol(fn5, Decl(simpleRecursionWithBaseCase1.ts, 28, 1)) | ||
} | ||
|
4 changes: 2 additions & 2 deletions
4
...ference/simpleRecursionWithBaseCase.types → ...erence/simpleRecursionWithBaseCase1.types
This file contains 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
119 changes: 119 additions & 0 deletions
119
tests/baselines/reference/simpleRecursionWithBaseCase2.symbols
This file contains 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,119 @@ | ||
//// [tests/cases/compiler/simpleRecursionWithBaseCase2.ts] //// | ||
|
||
=== simpleRecursionWithBaseCase2.ts === | ||
async function rec1() { | ||
>rec1 : Symbol(rec1, Decl(simpleRecursionWithBaseCase2.ts, 0, 0)) | ||
|
||
if (Math.random() < 0.5) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
return rec1(); | ||
>rec1 : Symbol(rec1, Decl(simpleRecursionWithBaseCase2.ts, 0, 0)) | ||
|
||
} else { | ||
return "hello"; | ||
} | ||
} | ||
|
||
async function rec2() { | ||
>rec2 : Symbol(rec2, Decl(simpleRecursionWithBaseCase2.ts, 6, 1)) | ||
|
||
if (Math.random() < 0.5) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
return await rec2(); | ||
>rec2 : Symbol(rec2, Decl(simpleRecursionWithBaseCase2.ts, 6, 1)) | ||
|
||
} else { | ||
return "hello"; | ||
} | ||
} | ||
|
||
async function rec3() { | ||
>rec3 : Symbol(rec3, Decl(simpleRecursionWithBaseCase2.ts, 14, 1)) | ||
|
||
return rec3(); | ||
>rec3 : Symbol(rec3, Decl(simpleRecursionWithBaseCase2.ts, 14, 1)) | ||
} | ||
|
||
async function rec4() { | ||
>rec4 : Symbol(rec4, Decl(simpleRecursionWithBaseCase2.ts, 18, 1)) | ||
|
||
return await rec4(); | ||
>rec4 : Symbol(rec4, Decl(simpleRecursionWithBaseCase2.ts, 18, 1)) | ||
} | ||
|
||
async function rec5() { | ||
>rec5 : Symbol(rec5, Decl(simpleRecursionWithBaseCase2.ts, 22, 1)) | ||
|
||
if (Math.random() < 0.5) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
return ((rec1())); | ||
>rec1 : Symbol(rec1, Decl(simpleRecursionWithBaseCase2.ts, 0, 0)) | ||
|
||
} else { | ||
return "hello"; | ||
} | ||
} | ||
|
||
async function rec6() { | ||
>rec6 : Symbol(rec6, Decl(simpleRecursionWithBaseCase2.ts, 30, 1)) | ||
|
||
if (Math.random() < 0.5) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
return await ((rec1())); | ||
>rec1 : Symbol(rec1, Decl(simpleRecursionWithBaseCase2.ts, 0, 0)) | ||
|
||
} else { | ||
return "hello"; | ||
} | ||
} | ||
|
||
declare const ps: Promise<string> | number; | ||
>ps : Symbol(ps, Decl(simpleRecursionWithBaseCase2.ts, 40, 13)) | ||
>Promise : Symbol(Promise, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.promise.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.promise.d.ts, --, --)) | ||
|
||
async function foo1() { | ||
>foo1 : Symbol(foo1, Decl(simpleRecursionWithBaseCase2.ts, 40, 43)) | ||
|
||
if (Math.random() > 0.5) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
return ps; | ||
>ps : Symbol(ps, Decl(simpleRecursionWithBaseCase2.ts, 40, 13)) | ||
|
||
} else { | ||
return await foo1(); | ||
>foo1 : Symbol(foo1, Decl(simpleRecursionWithBaseCase2.ts, 40, 43)) | ||
} | ||
} | ||
|
||
async function foo2() { | ||
>foo2 : Symbol(foo2, Decl(simpleRecursionWithBaseCase2.ts, 48, 1)) | ||
|
||
if (Math.random() > 0.5) { | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
return ps; | ||
>ps : Symbol(ps, Decl(simpleRecursionWithBaseCase2.ts, 40, 13)) | ||
|
||
} else { | ||
return foo2(); | ||
>foo2 : Symbol(foo2, Decl(simpleRecursionWithBaseCase2.ts, 48, 1)) | ||
} | ||
} | ||
|
Oops, something went wrong.