@zzzen/pyright-internal 1.2.0-dev.20231231 → 1.2.0-dev.20240107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analyzer/binder.js +12 -3
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.d.ts +2 -0
- package/dist/analyzer/checker.js +133 -28
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +4 -4
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +5 -1
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/namedTuples.js +13 -5
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/protocols.d.ts +2 -0
- package/dist/analyzer/protocols.js +72 -3
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/scopeUtils.d.ts +1 -0
- package/dist/analyzer/scopeUtils.js +12 -1
- package/dist/analyzer/scopeUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +175 -94
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -0
- package/dist/analyzer/typeEvaluatorTypes.js +2 -0
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +8 -4
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typePrinter.js +4 -2
- package/dist/analyzer/typePrinter.js.map +1 -1
- package/dist/analyzer/typeUtils.js +6 -1
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -1
- package/dist/analyzer/types.js +3 -3
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.js +4 -3
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +1 -0
- package/dist/backgroundThreadBase.js +8 -1
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/realFileSystem.js +44 -12
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/localization/localize.d.ts +27 -0
- package/dist/localization/localize.js +12 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +13 -1
- package/dist/tests/localizer.test.js +1 -1
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator2.test.js +15 -3
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +3 -3
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +6 -2
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/uri.test.js +7 -0
- package/dist/tests/uri.test.js.map +1 -1
- package/package.json +1 -1
package/dist/analyzer/checker.js
CHANGED
@@ -60,6 +60,7 @@ const parameterUtils_1 = require("./parameterUtils");
|
|
60
60
|
const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
|
61
61
|
const parseTreeWalker_1 = require("./parseTreeWalker");
|
62
62
|
const patternMatching_1 = require("./patternMatching");
|
63
|
+
const protocols_1 = require("./protocols");
|
63
64
|
const regions_1 = require("./regions");
|
64
65
|
const scopeUtils_1 = require("./scopeUtils");
|
65
66
|
const sourceFile_1 = require("./sourceFile");
|
@@ -162,8 +163,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
162
163
|
!types_1.ClassType.isBuiltIn(baseClassType, 'Generic')) {
|
163
164
|
if (!types_1.ClassType.isProtocolClass(baseClassType)) {
|
164
165
|
this._evaluator.addError(localize_1.Localizer.Diagnostic.protocolBaseClass().format({
|
165
|
-
classType:
|
166
|
-
baseType:
|
166
|
+
classType: classTypeResult.classType.details.name,
|
167
|
+
baseType: baseClassType.details.name,
|
167
168
|
}), arg.valueExpression);
|
168
169
|
}
|
169
170
|
}
|
@@ -179,6 +180,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
179
180
|
this._validateSlotsClassVarConflict(classTypeResult.classType);
|
180
181
|
}
|
181
182
|
this._validateBaseClassOverrides(classTypeResult.classType);
|
183
|
+
this._validateOverloadDecoratorConsistency(classTypeResult.classType);
|
182
184
|
this._validateMultipleInheritanceBaseClasses(classTypeResult.classType, node.name);
|
183
185
|
this._validateMultipleInheritanceCompatibility(classTypeResult.classType, node.name);
|
184
186
|
this._validateConstructorConsistency(classTypeResult.classType, node.name);
|
@@ -2546,6 +2548,23 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2546
2548
|
type: this._evaluator.printType(arg1Type),
|
2547
2549
|
}) + diag.getString(), node.arguments[1]);
|
2548
2550
|
}
|
2551
|
+
// If this call is an issubclass, check for the use of a "data protocol",
|
2552
|
+
// which PEP 544 says cannot be used in issubclass.
|
2553
|
+
if (!isInstanceCheck) {
|
2554
|
+
const diag = new diagnostic_1.DiagnosticAddendum();
|
2555
|
+
(0, typeUtils_1.doForEachSubtype)(arg1Type, (arg1Subtype) => {
|
2556
|
+
if ((0, types_1.isInstantiableClass)(arg1Subtype) &&
|
2557
|
+
types_1.ClassType.isProtocolClass(arg1Subtype) &&
|
2558
|
+
!(0, protocols_1.isMethodOnlyProtocol)(arg1Subtype)) {
|
2559
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.dataProtocolUnsupported().format({
|
2560
|
+
name: arg1Subtype.details.name,
|
2561
|
+
}));
|
2562
|
+
}
|
2563
|
+
});
|
2564
|
+
if (!diag.isEmpty()) {
|
2565
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.dataProtocolInSubclassCheck(), node.arguments[1]);
|
2566
|
+
}
|
2567
|
+
}
|
2549
2568
|
// If this call is within an assert statement, we won't check whether
|
2550
2569
|
// it's unnecessary.
|
2551
2570
|
let curNode = node;
|
@@ -2581,6 +2600,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2581
2600
|
arg1IncludesSubclasses = true;
|
2582
2601
|
}
|
2583
2602
|
}
|
2603
|
+
if (arg0Type) {
|
2604
|
+
this._validateUnsafeProtocolOverlap(node.arguments[0].valueExpression, (0, typeUtils_1.convertToInstance)(arg1Subtype), isInstanceCheck ? arg0Type : (0, typeUtils_1.convertToInstance)(arg0Type));
|
2605
|
+
}
|
2584
2606
|
}
|
2585
2607
|
else {
|
2586
2608
|
// The isinstance and issubclass call supports a variation where the second
|
@@ -2593,6 +2615,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2593
2615
|
if (typeArg.type.includeSubclasses) {
|
2594
2616
|
arg1IncludesSubclasses = true;
|
2595
2617
|
}
|
2618
|
+
if (arg0Type) {
|
2619
|
+
this._validateUnsafeProtocolOverlap(node.arguments[0].valueExpression, (0, typeUtils_1.convertToInstance)(typeArg.type), isInstanceCheck ? arg0Type : (0, typeUtils_1.convertToInstance)(arg0Type));
|
2620
|
+
}
|
2596
2621
|
}
|
2597
2622
|
else {
|
2598
2623
|
isValidType = false;
|
@@ -2706,6 +2731,29 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2706
2731
|
}), node);
|
2707
2732
|
}
|
2708
2733
|
}
|
2734
|
+
_validateUnsafeProtocolOverlap(errorNode, protocol, testType) {
|
2735
|
+
// If this is a protocol class, check for an "unsafe overlap"
|
2736
|
+
// with the arg0 type.
|
2737
|
+
if (types_1.ClassType.isProtocolClass(protocol)) {
|
2738
|
+
let isUnsafeOverlap = false;
|
2739
|
+
const diag = new diagnostic_1.DiagnosticAddendum();
|
2740
|
+
(0, typeUtils_1.doForEachSubtype)(testType, (testSubtype) => {
|
2741
|
+
if ((0, types_1.isClassInstance)(testSubtype)) {
|
2742
|
+
if ((0, protocols_1.isProtocolUnsafeOverlap)(this._evaluator, protocol, testSubtype)) {
|
2743
|
+
isUnsafeOverlap = true;
|
2744
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolUnsafeOverlap().format({
|
2745
|
+
name: testSubtype.details.name,
|
2746
|
+
}));
|
2747
|
+
}
|
2748
|
+
}
|
2749
|
+
});
|
2750
|
+
if (isUnsafeOverlap) {
|
2751
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.protocolUnsafeOverlap().format({
|
2752
|
+
name: protocol.details.name,
|
2753
|
+
}) + diag.getString(), errorNode);
|
2754
|
+
}
|
2755
|
+
}
|
2756
|
+
}
|
2709
2757
|
// Determines whether the specified type is allowed as the second argument
|
2710
2758
|
// to an isinstance or issubclass check.
|
2711
2759
|
_isTypeSupportedTypeForIsInstance(type, isInstanceCheck, diag) {
|
@@ -4094,6 +4142,51 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4094
4142
|
}), overrideDecl.uri, overrideDecl.range);
|
4095
4143
|
}
|
4096
4144
|
}
|
4145
|
+
// Validates that any overloaded methods are consistent in how they
|
4146
|
+
// are decorated. For example, if the first overload is not marked @final
|
4147
|
+
// but subsequent ones are, an error should be reported.
|
4148
|
+
_validateOverloadDecoratorConsistency(classType) {
|
4149
|
+
classType.details.fields.forEach((symbol, name) => {
|
4150
|
+
const primaryDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
4151
|
+
if (!primaryDecl || primaryDecl.type !== 5 /* DeclarationType.Function */) {
|
4152
|
+
return;
|
4153
|
+
}
|
4154
|
+
const typeOfSymbol = this._evaluator.getEffectiveTypeOfSymbol(symbol);
|
4155
|
+
if (!(0, types_1.isOverloadedFunction)(typeOfSymbol)) {
|
4156
|
+
return;
|
4157
|
+
}
|
4158
|
+
const overloads = types_1.OverloadedFunctionType.getOverloads(typeOfSymbol);
|
4159
|
+
// If there's an implementation, it will determine whether the
|
4160
|
+
// function is @final.
|
4161
|
+
const implementation = types_1.OverloadedFunctionType.getImplementation(typeOfSymbol);
|
4162
|
+
if (implementation) {
|
4163
|
+
// If one or more of the overloads is marked @final but the
|
4164
|
+
// implementation is not, report an error.
|
4165
|
+
if (!types_1.FunctionType.isFinal(implementation)) {
|
4166
|
+
overloads.forEach((overload) => {
|
4167
|
+
var _a, _b;
|
4168
|
+
if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
|
4169
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadFinalInconsistencyImpl().format({
|
4170
|
+
name: overload.details.name,
|
4171
|
+
}), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
|
4172
|
+
}
|
4173
|
+
});
|
4174
|
+
}
|
4175
|
+
return;
|
4176
|
+
}
|
4177
|
+
if (!types_1.FunctionType.isFinal(overloads[0])) {
|
4178
|
+
overloads.slice(1).forEach((overload, index) => {
|
4179
|
+
var _a, _b;
|
4180
|
+
if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
|
4181
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadFinalInconsistencyNoImpl().format({
|
4182
|
+
name: overload.details.name,
|
4183
|
+
index: index + 2,
|
4184
|
+
}), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
|
4185
|
+
}
|
4186
|
+
});
|
4187
|
+
}
|
4188
|
+
});
|
4189
|
+
}
|
4097
4190
|
// Validates that any overridden methods or variables contain the same
|
4098
4191
|
// types as the original method. Also marks the class as abstract if one
|
4099
4192
|
// or more abstract methods are not overridden.
|
@@ -4213,7 +4306,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4213
4306
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overriddenMethodNotFound().format({ name: funcNode.name.value }), funcNode.name);
|
4214
4307
|
}
|
4215
4308
|
_validateBaseClassOverride(baseClassAndSymbol, overrideSymbol, overrideType, childClassType, memberName) {
|
4216
|
-
var _a, _b;
|
4309
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
4217
4310
|
if (!(0, types_1.isInstantiableClass)(baseClassAndSymbol.classType)) {
|
4218
4311
|
return;
|
4219
4312
|
}
|
@@ -4237,6 +4330,31 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4237
4330
|
overrideType = (0, typeUtils_1.partiallySpecializeType)(overrideType, childClassType, childClassSelf);
|
4238
4331
|
if ((0, types_1.isFunction)(baseType) || (0, types_1.isOverloadedFunction)(baseType)) {
|
4239
4332
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4333
|
+
// Determine whether this is an attempt to override a method marked @final.
|
4334
|
+
let reportFinalMethodOverride = false;
|
4335
|
+
// Private names (starting with double underscore) are exempt from this check.
|
4336
|
+
if (!SymbolNameUtils.isPrivateName(memberName)) {
|
4337
|
+
if ((0, types_1.isFunction)(baseType) && types_1.FunctionType.isFinal(baseType)) {
|
4338
|
+
reportFinalMethodOverride = true;
|
4339
|
+
}
|
4340
|
+
else if ((0, types_1.isOverloadedFunction)(baseType) &&
|
4341
|
+
baseType.overloads.some((overload) => types_1.FunctionType.isFinal(overload))) {
|
4342
|
+
reportFinalMethodOverride = true;
|
4343
|
+
}
|
4344
|
+
}
|
4345
|
+
if (reportFinalMethodOverride) {
|
4346
|
+
const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
|
4347
|
+
if (decl && decl.type === 5 /* DeclarationType.Function */) {
|
4348
|
+
const diag = this._evaluator.addError(localize_1.Localizer.Diagnostic.finalMethodOverride().format({
|
4349
|
+
name: memberName,
|
4350
|
+
className: baseClass.details.name,
|
4351
|
+
}), decl.node.name);
|
4352
|
+
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
4353
|
+
if (diag && origDecl) {
|
4354
|
+
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.finalMethod(), origDecl.uri, origDecl.range);
|
4355
|
+
}
|
4356
|
+
}
|
4357
|
+
}
|
4240
4358
|
if ((0, types_1.isFunction)(overrideType) || (0, types_1.isOverloadedFunction)(overrideType)) {
|
4241
4359
|
// Don't enforce parameter names for dundered methods. Many of them
|
4242
4360
|
// are misnamed in typeshed stubs, so this would result in many
|
@@ -4257,7 +4375,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4257
4375
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.incompatibleMethodOverride().format({
|
4258
4376
|
name: memberName,
|
4259
4377
|
className: baseClass.details.name,
|
4260
|
-
}) + diagAddendum.getString(), decl
|
4378
|
+
}) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(decl)) !== null && _a !== void 0 ? _a : decl.node);
|
4261
4379
|
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
4262
4380
|
if (diag && origDecl) {
|
4263
4381
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
@@ -4265,22 +4383,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4265
4383
|
}
|
4266
4384
|
}
|
4267
4385
|
}
|
4268
|
-
if ((0, types_1.isFunction)(baseType)) {
|
4269
|
-
// Private names (starting with double underscore) are exempt from this check.
|
4270
|
-
if (!SymbolNameUtils.isPrivateName(memberName) && types_1.FunctionType.isFinal(baseType)) {
|
4271
|
-
const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
|
4272
|
-
if (decl && decl.type === 5 /* DeclarationType.Function */) {
|
4273
|
-
const diag = this._evaluator.addError(localize_1.Localizer.Diagnostic.finalMethodOverride().format({
|
4274
|
-
name: memberName,
|
4275
|
-
className: baseClass.details.name,
|
4276
|
-
}), decl.node.name);
|
4277
|
-
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
4278
|
-
if (diag && origDecl) {
|
4279
|
-
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.finalMethod(), origDecl.uri, origDecl.range);
|
4280
|
-
}
|
4281
|
-
}
|
4282
|
-
}
|
4283
|
-
}
|
4284
4386
|
}
|
4285
4387
|
else if (!(0, types_1.isAnyOrUnknown)(overrideType)) {
|
4286
4388
|
// Special-case overrides of methods in '_TypedDict', since
|
@@ -4294,7 +4396,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4294
4396
|
name: memberName,
|
4295
4397
|
className: baseClass.details.name,
|
4296
4398
|
type: this._evaluator.printType(overrideType),
|
4297
|
-
}), lastDecl.node);
|
4399
|
+
}), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _b !== void 0 ? _b : lastDecl.node);
|
4298
4400
|
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
4299
4401
|
if (diag && origDecl) {
|
4300
4402
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
@@ -4308,10 +4410,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4308
4410
|
if (!(0, typeUtils_1.isProperty)(overrideType)) {
|
4309
4411
|
const decls = overrideSymbol.getDeclarations();
|
4310
4412
|
if (decls.length > 0) {
|
4413
|
+
const lastDecl = decls[decls.length - 1];
|
4311
4414
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.propertyOverridden().format({
|
4312
4415
|
name: memberName,
|
4313
4416
|
className: baseClass.details.name,
|
4314
|
-
}),
|
4417
|
+
}), (_c = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _c !== void 0 ? _c : lastDecl.node);
|
4315
4418
|
}
|
4316
4419
|
}
|
4317
4420
|
else {
|
@@ -4322,6 +4425,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4322
4425
|
['fdel', (c) => { var _a; return (_a = c.fdelInfo) === null || _a === void 0 ? void 0 : _a.methodType; }],
|
4323
4426
|
];
|
4324
4427
|
propMethodInfo.forEach((info) => {
|
4428
|
+
var _a;
|
4325
4429
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
4326
4430
|
const [methodName, methodAccessor] = info;
|
4327
4431
|
const baseClassPropMethod = methodAccessor(baseType);
|
@@ -4337,10 +4441,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4337
4441
|
}));
|
4338
4442
|
const decls = overrideSymbol.getDeclarations();
|
4339
4443
|
if (decls.length > 0) {
|
4444
|
+
const lastDecl = decls[decls.length - 1];
|
4340
4445
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.propertyOverridden().format({
|
4341
4446
|
name: memberName,
|
4342
4447
|
className: baseClassType.details.name,
|
4343
|
-
}) + diagAddendum.getString(),
|
4448
|
+
}) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _a !== void 0 ? _a : lastDecl.node);
|
4344
4449
|
const origDecl = baseClassMethodType.details.declaration;
|
4345
4450
|
if (diag && origDecl) {
|
4346
4451
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
|
@@ -4418,7 +4523,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4418
4523
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.symbolOverridden().format({
|
4419
4524
|
name: memberName,
|
4420
4525
|
className: baseClass.details.name,
|
4421
|
-
}) + diagAddendum.getString(), (
|
4526
|
+
}) + diagAddendum.getString(), (_d = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _d !== void 0 ? _d : lastDecl.node);
|
4422
4527
|
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
4423
4528
|
if (diag && origDecl) {
|
4424
4529
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
|
@@ -4439,14 +4544,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4439
4544
|
const message = overrideTDEntry.isRequired
|
4440
4545
|
? localize_1.Localizer.Diagnostic.typedDictFieldRequiredRedefinition
|
4441
4546
|
: localize_1.Localizer.Diagnostic.typedDictFieldNotRequiredRedefinition;
|
4442
|
-
this._evaluator.addDiagnostic(AnalyzerNodeInfo.getFileInfo(lastDecl.node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message().format({ name: memberName }), lastDecl.node);
|
4547
|
+
this._evaluator.addDiagnostic(AnalyzerNodeInfo.getFileInfo(lastDecl.node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message().format({ name: memberName }), (_e = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _e !== void 0 ? _e : lastDecl.node);
|
4443
4548
|
}
|
4444
4549
|
// Make sure that the derived class isn't marking a previously writable
|
4445
4550
|
// entry as read-only.
|
4446
4551
|
if (!overriddenTDEntry.isReadOnly && overrideTDEntry.isReadOnly) {
|
4447
4552
|
this._evaluator.addDiagnostic(AnalyzerNodeInfo.getFileInfo(lastDecl.node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typedDictFieldReadOnlyRedefinition().format({
|
4448
4553
|
name: memberName,
|
4449
|
-
}), lastDecl.node);
|
4554
|
+
}), (_f = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _f !== void 0 ? _f : lastDecl.node);
|
4450
4555
|
}
|
4451
4556
|
}
|
4452
4557
|
// Verify that there is not a Final mismatch.
|
@@ -4456,7 +4561,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4456
4561
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.variableFinalOverride().format({
|
4457
4562
|
name: memberName,
|
4458
4563
|
className: baseClass.details.name,
|
4459
|
-
}), lastDecl.node);
|
4564
|
+
}), (_g = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _g !== void 0 ? _g : lastDecl.node);
|
4460
4565
|
if (diag) {
|
4461
4566
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), overrideFinalVarDecl.uri, overrideFinalVarDecl.range);
|
4462
4567
|
}
|
@@ -4485,7 +4590,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
4485
4590
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, unformattedMessage.format({
|
4486
4591
|
name: memberName,
|
4487
4592
|
className: baseClass.details.name,
|
4488
|
-
}), (
|
4593
|
+
}), (_h = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _h !== void 0 ? _h : lastDecl.node);
|
4489
4594
|
const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
|
4490
4595
|
if (diag && origDecl) {
|
4491
4596
|
diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
|