mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 10:41:56 -05:00
Handle silentNeverType in iteration-related functions (#61317)
This commit is contained in:
committed by
GitHub
parent
5519be3ae1
commit
3267e426e3
@@ -2180,6 +2180,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
};
|
||||
|
||||
var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
|
||||
var silentNeverIterationTypes = createIterationTypes(silentNeverType, silentNeverType, silentNeverType);
|
||||
|
||||
var asyncIterationTypesResolver: IterationTypesResolver = {
|
||||
iterableCacheKey: "iterationTypesOfAsyncIterable",
|
||||
@@ -39164,6 +39165,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
}
|
||||
|
||||
function getYieldedTypeOfYieldExpression(node: YieldExpression, expressionType: Type, sentType: Type, isAsync: boolean): Type | undefined {
|
||||
if (expressionType === silentNeverType) {
|
||||
return silentNeverType;
|
||||
}
|
||||
const errorNode = node.expression || node;
|
||||
// A `yield*` expression effectively yields everything that its operand yields
|
||||
const yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? IterationUse.AsyncYieldStar : IterationUse.YieldStar, expressionType, sentType, errorNode) : expressionType;
|
||||
@@ -45663,6 +45667,9 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
|
||||
* the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method.
|
||||
*/
|
||||
function getIterationTypesOfIterable(type: Type, use: IterationUse, errorNode: Node | undefined) {
|
||||
if (type === silentNeverType) {
|
||||
return silentNeverIterationTypes;
|
||||
}
|
||||
if (isTypeAny(type)) {
|
||||
return anyIterationTypes;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
genericCallAtYieldExpressionInGenericCall1.ts(26,25): error TS2488: Type '() => T' must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
|
||||
|
||||
==== genericCallAtYieldExpressionInGenericCall1.ts (1 errors) ====
|
||||
declare const inner: {
|
||||
<A>(value: A): {
|
||||
(): A;
|
||||
[Symbol.iterator](): {
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, A>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
declare function outer<A>(body: (value: A) => Generator<any, any, any>): void;
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
const result = yield* inner(value); // ok
|
||||
});
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
const x = inner(value);
|
||||
const result = yield* x; // ok
|
||||
});
|
||||
|
||||
declare const inner2: {
|
||||
<A>(value: A): () => A;
|
||||
};
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
const result = yield* inner2(value); // error
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS2488: Type '() => T' must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
});
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
//// [tests/cases/compiler/genericCallAtYieldExpressionInGenericCall1.ts] ////
|
||||
|
||||
=== genericCallAtYieldExpressionInGenericCall1.ts ===
|
||||
declare const inner: {
|
||||
>inner : Symbol(inner, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 0, 13))
|
||||
|
||||
<A>(value: A): {
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 1, 3))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 1, 6))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 1, 3))
|
||||
|
||||
(): A;
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 1, 3))
|
||||
|
||||
[Symbol.iterator](): {
|
||||
>[Symbol.iterator] : Symbol([Symbol.iterator], Decl(genericCallAtYieldExpressionInGenericCall1.ts, 2, 10))
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, A>;
|
||||
>next : Symbol(next, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 3, 26))
|
||||
>args : Symbol(args, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 4, 11))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more)
|
||||
>IteratorResult : Symbol(IteratorResult, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 1, 3))
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
declare function outer<A>(body: (value: A) => Generator<any, any, any>): void;
|
||||
>outer : Symbol(outer, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 7, 2))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 9, 23))
|
||||
>body : Symbol(body, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 9, 26))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 9, 33))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 9, 23))
|
||||
>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --))
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
>outer : Symbol(outer, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 7, 2))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 11, 17))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 11, 20))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 11, 17))
|
||||
|
||||
const result = yield* inner(value); // ok
|
||||
>result : Symbol(result, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 12, 7))
|
||||
>inner : Symbol(inner, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 0, 13))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 11, 20))
|
||||
|
||||
});
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
>outer : Symbol(outer, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 7, 2))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 15, 17))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 15, 20))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 15, 17))
|
||||
|
||||
const x = inner(value);
|
||||
>x : Symbol(x, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 16, 7))
|
||||
>inner : Symbol(inner, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 0, 13))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 15, 20))
|
||||
|
||||
const result = yield* x; // ok
|
||||
>result : Symbol(result, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 17, 7))
|
||||
>x : Symbol(x, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 16, 7))
|
||||
|
||||
});
|
||||
|
||||
declare const inner2: {
|
||||
>inner2 : Symbol(inner2, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 20, 13))
|
||||
|
||||
<A>(value: A): () => A;
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 21, 3))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 21, 6))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 21, 3))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 21, 3))
|
||||
|
||||
};
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
>outer : Symbol(outer, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 7, 2))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 24, 17))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 24, 20))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 24, 17))
|
||||
|
||||
const result = yield* inner2(value); // error
|
||||
>result : Symbol(result, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 25, 7))
|
||||
>inner2 : Symbol(inner2, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 20, 13))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall1.ts, 24, 20))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
//// [tests/cases/compiler/genericCallAtYieldExpressionInGenericCall1.ts] ////
|
||||
|
||||
=== Performance Stats ===
|
||||
Type Count: 1,000
|
||||
Instantiation count: 2,500
|
||||
|
||||
=== genericCallAtYieldExpressionInGenericCall1.ts ===
|
||||
declare const inner: {
|
||||
>inner : <A>(value: A) => { (): A; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, A>; }; }
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
|
||||
<A>(value: A): {
|
||||
>value : A
|
||||
> : ^
|
||||
|
||||
(): A;
|
||||
[Symbol.iterator](): {
|
||||
>[Symbol.iterator] : () => { next(...args: ReadonlyArray<any>): IteratorResult<any, A>; }
|
||||
> : ^^^^^^
|
||||
>Symbol.iterator : unique symbol
|
||||
> : ^^^^^^^^^^^^^
|
||||
>Symbol : SymbolConstructor
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
>iterator : unique symbol
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, A>;
|
||||
>next : (...args: ReadonlyArray<any>) => IteratorResult<any, A>
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>args : readonly any[]
|
||||
> : ^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
declare function outer<A>(body: (value: A) => Generator<any, any, any>): void;
|
||||
>outer : <A>(body: (value: A) => Generator<any, any, any>) => void
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>body : (value: A) => Generator<any, any, any>
|
||||
> : ^ ^^ ^^^^^
|
||||
>value : A
|
||||
> : ^
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
>outer(function* <T>(value: T) { const result = yield* inner(value); // ok}) : void
|
||||
> : ^^^^
|
||||
>outer : <A>(body: (value: A) => Generator<any, any, any>) => void
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>function* <T>(value: T) { const result = yield* inner(value); // ok} : <T>(value: T) => Generator<never, void, never>
|
||||
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
const result = yield* inner(value); // ok
|
||||
>result : T
|
||||
> : ^
|
||||
>yield* inner(value) : T
|
||||
> : ^
|
||||
>inner(value) : { (): T; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, T>; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>inner : <A>(value: A) => { (): A; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, A>; }; }
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
});
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
>outer(function* <T>(value: T) { const x = inner(value); const result = yield* x; // ok}) : void
|
||||
> : ^^^^
|
||||
>outer : <A>(body: (value: A) => Generator<any, any, any>) => void
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>function* <T>(value: T) { const x = inner(value); const result = yield* x; // ok} : <T>(value: T) => Generator<any, void, any>
|
||||
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
const x = inner(value);
|
||||
>x : { (): T; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, T>; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>inner(value) : { (): T; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, T>; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>inner : <A>(value: A) => { (): A; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, A>; }; }
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
const result = yield* x; // ok
|
||||
>result : T
|
||||
> : ^
|
||||
>yield* x : T
|
||||
> : ^
|
||||
>x : { (): T; [Symbol.iterator](): { next(...args: ReadonlyArray<any>): IteratorResult<any, T>; }; }
|
||||
> : ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
});
|
||||
|
||||
declare const inner2: {
|
||||
>inner2 : <A>(value: A) => () => A
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
|
||||
<A>(value: A): () => A;
|
||||
>value : A
|
||||
> : ^
|
||||
|
||||
};
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
>outer(function* <T>(value: T) { const result = yield* inner2(value); // error}) : void
|
||||
> : ^^^^
|
||||
>outer : <A>(body: (value: A) => Generator<any, any, any>) => void
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>function* <T>(value: T) { const result = yield* inner2(value); // error} : <T>(value: T) => Generator<never, void, never>
|
||||
> : ^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
const result = yield* inner2(value); // error
|
||||
>result : any
|
||||
> : ^^^
|
||||
>yield* inner2(value) : any
|
||||
> : ^^^
|
||||
>inner2(value) : () => T
|
||||
> : ^^^^^^^
|
||||
>inner2 : <A>(value: A) => () => A
|
||||
> : ^ ^^ ^^ ^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
//// [tests/cases/compiler/genericCallAtYieldExpressionInGenericCall2.ts] ////
|
||||
|
||||
=== genericCallAtYieldExpressionInGenericCall2.ts ===
|
||||
interface Effect {
|
||||
>Effect : Symbol(Effect, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 0, 0))
|
||||
|
||||
[Symbol.iterator](): {
|
||||
>[Symbol.iterator] : Symbol(Effect[Symbol.iterator], Decl(genericCallAtYieldExpressionInGenericCall2.ts, 0, 18))
|
||||
>Symbol.iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
>Symbol : Symbol(Symbol, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2019.symbol.d.ts, --, --))
|
||||
>iterator : Symbol(SymbolConstructor.iterator, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, any>;
|
||||
>next : Symbol(next, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 1, 24))
|
||||
>args : Symbol(args, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 2, 9))
|
||||
>ReadonlyArray : Symbol(ReadonlyArray, Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2016.array.include.d.ts, --, --) ... and 3 more)
|
||||
>IteratorResult : Symbol(IteratorResult, Decl(lib.es2015.iterable.d.ts, --, --))
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
interface Enqueue<A> {
|
||||
>Enqueue : Symbol(Enqueue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 4, 1))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 6, 18))
|
||||
|
||||
offer: (value: A) => Effect;
|
||||
>offer : Symbol(Enqueue.offer, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 6, 22))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 7, 10))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 6, 18))
|
||||
>Effect : Symbol(Effect, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 0, 0))
|
||||
}
|
||||
|
||||
declare const offer: {
|
||||
>offer : Symbol(offer, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 10, 13))
|
||||
|
||||
<A>(value: A): (self: Enqueue<A>) => Effect;
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 11, 3))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 11, 6))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 11, 3))
|
||||
>self : Symbol(self, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 11, 18))
|
||||
>Enqueue : Symbol(Enqueue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 4, 1))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 11, 3))
|
||||
>Effect : Symbol(Effect, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 0, 0))
|
||||
|
||||
<A>(self: Enqueue<A>, value: A): Effect;
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 12, 3))
|
||||
>self : Symbol(self, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 12, 6))
|
||||
>Enqueue : Symbol(Enqueue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 4, 1))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 12, 3))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 12, 23))
|
||||
>A : Symbol(A, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 12, 3))
|
||||
>Effect : Symbol(Effect, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 0, 0))
|
||||
|
||||
};
|
||||
|
||||
declare function fn<Eff extends Effect, AEff, Args extends Array<any>>(
|
||||
>fn : Symbol(fn, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 13, 2))
|
||||
>Eff : Symbol(Eff, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 20))
|
||||
>Effect : Symbol(Effect, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 0, 0))
|
||||
>AEff : Symbol(AEff, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 39))
|
||||
>Args : Symbol(Args, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 45))
|
||||
>Array : Symbol(Array, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.iterable.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --) ... and 4 more)
|
||||
|
||||
body: (...args: Args) => Generator<Eff, AEff, any>,
|
||||
>body : Symbol(body, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 71))
|
||||
>args : Symbol(args, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 16, 9))
|
||||
>Args : Symbol(Args, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 45))
|
||||
>Generator : Symbol(Generator, Decl(lib.es2015.generator.d.ts, --, --))
|
||||
>Eff : Symbol(Eff, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 20))
|
||||
>AEff : Symbol(AEff, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 39))
|
||||
|
||||
): (...args: Args) => any;
|
||||
>args : Symbol(args, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 17, 4))
|
||||
>Args : Symbol(Args, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 15, 45))
|
||||
|
||||
fn(function* <T>(queue: Enqueue<T>, value: T) {
|
||||
>fn : Symbol(fn, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 13, 2))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 14))
|
||||
>queue : Symbol(queue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 17))
|
||||
>Enqueue : Symbol(Enqueue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 4, 1))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 14))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 35))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 14))
|
||||
|
||||
yield* offer(queue, value);
|
||||
>offer : Symbol(offer, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 10, 13))
|
||||
>queue : Symbol(queue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 17))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 19, 35))
|
||||
|
||||
});
|
||||
|
||||
fn(function* <T>(queue: Enqueue<T>, value: T) {
|
||||
>fn : Symbol(fn, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 13, 2))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 14))
|
||||
>queue : Symbol(queue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 17))
|
||||
>Enqueue : Symbol(Enqueue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 4, 1))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 14))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 35))
|
||||
>T : Symbol(T, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 14))
|
||||
|
||||
const x = offer(queue, value);
|
||||
>x : Symbol(x, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 24, 7))
|
||||
>offer : Symbol(offer, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 10, 13))
|
||||
>queue : Symbol(queue, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 17))
|
||||
>value : Symbol(value, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 23, 35))
|
||||
|
||||
yield* x;
|
||||
>x : Symbol(x, Decl(genericCallAtYieldExpressionInGenericCall2.ts, 24, 7))
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
//// [tests/cases/compiler/genericCallAtYieldExpressionInGenericCall2.ts] ////
|
||||
|
||||
=== Performance Stats ===
|
||||
Type Count: 1,000
|
||||
Instantiation count: 2,500
|
||||
|
||||
=== genericCallAtYieldExpressionInGenericCall2.ts ===
|
||||
interface Effect {
|
||||
[Symbol.iterator](): {
|
||||
>[Symbol.iterator] : () => { next(...args: ReadonlyArray<any>): IteratorResult<any, any>; }
|
||||
> : ^^^^^^
|
||||
>Symbol.iterator : unique symbol
|
||||
> : ^^^^^^^^^^^^^
|
||||
>Symbol : SymbolConstructor
|
||||
> : ^^^^^^^^^^^^^^^^^
|
||||
>iterator : unique symbol
|
||||
> : ^^^^^^^^^^^^^
|
||||
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, any>;
|
||||
>next : (...args: ReadonlyArray<any>) => IteratorResult<any, any>
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>args : readonly any[]
|
||||
> : ^^^^^^^^^^^^^^
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
interface Enqueue<A> {
|
||||
offer: (value: A) => Effect;
|
||||
>offer : (value: A) => Effect
|
||||
> : ^ ^^ ^^^^^
|
||||
>value : A
|
||||
> : ^
|
||||
}
|
||||
|
||||
declare const offer: {
|
||||
>offer : { <A>(value: A): (self: Enqueue<A>) => Effect; <A>(self: Enqueue<A>, value: A): Effect; }
|
||||
> : ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^ ^^ ^^^ ^^^
|
||||
|
||||
<A>(value: A): (self: Enqueue<A>) => Effect;
|
||||
>value : A
|
||||
> : ^
|
||||
>self : Enqueue<A>
|
||||
> : ^^^^^^^^^^
|
||||
|
||||
<A>(self: Enqueue<A>, value: A): Effect;
|
||||
>self : Enqueue<A>
|
||||
> : ^^^^^^^^^^
|
||||
>value : A
|
||||
> : ^
|
||||
|
||||
};
|
||||
|
||||
declare function fn<Eff extends Effect, AEff, Args extends Array<any>>(
|
||||
>fn : <Eff extends Effect, AEff, Args extends Array<any>>(body: (...args: Args) => Generator<Eff, AEff, any>) => (...args: Args) => any
|
||||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^
|
||||
|
||||
body: (...args: Args) => Generator<Eff, AEff, any>,
|
||||
>body : (...args: Args) => Generator<Eff, AEff, any>
|
||||
> : ^^^^ ^^ ^^^^^
|
||||
>args : Args
|
||||
> : ^^^^
|
||||
|
||||
): (...args: Args) => any;
|
||||
>args : Args
|
||||
> : ^^^^
|
||||
|
||||
fn(function* <T>(queue: Enqueue<T>, value: T) {
|
||||
>fn(function* <T>(queue: Enqueue<T>, value: T) { yield* offer(queue, value);}) : <T>(queue: Enqueue<T>, value: T) => any
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>fn : <Eff extends Effect, AEff, Args extends Array<any>>(body: (...args: Args) => Generator<Eff, AEff, any>) => (...args: Args) => any
|
||||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^
|
||||
>function* <T>(queue: Enqueue<T>, value: T) { yield* offer(queue, value);} : <T>(queue: Enqueue<T>, value: T) => Generator<never, void, never>
|
||||
> : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>queue : Enqueue<T>
|
||||
> : ^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
yield* offer(queue, value);
|
||||
>yield* offer(queue, value) : any
|
||||
>offer(queue, value) : Effect
|
||||
> : ^^^^^^
|
||||
>offer : { <A>(value: A): (self: Enqueue<A>) => Effect; <A>(self: Enqueue<A>, value: A): Effect; }
|
||||
> : ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^ ^^ ^^^ ^^^
|
||||
>queue : Enqueue<T>
|
||||
> : ^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
});
|
||||
|
||||
fn(function* <T>(queue: Enqueue<T>, value: T) {
|
||||
>fn(function* <T>(queue: Enqueue<T>, value: T) { const x = offer(queue, value); yield* x;}) : <T>(queue: Enqueue<T>, value: T) => any
|
||||
> : ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>fn : <Eff extends Effect, AEff, Args extends Array<any>>(body: (...args: Args) => Generator<Eff, AEff, any>) => (...args: Args) => any
|
||||
> : ^ ^^^^^^^^^ ^^ ^^ ^^^^^^^^^ ^^ ^^ ^^^^^
|
||||
>function* <T>(queue: Enqueue<T>, value: T) { const x = offer(queue, value); yield* x;} : <T>(queue: Enqueue<T>, value: T) => Generator<any, void, any>
|
||||
> : ^ ^^ ^^ ^^ ^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
>queue : Enqueue<T>
|
||||
> : ^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
const x = offer(queue, value);
|
||||
>x : Effect
|
||||
> : ^^^^^^
|
||||
>offer(queue, value) : Effect
|
||||
> : ^^^^^^
|
||||
>offer : { <A>(value: A): (self: Enqueue<A>) => Effect; <A>(self: Enqueue<A>, value: A): Effect; }
|
||||
> : ^^^ ^^ ^^ ^^^ ^^^ ^^ ^^ ^^ ^^ ^^^ ^^^
|
||||
>queue : Enqueue<T>
|
||||
> : ^^^^^^^^^^
|
||||
>value : T
|
||||
> : ^
|
||||
|
||||
yield* x;
|
||||
>yield* x : any
|
||||
>x : Effect
|
||||
> : ^^^^^^
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// @strict: true
|
||||
// @target: esnext
|
||||
// @lib: esnext
|
||||
// @noEmit: true
|
||||
|
||||
declare const inner: {
|
||||
<A>(value: A): {
|
||||
(): A;
|
||||
[Symbol.iterator](): {
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, A>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
declare function outer<A>(body: (value: A) => Generator<any, any, any>): void;
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
const result = yield* inner(value); // ok
|
||||
});
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
const x = inner(value);
|
||||
const result = yield* x; // ok
|
||||
});
|
||||
|
||||
declare const inner2: {
|
||||
<A>(value: A): () => A;
|
||||
};
|
||||
|
||||
outer(function* <T>(value: T) {
|
||||
const result = yield* inner2(value); // error
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
// @strict: true
|
||||
// @target: esnext
|
||||
// @lib: esnext
|
||||
// @noEmit: true
|
||||
|
||||
interface Effect {
|
||||
[Symbol.iterator](): {
|
||||
next(...args: ReadonlyArray<any>): IteratorResult<any, any>;
|
||||
};
|
||||
}
|
||||
|
||||
interface Enqueue<A> {
|
||||
offer: (value: A) => Effect;
|
||||
}
|
||||
|
||||
declare const offer: {
|
||||
<A>(value: A): (self: Enqueue<A>) => Effect;
|
||||
<A>(self: Enqueue<A>, value: A): Effect;
|
||||
};
|
||||
|
||||
declare function fn<Eff extends Effect, AEff, Args extends Array<any>>(
|
||||
body: (...args: Args) => Generator<Eff, AEff, any>,
|
||||
): (...args: Args) => any;
|
||||
|
||||
fn(function* <T>(queue: Enqueue<T>, value: T) {
|
||||
yield* offer(queue, value);
|
||||
});
|
||||
|
||||
fn(function* <T>(queue: Enqueue<T>, value: T) {
|
||||
const x = offer(queue, value);
|
||||
yield* x;
|
||||
});
|
||||
Reference in New Issue
Block a user