@zzzen/pyright-internal 1.2.0-dev.20230219 → 1.2.0-dev.20230305
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/backgroundAnalysisProgram.d.ts +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.js +3 -3
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.d.ts +0 -1
- package/dist/analyzer/binder.js +18 -93
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +50 -30
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +5 -5
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +0 -10
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/declaration.d.ts +3 -4
- package/dist/analyzer/declaration.js +6 -1
- package/dist/analyzer/declaration.js.map +1 -1
- package/dist/analyzer/declarationUtils.d.ts +1 -5
- package/dist/analyzer/declarationUtils.js +2 -47
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +9 -3
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +3 -2
- package/dist/analyzer/importResolver.js +28 -19
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.d.ts +4 -2
- package/dist/analyzer/parseTreeUtils.js +77 -2
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.d.ts +1 -0
- package/dist/analyzer/patternMatching.js +47 -2
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/program.d.ts +5 -4
- package/dist/analyzer/program.js +182 -43
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/properties.js +8 -3
- package/dist/analyzer/properties.js.map +1 -1
- package/dist/analyzer/protocols.js +8 -5
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +27 -13
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +7 -3
- package/dist/analyzer/service.js +24 -7
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.js +3 -0
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/symbol.js +1 -4
- package/dist/analyzer/symbol.js.map +1 -1
- package/dist/analyzer/symbolUtils.d.ts +0 -3
- package/dist/analyzer/symbolUtils.js +1 -14
- package/dist/analyzer/symbolUtils.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.js +5 -3
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +586 -294
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +10 -2
- package/dist/analyzer/typeGuards.js +2 -2
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +1 -0
- package/dist/analyzer/typeUtils.js +14 -1
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +26 -17
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.d.ts +2 -1
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +2 -3
- package/dist/backgroundAnalysisBase.js +12 -13
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/commands/commandController.js +1 -0
- package/dist/commands/commandController.js.map +1 -1
- package/dist/commands/quickActionCommand.js +2 -2
- package/dist/commands/quickActionCommand.js.map +1 -1
- package/dist/common/cancellationUtils.d.ts +18 -2
- package/dist/common/cancellationUtils.js +80 -3
- package/dist/common/cancellationUtils.js.map +1 -1
- package/dist/common/collectionUtils.d.ts +1 -0
- package/dist/common/collectionUtils.js +8 -1
- package/dist/common/collectionUtils.js.map +1 -1
- package/dist/common/extensibility.d.ts +4 -3
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileBasedCancellationUtils.d.ts +0 -1
- package/dist/common/fileBasedCancellationUtils.js +7 -81
- package/dist/common/fileBasedCancellationUtils.js.map +1 -1
- package/dist/common/positionUtils.d.ts +2 -0
- package/dist/common/positionUtils.js +15 -1
- package/dist/common/positionUtils.js.map +1 -1
- package/dist/common/{textEditUtils.d.ts → textEditTracker.d.ts} +2 -6
- package/dist/common/{textEditUtils.js → textEditTracker.js} +6 -49
- package/dist/common/textEditTracker.js.map +1 -0
- package/dist/common/workspaceEditUtils.d.ts +14 -8
- package/dist/common/workspaceEditUtils.js +115 -59
- package/dist/common/workspaceEditUtils.js.map +1 -1
- package/dist/languageServerBase.js +9 -3
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/callHierarchyProvider.js +4 -2
- package/dist/languageService/callHierarchyProvider.js.map +1 -1
- package/dist/languageService/codeActionProvider.js +1 -1
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +49 -43
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +1 -1
- package/dist/languageService/completionProviderUtils.js +3 -3
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/languageService/definitionProvider.js +2 -1
- package/dist/languageService/definitionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.js +2 -1
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.js +14 -3
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/importAdder.d.ts +2 -2
- package/dist/languageService/importAdder.js +5 -3
- package/dist/languageService/importAdder.js.map +1 -1
- package/dist/languageService/indentationUtils.d.ts +6 -2
- package/dist/languageService/indentationUtils.js +33 -13
- package/dist/languageService/indentationUtils.js.map +1 -1
- package/dist/languageService/renameModuleProvider.d.ts +10 -2
- package/dist/languageService/renameModuleProvider.js +87 -14
- package/dist/languageService/renameModuleProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +12 -2
- package/dist/localization/localize.js +5 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +6 -2
- package/dist/parser/parser.js +18 -18
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +1 -1
- package/dist/pyright.js.map +1 -1
- package/dist/tests/docStringConversion.test.js +23 -0
- package/dist/tests/docStringConversion.test.js.map +1 -1
- package/dist/tests/fourslash/completions.errorNodes.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/completions.errorNodes.fourslash.js +24 -0
- package/dist/tests/fourslash/completions.errorNodes.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.docstring.parameter.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.docstring.parameter.fourslash.js +57 -0
- package/dist/tests/fourslash/hover.docstring.parameter.fourslash.js.map +1 -0
- package/dist/tests/fourslash/hover.slots.fourslash.d.ts +1 -0
- package/dist/tests/fourslash/hover.slots.fourslash.js +16 -0
- package/dist/tests/fourslash/hover.slots.fourslash.js.map +1 -0
- package/dist/tests/harness/fourslash/testState.js +9 -2
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/importAdder.test.js +16 -3
- package/dist/tests/importAdder.test.js.map +1 -1
- package/dist/tests/indentationUtils.reindent.test.js +22 -1
- package/dist/tests/indentationUtils.reindent.test.js.map +1 -1
- package/dist/tests/moveSymbol.importAdder.test.js +183 -24
- package/dist/tests/moveSymbol.importAdder.test.js.map +1 -1
- package/dist/tests/moveSymbol.insertion.test.js +137 -2
- package/dist/tests/moveSymbol.insertion.test.js.map +1 -1
- package/dist/tests/moveSymbol.misc.test.js +109 -4
- package/dist/tests/moveSymbol.misc.test.js.map +1 -1
- package/dist/tests/renameModuleTestUtils.d.ts +1 -1
- package/dist/tests/renameModuleTestUtils.js +9 -5
- package/dist/tests/renameModuleTestUtils.js.map +1 -1
- package/dist/tests/testStateUtils.js +2 -2
- package/dist/tests/testStateUtils.js.map +1 -1
- package/dist/tests/textEditUtil.test.js +2 -2
- package/dist/tests/textEditUtil.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +8 -0
- package/dist/tests/typeEvaluator1.test.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +13 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +29 -4
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/dist/tests/typeEvaluator5.test.js +6 -0
- package/dist/tests/typeEvaluator5.test.js.map +1 -1
- package/dist/tests/workspaceEditUtils.test.js +7 -7
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/package.json +3 -3
- package/dist/common/textEditUtils.js.map +0 -1
package/dist/analyzer/checker.js
CHANGED
@@ -46,7 +46,6 @@ const parseNodes_1 = require("../parser/parseNodes");
|
|
46
46
|
const stringTokenUtils_1 = require("../parser/stringTokenUtils");
|
47
47
|
const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
|
48
48
|
const declaration_1 = require("./declaration");
|
49
|
-
const declarationUtils_1 = require("./declarationUtils");
|
50
49
|
const importResolver_1 = require("./importResolver");
|
51
50
|
const importStatementUtils_1 = require("./importStatementUtils");
|
52
51
|
const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
|
@@ -271,20 +270,22 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
271
270
|
const functionTypeParam = functionTypeResult.functionType.details.parameters.find((p) => { var _a; return p.name === ((_a = param.name) === null || _a === void 0 ? void 0 : _a.value); });
|
272
271
|
if (functionTypeParam) {
|
273
272
|
const paramType = functionTypeParam.type;
|
274
|
-
if (
|
275
|
-
((0, types_1.
|
276
|
-
paramType
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
273
|
+
if (this._fileInfo.diagnosticRuleSet.reportUnknownParameterType !== 'none') {
|
274
|
+
if ((0, types_1.isUnknown)(paramType) ||
|
275
|
+
((0, types_1.isTypeVar)(paramType) &&
|
276
|
+
paramType.details.isSynthesized &&
|
277
|
+
!paramType.details.isSynthesizedSelf)) {
|
278
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.paramTypeUnknown().format({ paramName: param.name.value }), param.name);
|
279
|
+
}
|
280
|
+
else if ((0, typeUtils_1.isPartlyUnknown)(paramType)) {
|
281
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
282
|
+
diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.paramType().format({
|
283
|
+
paramType: this._evaluator.printType(paramType, { expandTypeAlias: true }),
|
284
|
+
}));
|
285
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.paramTypePartiallyUnknown().format({
|
286
|
+
paramName: param.name.value,
|
287
|
+
}) + diagAddendum.getString(), param.name);
|
288
|
+
}
|
288
289
|
}
|
289
290
|
let hasAnnotation = false;
|
290
291
|
if (functionTypeParam.typeAnnotation) {
|
@@ -296,7 +297,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
296
297
|
hasAnnotation = true;
|
297
298
|
}
|
298
299
|
}
|
299
|
-
if (!hasAnnotation) {
|
300
|
+
if (!hasAnnotation && this._fileInfo.diagnosticRuleSet.reportMissingParameterType !== 'none') {
|
300
301
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingParameterType, diagnosticRules_1.DiagnosticRule.reportMissingParameterType, localize_1.Localizer.Diagnostic.paramAnnotationMissing().format({ name: param.name.value }), param.name);
|
301
302
|
}
|
302
303
|
}
|
@@ -716,6 +717,20 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
716
717
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage, diagnosticRules_1.DiagnosticRule.reportTypeCommentUsage, localize_1.Localizer.Diagnostic.typeCommentDeprecated(), node.typeAnnotationComment);
|
717
718
|
}
|
718
719
|
}
|
720
|
+
// If this isn't a class or global scope, explicit type aliases are not allowed.
|
721
|
+
if (node.leftExpression.nodeType === 54 /* TypeAnnotation */) {
|
722
|
+
const annotationType = this._evaluator.getTypeOfAnnotation(node.leftExpression.typeAnnotation);
|
723
|
+
if ((0, types_1.isClassInstance)(annotationType) && types_1.ClassType.isBuiltIn(annotationType, 'TypeAlias')) {
|
724
|
+
const scope = (0, scopeUtils_1.getScopeForNode)(node);
|
725
|
+
if (scope) {
|
726
|
+
if (scope.type !== 2 /* Class */ &&
|
727
|
+
scope.type !== 3 /* Module */ &&
|
728
|
+
scope.type !== 4 /* Builtin */) {
|
729
|
+
this._evaluator.addError(localize_1.Localizer.Diagnostic.typeAliasNotInModuleOrClass(), node.leftExpression.typeAnnotation);
|
730
|
+
}
|
731
|
+
}
|
732
|
+
}
|
733
|
+
}
|
719
734
|
return true;
|
720
735
|
}
|
721
736
|
visitAssignmentExpression(node) {
|
@@ -1368,6 +1383,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1368
1383
|
// other types, and ParamSpecs. There are legitimate uses for singleton
|
1369
1384
|
// instances in these particular cases.
|
1370
1385
|
let isExempt = nameType.details.constraints.length > 0 ||
|
1386
|
+
!!nameType.details.defaultType ||
|
1371
1387
|
(exemptBoundTypeVar &&
|
1372
1388
|
nameType.details.boundType !== undefined &&
|
1373
1389
|
subscriptIndex !== undefined) ||
|
@@ -1416,6 +1432,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1416
1432
|
if (constructorClass && nameType.scopeId === constructorClass.details.typeVarScopeId) {
|
1417
1433
|
const existingEntry = classTypeVarUsage.get(nameType.details.name);
|
1418
1434
|
const isParamTypeWithEllipsisUsage = ((_d = curParamNode === null || curParamNode === void 0 ? void 0 : curParamNode.defaultValue) === null || _d === void 0 ? void 0 : _d.nodeType) === 18 /* Ellipsis */;
|
1435
|
+
const isExempt = !!nameType.details.defaultType;
|
1419
1436
|
if (!existingEntry) {
|
1420
1437
|
classTypeVarUsage.set(nameType.details.name, {
|
1421
1438
|
nodes: [nameNode],
|
@@ -1423,7 +1440,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1423
1440
|
paramTypeWithEllipsisUsageCount: isParamTypeWithEllipsisUsage ? 1 : 0,
|
1424
1441
|
returnTypeUsageCount: 0,
|
1425
1442
|
paramWithEllipsis: isParamTypeWithEllipsisUsage ? (_e = curParamNode === null || curParamNode === void 0 ? void 0 : curParamNode.name) === null || _e === void 0 ? void 0 : _e.value : undefined,
|
1426
|
-
isExempt
|
1443
|
+
isExempt,
|
1427
1444
|
});
|
1428
1445
|
}
|
1429
1446
|
else {
|
@@ -1501,7 +1518,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1501
1518
|
classTypeVarUsage.forEach((usage) => {
|
1502
1519
|
var _a;
|
1503
1520
|
if (usage.paramTypeWithEllipsisUsageCount > 0 &&
|
1504
|
-
usage.paramTypeUsageCount === usage.paramTypeWithEllipsisUsageCount
|
1521
|
+
usage.paramTypeUsageCount === usage.paramTypeWithEllipsisUsageCount &&
|
1522
|
+
!usage.isExempt) {
|
1505
1523
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
1506
1524
|
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarUnsolvableRemedy());
|
1507
1525
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidTypeVarUse, diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.Localizer.Diagnostic.typeVarPossiblyUnsolvable().format({
|
@@ -1872,14 +1890,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1872
1890
|
}
|
1873
1891
|
}
|
1874
1892
|
_reportMultipleFinalDeclarations(name, symbol, scopeType) {
|
1875
|
-
if (!
|
1893
|
+
if (!this._evaluator.isFinalVariable(symbol)) {
|
1876
1894
|
return;
|
1877
1895
|
}
|
1878
1896
|
const decls = symbol.getDeclarations();
|
1879
1897
|
let sawFinal = false;
|
1880
1898
|
let sawAssignment = false;
|
1881
1899
|
decls.forEach((decl) => {
|
1882
|
-
if (
|
1900
|
+
if (this._evaluator.isFinalVariableDeclaration(decl)) {
|
1883
1901
|
if (sawFinal) {
|
1884
1902
|
this._evaluator.addError(localize_1.Localizer.Diagnostic.finalRedeclaration().format({ name }), decl.node);
|
1885
1903
|
}
|
@@ -1925,7 +1943,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1925
1943
|
}
|
1926
1944
|
_reportMultipleTypeAliasDeclarations(name, symbol) {
|
1927
1945
|
const decls = symbol.getDeclarations();
|
1928
|
-
const typeAliasDecl = decls.find((decl) =>
|
1946
|
+
const typeAliasDecl = decls.find((decl) => this._evaluator.isExplicitTypeAliasDeclaration(decl));
|
1929
1947
|
// If this is a type alias, there should be only one declaration.
|
1930
1948
|
if (typeAliasDecl && decls.length > 1) {
|
1931
1949
|
decls.forEach((decl) => {
|
@@ -1936,6 +1954,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
1936
1954
|
}
|
1937
1955
|
}
|
1938
1956
|
_reportIncompatibleDeclarations(name, symbol) {
|
1957
|
+
var _a, _b, _c, _d;
|
1939
1958
|
// If there's one or more declaration with a declared type,
|
1940
1959
|
// all other declarations should match. The only exception is
|
1941
1960
|
// for functions that have an overload.
|
@@ -2042,13 +2061,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2042
2061
|
}
|
2043
2062
|
}
|
2044
2063
|
else if (otherDecl.type === 5 /* Function */) {
|
2045
|
-
const primaryType = this._evaluator.getTypeForDeclaration(primaryDecl);
|
2064
|
+
const primaryType = (_a = this._evaluator.getTypeForDeclaration(primaryDecl)) === null || _a === void 0 ? void 0 : _a.type;
|
2046
2065
|
let duplicateIsOk = false;
|
2047
2066
|
// If the return type has not yet been inferred, do so now.
|
2048
2067
|
if (primaryType && (0, types_1.isFunction)(primaryType)) {
|
2049
2068
|
this._evaluator.getFunctionInferredReturnType(primaryType);
|
2050
2069
|
}
|
2051
|
-
const otherType = this._evaluator.getTypeForDeclaration(otherDecl);
|
2070
|
+
const otherType = (_b = this._evaluator.getTypeForDeclaration(otherDecl)) === null || _b === void 0 ? void 0 : _b.type;
|
2052
2071
|
const suite1 = ParseTreeUtils.getEnclosingSuite(primaryDecl.node);
|
2053
2072
|
const suite2 = ParseTreeUtils.getEnclosingSuite(otherDecl.node);
|
2054
2073
|
// Allow same-signature overrides in cases where the declarations
|
@@ -2092,12 +2111,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
2092
2111
|
}
|
2093
2112
|
}
|
2094
2113
|
else if (otherDecl.type === 1 /* Variable */) {
|
2095
|
-
const primaryType = this._evaluator.getTypeForDeclaration(primaryDecl);
|
2114
|
+
const primaryType = (_c = this._evaluator.getTypeForDeclaration(primaryDecl)) === null || _c === void 0 ? void 0 : _c.type;
|
2096
2115
|
if (otherDecl.typeAnnotationNode) {
|
2097
2116
|
if (otherDecl.node.nodeType === 38 /* Name */) {
|
2098
2117
|
let duplicateIsOk = false;
|
2099
2118
|
// It's OK if they both have the same declared type.
|
2100
|
-
const otherType = this._evaluator.getTypeForDeclaration(otherDecl);
|
2119
|
+
const otherType = (_d = this._evaluator.getTypeForDeclaration(otherDecl)) === null || _d === void 0 ? void 0 : _d.type;
|
2101
2120
|
if (primaryType && otherType && (0, types_1.isTypeSame)(primaryType, otherType)) {
|
2102
2121
|
duplicateIsOk = true;
|
2103
2122
|
}
|
@@ -3004,7 +3023,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3004
3023
|
const parentSymbol = (0, typeUtils_1.lookUpClassMember)(classType, name, 1 /* SkipOriginalClass */);
|
3005
3024
|
if (parentSymbol &&
|
3006
3025
|
(0, types_1.isInstantiableClass)(parentSymbol.classType) &&
|
3007
|
-
|
3026
|
+
this._evaluator.isFinalVariable(parentSymbol.symbol) &&
|
3008
3027
|
!SymbolNameUtils.isPrivateName(name)) {
|
3009
3028
|
const decl = localSymbol.getDeclarations()[0];
|
3010
3029
|
this._evaluator.addError(localize_1.Localizer.Diagnostic.finalRedeclarationBySubclass().format({
|
@@ -3141,12 +3160,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3141
3160
|
// Verify that the parameter types match.
|
3142
3161
|
let paramIndex = 1;
|
3143
3162
|
initOnlySymbolMap.forEach((symbol, fieldName) => {
|
3163
|
+
var _a;
|
3144
3164
|
if (paramIndex >= paramListDetails.params.length) {
|
3145
3165
|
return;
|
3146
3166
|
}
|
3147
3167
|
const param = paramListDetails.params[paramIndex].param;
|
3148
3168
|
if (param.hasDeclaredType && param.typeAnnotation) {
|
3149
|
-
const fieldType = this._evaluator.getDeclaredTypeOfSymbol(symbol);
|
3169
|
+
const fieldType = (_a = this._evaluator.getDeclaredTypeOfSymbol(symbol)) === null || _a === void 0 ? void 0 : _a.type;
|
3150
3170
|
const paramType = types_1.FunctionType.getEffectiveParameterType(postInitType, paramListDetails.params[paramIndex].index);
|
3151
3171
|
const assignTypeDiag = new diagnostic_1.DiagnosticAddendum();
|
3152
3172
|
if (fieldType && !this._evaluator.assignType(paramType, fieldType, assignTypeDiag)) {
|
@@ -3650,7 +3670,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3650
3670
|
}
|
3651
3671
|
// If the symbol has no declaration, and the type is inferred,
|
3652
3672
|
// skip this check.
|
3653
|
-
if (!symbol.hasTypedDeclarations() && !
|
3673
|
+
if (!symbol.hasTypedDeclarations() && !this._evaluator.isFinalVariable(symbol)) {
|
3654
3674
|
return;
|
3655
3675
|
}
|
3656
3676
|
// Get the symbol type defined in this class.
|
@@ -3871,8 +3891,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
|
|
3871
3891
|
}
|
3872
3892
|
}
|
3873
3893
|
// Verify that there is not a Final mismatch.
|
3874
|
-
const isBaseVarFinal =
|
3875
|
-
const overrideFinalVarDecl = decls.find((d) =>
|
3894
|
+
const isBaseVarFinal = this._evaluator.isFinalVariable(baseClassAndSymbol.symbol);
|
3895
|
+
const overrideFinalVarDecl = decls.find((d) => this._evaluator.isFinalVariableDeclaration(d));
|
3876
3896
|
if (!isBaseVarFinal && overrideFinalVarDecl) {
|
3877
3897
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.variableFinalOverride().format({
|
3878
3898
|
name: memberName,
|