Fixed "NoReturn" inference logic for async functions. This logic was previously flagging the code after a call to such a function as unreachable.

This commit is contained in:
Eric Traut 2020-09-04 18:50:49 -07:00
parent 09d6ea7ee0
commit 1eba08bbe5

View File

@ -9729,6 +9729,11 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
// Wrap in a Coroutine, which is a subclass of Awaitable.
const coroutineType = getTypingType(node, 'Coroutine');
if (coroutineType && isClass(coroutineType)) {
// Don't wrap a NoReturn in a Coroutine. Treat it as an Any.
if (isNoReturnType(returnType)) {
returnType = AnyType.create();
}
awaitableReturnType = ObjectType.create(
ClassType.cloneForSpecialization(
coroutineType,
@ -10641,7 +10646,7 @@ export function createTypeEvaluator(importLookup: ImportLookup, printTypeFlags:
functionType = overloadedFunction.overloads[overloadedFunction.overloads.length - 1];
}
if (functionType) {
if (functionType && !FunctionType.isAsync(functionType)) {
if (functionType.details.declaredReturnType) {
callIsNoReturn = isNoReturnType(functionType.details.declaredReturnType);
} else if (functionType.inferredReturnType) {