From 60e49580e4a05964b6160cec26a3a818e0523dcd Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Wed, 15 Dec 2021 19:48:06 -0800 Subject: [PATCH] Added name to dummy type created for protocol variance testing. --- .../pyright-internal/src/analyzer/checker.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/pyright-internal/src/analyzer/checker.ts b/packages/pyright-internal/src/analyzer/checker.ts index 494348f2f..4bd288145 100644 --- a/packages/pyright-internal/src/analyzer/checker.ts +++ b/packages/pyright-internal/src/analyzer/checker.ts @@ -3303,19 +3303,28 @@ export class Checker extends ParseTreeWalker { const updatedClassType = ClassType.cloneWithNewTypeParameters(classType, updatedTypeParams); const objectObject = ClassType.cloneAsInstance(objectType); - const arbitraryTypeObject = ClassType.createInstantiable('', '', '', '', 0, 0, undefined, undefined); + const dummyTypeObject = ClassType.createInstantiable( + '__protocolVarianceDummy', + '', + '', + '', + 0, + 0, + undefined, + undefined + ); updatedTypeParams.forEach((param, paramIndex) => { - // Replace all type arguments with an arbitary type except for the + // Replace all type arguments with a dummy type except for the // TypeVar of interest, which is replaced with an object instance. const srcTypeArgs = updatedTypeParams.map((_, i) => { - return i === paramIndex ? objectObject : arbitraryTypeObject; + return i === paramIndex ? objectObject : dummyTypeObject; }); - // Replace all type arguments with an arbitary type except for the + // Replace all type arguments with a dummy type except for the // TypeVar of interest, which is replaced with itself. const destTypeArgs = updatedTypeParams.map((p, i) => { - return i === paramIndex ? p : arbitraryTypeObject; + return i === paramIndex ? p : dummyTypeObject; }); const srcType = ClassType.cloneForSpecialization(