@artel/artc 0.6.26027 → 0.6.26028
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/build/Cli.js +3 -3
- package/build/api/Api.js +2 -2
- package/build/api/ApiNodeJS.js +3 -3
- package/build/api/ApiServices.js +1 -1
- package/build/{chunk-4HXQNBLV.js → chunk-G5UKABEH.js} +2 -2
- package/build/{chunk-IJGHVDYP.js → chunk-SPNTJ746.js} +1067 -1006
- package/build/{chunk-HOPCXROF.js → chunk-SYVSMJJH.js} +1 -1
- package/build/types/analysis/a/SourceFileAnalyzer.d.ts +59 -28
- package/build/types/diagnostic/DiagnosticCode.d.ts +1 -0
- package/package.json +1 -1
|
@@ -764,7 +764,7 @@ var UniqueWithComparatorQuery = class extends Query {
|
|
|
764
764
|
};
|
|
765
765
|
|
|
766
766
|
// source/common/Constants.ts
|
|
767
|
-
var ArtelVersion = true ? "0.6.
|
|
767
|
+
var ArtelVersion = true ? "0.6.26028" : "";
|
|
768
768
|
var ArtelSourceFileExtensions = [".\u0430\u0440\u0442", ".\u0430\u0440\u0442\u0435\u043B\u044C", ".art", ".artel", ".\u0430\u0440\u0442\u043C", ".\u0430\u0440\u0442\u0435\u043B\u044C\u043C", ".artm", ".artelm"];
|
|
769
769
|
var ArtelSourceFileExtensionSet = new Set(ArtelSourceFileExtensions);
|
|
770
770
|
var ArtelSourceAndConfigurationFileExtensionSet = new Set(ArtelSourceFileExtensionSet).add(".json");
|
|
@@ -3913,7 +3913,7 @@ var StructuredTypeKind = /* @__PURE__ */ ((StructuredTypeKind3) => {
|
|
|
3913
3913
|
|
|
3914
3914
|
// source/entities/TypeEntity.ts
|
|
3915
3915
|
var TypeEntity;
|
|
3916
|
-
((
|
|
3916
|
+
((TypeEntity15) => {
|
|
3917
3917
|
function isAbstract(entity) {
|
|
3918
3918
|
switch (entity.typeEntityKind) {
|
|
3919
3919
|
case 1 /* Structured */:
|
|
@@ -3928,7 +3928,7 @@ var TypeEntity;
|
|
|
3928
3928
|
Debug.never(entity);
|
|
3929
3929
|
}
|
|
3930
3930
|
}
|
|
3931
|
-
|
|
3931
|
+
TypeEntity15.isAbstract = isAbstract;
|
|
3932
3932
|
function isAbstractOrAliasedAbstract(entity) {
|
|
3933
3933
|
switch (entity.typeEntityKind) {
|
|
3934
3934
|
case 1 /* Structured */:
|
|
@@ -3946,7 +3946,7 @@ var TypeEntity;
|
|
|
3946
3946
|
Debug.never(entity);
|
|
3947
3947
|
}
|
|
3948
3948
|
}
|
|
3949
|
-
|
|
3949
|
+
TypeEntity15.isAbstractOrAliasedAbstract = isAbstractOrAliasedAbstract;
|
|
3950
3950
|
function isBasic(entity) {
|
|
3951
3951
|
switch (entity.typeEntityKind) {
|
|
3952
3952
|
case 1 /* Structured */:
|
|
@@ -3961,7 +3961,7 @@ var TypeEntity;
|
|
|
3961
3961
|
Debug.never(entity);
|
|
3962
3962
|
}
|
|
3963
3963
|
}
|
|
3964
|
-
|
|
3964
|
+
TypeEntity15.isBasic = isBasic;
|
|
3965
3965
|
function isBasicOrAliasedBasic(entity) {
|
|
3966
3966
|
switch (entity.typeEntityKind) {
|
|
3967
3967
|
case 1 /* Structured */:
|
|
@@ -3979,7 +3979,7 @@ var TypeEntity;
|
|
|
3979
3979
|
Debug.never(entity);
|
|
3980
3980
|
}
|
|
3981
3981
|
}
|
|
3982
|
-
|
|
3982
|
+
TypeEntity15.isBasicOrAliasedBasic = isBasicOrAliasedBasic;
|
|
3983
3983
|
})(TypeEntity || (TypeEntity = {}));
|
|
3984
3984
|
var TypeEntityKind = /* @__PURE__ */ ((TypeEntityKind2) => {
|
|
3985
3985
|
TypeEntityKind2[TypeEntityKind2["Function"] = 0] = "Function";
|
|
@@ -12255,6 +12255,7 @@ var DiagnosticCode = /* @__PURE__ */ ((DiagnosticCode2) => {
|
|
|
12255
12255
|
DiagnosticCode2[DiagnosticCode2["CannotAssignValueBecauseWriteFunctionIsNotDefined"] = 2243] = "CannotAssignValueBecauseWriteFunctionIsNotDefined";
|
|
12256
12256
|
DiagnosticCode2[DiagnosticCode2["CannotAssignValueBecauseWriteFunctionIsHidden"] = 2244] = "CannotAssignValueBecauseWriteFunctionIsHidden";
|
|
12257
12257
|
DiagnosticCode2[DiagnosticCode2["ReadFunctionMustHaveTheSameTypeAsWriteFunction"] = 2245] = "ReadFunctionMustHaveTheSameTypeAsWriteFunction";
|
|
12258
|
+
DiagnosticCode2[DiagnosticCode2["AspectHasAlreadyBeenExtendedWithDifferentTypeArguments0"] = 2246] = "AspectHasAlreadyBeenExtendedWithDifferentTypeArguments0";
|
|
12258
12259
|
DiagnosticCode2[DiagnosticCode2["CannotFindTsLibDirectoryBaseSearchPaths0"] = 3e3] = "CannotFindTsLibDirectoryBaseSearchPaths0";
|
|
12259
12260
|
DiagnosticCode2[DiagnosticCode2["SourceFile0IsNotPartOfThePackageAndWontBeLoaded"] = 3001] = "SourceFile0IsNotPartOfThePackageAndWontBeLoaded";
|
|
12260
12261
|
DiagnosticCode2[DiagnosticCode2["ProgramWithoutMainPackageCannotBeCompiled"] = 3002] = "ProgramWithoutMainPackageCannotBeCompiled";
|
|
@@ -12600,6 +12601,7 @@ var englishErrorMessages = {
|
|
|
12600
12601
|
[2243 /* CannotAssignValueBecauseWriteFunctionIsNotDefined */]: "Cannot assign value because write function is not defined.",
|
|
12601
12602
|
[2244 /* CannotAssignValueBecauseWriteFunctionIsHidden */]: "Cannot assign value because write function is hidden.",
|
|
12602
12603
|
[2245 /* ReadFunctionMustHaveTheSameTypeAsWriteFunction */]: "Read function must have the same type as write function.",
|
|
12604
|
+
[2246 /* AspectHasAlreadyBeenExtendedWithDifferentTypeArguments0 */]: "Aspect has already been extended with different type arguments: '{0}'.",
|
|
12603
12605
|
[3e3 /* CannotFindTsLibDirectoryBaseSearchPaths0 */]: "Can not find directory with TypeScript library. Base search paths: {0}.",
|
|
12604
12606
|
[3001 /* SourceFile0IsNotPartOfThePackageAndWontBeLoaded */]: "Source file '{0}' is not part of the package and won't be loaded.",
|
|
12605
12607
|
[3002 /* ProgramWithoutMainPackageCannotBeCompiled */]: "Program without main package cannot be compiled.",
|
|
@@ -12899,6 +12901,7 @@ var russianErrorMessages = {
|
|
|
12899
12901
|
[2243 /* CannotAssignValueBecauseWriteFunctionIsNotDefined */]: "\u041D\u0435\u043B\u044C\u0437\u044F \u043F\u0440\u0438\u0441\u0432\u043E\u0438\u0442\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435, \u043F\u043E\u0441\u043A\u043E\u043B\u044C\u043A\u0443 \u043E\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0444\u0443\u043D\u043A\u0446\u0438\u044F \u0437\u0430\u043F\u0438\u0441\u0438.",
|
|
12900
12902
|
[2244 /* CannotAssignValueBecauseWriteFunctionIsHidden */]: "\u041D\u0435\u043B\u044C\u0437\u044F \u043F\u0440\u0438\u0441\u0432\u043E\u0438\u0442\u044C \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435, \u043F\u043E\u0441\u043A\u043E\u043B\u044C\u043A\u0443 \u0444\u0443\u043D\u043A\u0446\u0438\u044F \u0437\u0430\u043F\u0438\u0441\u0438 \u0441\u043A\u0440\u044B\u0442\u0430.",
|
|
12901
12903
|
[2245 /* ReadFunctionMustHaveTheSameTypeAsWriteFunction */]: "\u0424\u0443\u043D\u043A\u0446\u0438\u044F \u0447\u0442\u0435\u043D\u0438\u044F \u0434\u043E\u043B\u0436\u043D\u0430 \u0438\u043C\u0435\u0442\u044C \u0442\u0430\u043A\u043E\u0439 \u0436\u0435 \u0442\u0438\u043F, \u043A\u0430\u043A \u0444\u0443\u043D\u043A\u0446\u0438\u044F \u0437\u0430\u043F\u0438\u0441\u0438.",
|
|
12904
|
+
[2246 /* AspectHasAlreadyBeenExtendedWithDifferentTypeArguments0 */]: "\u0410\u0441\u043F\u0435\u043A\u0442 \u0443\u0436\u0435 \u0431\u044B\u043B \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043D \u0441 \u0434\u0440\u0443\u0433\u0438\u043C\u0438 \u0430\u0440\u0433\u0443\u043C\u0435\u043D\u0442\u0430\u043C\u0438 \u0442\u0438\u043F\u0430: '{0}'.",
|
|
12902
12905
|
[3e3 /* CannotFindTsLibDirectoryBaseSearchPaths0 */]: "\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043D\u0430\u0439\u0442\u0438 \u043F\u0430\u043F\u043A\u0443 \u0441\u043E \u0441\u0442\u0430\u043D\u0434\u0430\u0440\u0442\u043D\u043E\u0439 \u0431\u0438\u0431\u043B\u0438\u043E\u0442\u0435\u043A\u043E\u0439 TypeScript. \u041F\u0443\u0442\u0438, \u043E\u0442\u043D\u043E\u0441\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u043A\u043E\u0442\u043E\u0440\u044B\u0445 \u043E\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043B\u044F\u043B\u0441\u044F \u043F\u043E\u0438\u0441\u043A: {0}.",
|
|
12903
12906
|
[3001 /* SourceFile0IsNotPartOfThePackageAndWontBeLoaded */]: "\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0444\u0430\u0439\u043B '{0}' \u043D\u0435 \u044F\u0432\u043B\u044F\u0435\u0442\u0441\u044F \u0447\u0430\u0441\u0442\u044C\u044E \u043F\u0430\u043A\u0435\u0442\u0430 \u0438 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043D.",
|
|
12904
12907
|
[3002 /* ProgramWithoutMainPackageCannotBeCompiled */]: "\u041F\u0440\u043E\u0433\u0440\u0430\u043C\u043C\u0430 \u0431\u0435\u0437 \u0433\u043B\u0430\u0432\u043D\u043E\u0433\u043E \u043F\u0430\u043A\u0435\u0442\u0430 \u043D\u0435 \u043C\u043E\u0436\u0435\u0442 \u0431\u044B\u0442\u044C \u0441\u043A\u043E\u043C\u043F\u0438\u043B\u0438\u0440\u043E\u0432\u0430\u043D\u0430.",
|
|
@@ -60694,518 +60697,375 @@ var SourceFileAnalyzer = class {
|
|
|
60694
60697
|
});
|
|
60695
60698
|
}
|
|
60696
60699
|
analyzeNode(node, controller) {
|
|
60700
|
+
let result = void 0;
|
|
60697
60701
|
switch (node.kind) {
|
|
60698
|
-
case 86 /* IdentifierExpression */:
|
|
60702
|
+
case 86 /* IdentifierExpression */:
|
|
60699
60703
|
this.checkIdentifierExpression(node);
|
|
60700
60704
|
break;
|
|
60701
|
-
|
|
60702
|
-
case 65 /* CallExpression */: {
|
|
60705
|
+
case 65 /* CallExpression */:
|
|
60703
60706
|
this.checkCallExpression(node);
|
|
60704
60707
|
break;
|
|
60705
|
-
|
|
60706
|
-
|
|
60707
|
-
this.analyzer.resolveAutotypeCallExpression(node);
|
|
60708
|
+
case 66 /* AutotypeCallExpression */:
|
|
60709
|
+
this.checkAutotypeCallExpression(node);
|
|
60708
60710
|
break;
|
|
60709
|
-
|
|
60710
|
-
case 67 /* IndexedAccessExpression */: {
|
|
60711
|
+
case 67 /* IndexedAccessExpression */:
|
|
60711
60712
|
this.checkIndexedAccessExpression(node);
|
|
60712
60713
|
break;
|
|
60713
|
-
|
|
60714
|
-
case 75 /* DereferenceExpression */: {
|
|
60714
|
+
case 75 /* DereferenceExpression */:
|
|
60715
60715
|
this.checkDereferenceExpression(node);
|
|
60716
60716
|
break;
|
|
60717
|
-
|
|
60718
|
-
|
|
60719
|
-
this.analyzer.resolveTag(node);
|
|
60717
|
+
case 150 /* Tag */:
|
|
60718
|
+
this.checkTag(node);
|
|
60720
60719
|
break;
|
|
60721
|
-
|
|
60722
|
-
|
|
60723
|
-
const resolutionResult = this.analyzer.resolveNamedTypeSpecifier(node);
|
|
60724
|
-
if (resolutionResult.type !== void 0) {
|
|
60725
|
-
const entity = resolutionResult.type.getEntity();
|
|
60726
|
-
if (entity !== void 0) {
|
|
60727
|
-
const typeArgumentCount = node.typeArgumentClause?.typeArgumentList.typeArguments.count() ?? 0;
|
|
60728
|
-
this.analyzer.checkTypeArgumentCount(
|
|
60729
|
-
typeArgumentCount,
|
|
60730
|
-
entity.getTypeParameters(),
|
|
60731
|
-
this.diagnosticAcceptor,
|
|
60732
|
-
node.typeArgumentClause ?? node.qualifiedName
|
|
60733
|
-
);
|
|
60734
|
-
const substitutions = resolutionResult.type.getSubstitutions();
|
|
60735
|
-
this.checkTypeArgumentTypesAreAssignableToConstraints(
|
|
60736
|
-
entity.getTypeParameters(),
|
|
60737
|
-
substitutions,
|
|
60738
|
-
void 0,
|
|
60739
|
-
node.typeArgumentClause ?? node
|
|
60740
|
-
);
|
|
60741
|
-
}
|
|
60742
|
-
}
|
|
60720
|
+
case 10 /* NamedTypeSpecifier */:
|
|
60721
|
+
this.checkNamedTypeSpecifier(node);
|
|
60743
60722
|
break;
|
|
60744
|
-
|
|
60745
|
-
case 37 /* ExtendedTypeClause */: {
|
|
60723
|
+
case 37 /* ExtendedTypeClause */:
|
|
60746
60724
|
break;
|
|
60747
|
-
|
|
60748
|
-
case 73 /* MemberAccessExpression */: {
|
|
60725
|
+
case 73 /* MemberAccessExpression */:
|
|
60749
60726
|
this.checkMemberAccessExpression(node);
|
|
60750
60727
|
break;
|
|
60751
|
-
|
|
60752
|
-
|
|
60753
|
-
this.analyzer.resolveLocalizableTextOrTextTemplate(node);
|
|
60728
|
+
case 82 /* LocalizableTextLiteral */:
|
|
60729
|
+
this.checkLocalizableTextLiteral(node);
|
|
60754
60730
|
break;
|
|
60755
|
-
|
|
60756
|
-
|
|
60757
|
-
const resolved = this.analyzer.resolveLocalizableTextOrTextTemplate(node);
|
|
60758
|
-
if (resolved !== void 0) {
|
|
60759
|
-
const spans = node.spanList.spans;
|
|
60760
|
-
const parameters = resolved.getParameters();
|
|
60761
|
-
if (spans.length === parameters.length) {
|
|
60762
|
-
for (let i = 0; i < spans.length; i++) {
|
|
60763
|
-
const argument2 = spans[i].expression;
|
|
60764
|
-
const parameter = parameters[i];
|
|
60765
|
-
this.checkExpressionTypeIsAssignableToTargetType(argument2, parameter.getType());
|
|
60766
|
-
}
|
|
60767
|
-
}
|
|
60768
|
-
}
|
|
60731
|
+
case 77 /* LocalizableTextTemplateLiteral */:
|
|
60732
|
+
this.checkLocalizableTextTemplateLiteral(node);
|
|
60769
60733
|
break;
|
|
60770
|
-
|
|
60771
|
-
|
|
60772
|
-
if (this.sourceFile.package.kind === "program") {
|
|
60773
|
-
this.createAndAddDiagnostic(
|
|
60774
|
-
2051 /* TranslationsCanOnlyBeDeclaredInTranslationPackage */,
|
|
60775
|
-
node.translationsKeyword
|
|
60776
|
-
);
|
|
60777
|
-
controller.skipChildrenTraverse();
|
|
60778
|
-
} else if (this.sourceFile.package.kind === "translation") {
|
|
60779
|
-
if (this.resolvedTranslationPackage === void 0) {
|
|
60780
|
-
this.createAndAddDiagnostic(
|
|
60781
|
-
2052 /* UnknownTranslatingPackage0 */,
|
|
60782
|
-
node.translationsKeyword,
|
|
60783
|
-
[this.sourceFile.package.configuration.targetPackageName.toString()]
|
|
60784
|
-
);
|
|
60785
|
-
controller.skipChildrenTraverse();
|
|
60786
|
-
}
|
|
60787
|
-
} else if (this.sourceFile.package.kind === "text-translation") {
|
|
60788
|
-
const textTranslationPackage = this.textTranslationPackage;
|
|
60789
|
-
const targetPackage = textTranslationPackage?.getTargetPackage();
|
|
60790
|
-
if (targetPackage === void 0 || textTranslationPackage === void 0) {
|
|
60791
|
-
this.createAndAddDiagnostic(
|
|
60792
|
-
2052 /* UnknownTranslatingPackage0 */,
|
|
60793
|
-
node.translationsKeyword,
|
|
60794
|
-
[this.sourceFile.package.configuration.targetPackageName.toString()]
|
|
60795
|
-
);
|
|
60796
|
-
controller.skipChildrenTraverse();
|
|
60797
|
-
} else {
|
|
60798
|
-
if (textTranslationPackage.isPrimary()) {
|
|
60799
|
-
const packages = this.analyzer.getTextTranslationPackagesOfTargetPackage(targetPackage);
|
|
60800
|
-
if (packages !== void 0 && packages.some((p) => p.isPrimary() && p !== textTranslationPackage)) {
|
|
60801
|
-
this.createAndAddDiagnostic(
|
|
60802
|
-
2196 /* OnlyOneTextTranslationPackageShouldBeMarkedAsPrimary */,
|
|
60803
|
-
node.translationsKeyword,
|
|
60804
|
-
[]
|
|
60805
|
-
);
|
|
60806
|
-
}
|
|
60807
|
-
}
|
|
60808
|
-
if (this.sourceFile.package.sourceFiles[0] === this.sourceFile) {
|
|
60809
|
-
this.addNotTranslatedTextsDiagnostics(textTranslationPackage, node.translationsKeyword);
|
|
60810
|
-
}
|
|
60811
|
-
}
|
|
60812
|
-
}
|
|
60734
|
+
case 121 /* TranslationsDeclaration */:
|
|
60735
|
+
this.checkTranslationsDeclaration(node, controller);
|
|
60813
60736
|
break;
|
|
60814
|
-
}
|
|
60815
60737
|
case 138 /* TextTranslationDeclaration */:
|
|
60816
|
-
case 139 /* TextTranslationFunctionDeclaration */:
|
|
60738
|
+
case 139 /* TextTranslationFunctionDeclaration */:
|
|
60817
60739
|
this.checkTextTranslationDeclaration(node);
|
|
60818
60740
|
break;
|
|
60819
|
-
}
|
|
60820
60741
|
case 27 /* PackageClassDeclaration */:
|
|
60821
60742
|
case 28 /* PackageStructureDeclaration */:
|
|
60822
|
-
case 29 /* PackageAspectDeclaration */:
|
|
60823
|
-
|
|
60824
|
-
|
|
60825
|
-
case 31 /* PackageVariantDeclaration */:
|
|
60743
|
+
case 29 /* PackageAspectDeclaration */:
|
|
60744
|
+
result = this.checkPackageStructuredTypeDeclaration(node, controller);
|
|
60745
|
+
break;
|
|
60746
|
+
case 31 /* PackageVariantDeclaration */:
|
|
60826
60747
|
this.checkPackageVariantDeclaration(node);
|
|
60827
60748
|
break;
|
|
60828
|
-
|
|
60829
|
-
case 32 /* PackageVariableDeclaration */: {
|
|
60749
|
+
case 32 /* PackageVariableDeclaration */:
|
|
60830
60750
|
this.checkPackageVariableDeclaration(node);
|
|
60831
60751
|
break;
|
|
60832
|
-
|
|
60833
|
-
case 23 /* PackageFunctionDeclaration */: {
|
|
60752
|
+
case 23 /* PackageFunctionDeclaration */:
|
|
60834
60753
|
this.checkPackageFunctionDeclaration(node);
|
|
60835
60754
|
break;
|
|
60836
|
-
|
|
60837
|
-
case 33 /* PackageVariableGetterDeclaration */: {
|
|
60755
|
+
case 33 /* PackageVariableGetterDeclaration */:
|
|
60838
60756
|
this.checkPackageVariableGetterDeclaration(node);
|
|
60839
60757
|
break;
|
|
60840
|
-
|
|
60841
|
-
case 34 /* PackageVariableSetterDeclaration */: {
|
|
60758
|
+
case 34 /* PackageVariableSetterDeclaration */:
|
|
60842
60759
|
this.checkPackageVariableSetterDeclaration(node);
|
|
60843
60760
|
break;
|
|
60844
|
-
|
|
60845
|
-
|
|
60846
|
-
if (this.isInterfacePackageFile) {
|
|
60847
|
-
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, node);
|
|
60848
|
-
}
|
|
60761
|
+
case 21 /* PackageConstructorDeclaration */:
|
|
60762
|
+
this.checkPackageConstructorDeclaration(node);
|
|
60849
60763
|
break;
|
|
60850
|
-
|
|
60851
|
-
|
|
60852
|
-
if (this.isInterfacePackageFile) {
|
|
60853
|
-
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, node.runKeyword);
|
|
60854
|
-
}
|
|
60764
|
+
case 22 /* PackageEntryPointDeclaration */:
|
|
60765
|
+
this.checkPackageEntryPointDeclaration(node);
|
|
60855
60766
|
break;
|
|
60856
|
-
|
|
60857
|
-
case 40 /* ConstructorDeclaration */: {
|
|
60767
|
+
case 40 /* ConstructorDeclaration */:
|
|
60858
60768
|
this.checkConstructorDeclaration(node);
|
|
60859
60769
|
break;
|
|
60860
|
-
|
|
60861
|
-
|
|
60862
|
-
const entity = this.analyzer.entity.ofDestructorDeclaration(node);
|
|
60863
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
60864
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.destructionKeyword);
|
|
60865
|
-
this.analyzer.semanticContext.ofDestructorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
60770
|
+
case 41 /* DestructorDeclaration */:
|
|
60771
|
+
this.checkDestructorDeclaration(node);
|
|
60866
60772
|
break;
|
|
60867
|
-
|
|
60868
|
-
case 49 /* FieldDeclaration */: {
|
|
60773
|
+
case 49 /* FieldDeclaration */:
|
|
60869
60774
|
this.checkFieldDeclaration(node);
|
|
60870
60775
|
break;
|
|
60871
|
-
|
|
60872
|
-
case 47 /* MethodDeclaration */: {
|
|
60776
|
+
case 47 /* MethodDeclaration */:
|
|
60873
60777
|
this.checkMethodDeclaration(node);
|
|
60874
60778
|
break;
|
|
60875
|
-
|
|
60876
|
-
case 50 /* FieldGetterDeclaration */: {
|
|
60779
|
+
case 50 /* FieldGetterDeclaration */:
|
|
60877
60780
|
this.checkFieldGetterDeclaration(node);
|
|
60878
60781
|
break;
|
|
60879
|
-
|
|
60880
|
-
case 51 /* FieldSetterDeclaration */: {
|
|
60782
|
+
case 51 /* FieldSetterDeclaration */:
|
|
60881
60783
|
this.checkFieldSetterDeclaration(node);
|
|
60882
60784
|
break;
|
|
60883
|
-
|
|
60884
|
-
case 42 /* IndexedElementGetterDeclaration */: {
|
|
60785
|
+
case 42 /* IndexedElementGetterDeclaration */:
|
|
60885
60786
|
this.checkIndexedElementGetterDeclaration(node);
|
|
60886
60787
|
break;
|
|
60887
|
-
|
|
60888
|
-
case 43 /* IndexedElementSetterDeclaration */: {
|
|
60788
|
+
case 43 /* IndexedElementSetterDeclaration */:
|
|
60889
60789
|
this.checkIndexedElementSetterDeclaration(node);
|
|
60890
60790
|
break;
|
|
60891
|
-
|
|
60892
|
-
case 45 /* DereferencedVariableGetterDeclaration */: {
|
|
60791
|
+
case 45 /* DereferencedVariableGetterDeclaration */:
|
|
60893
60792
|
this.checkDereferencedVariableGetterDeclaration(node);
|
|
60894
60793
|
break;
|
|
60895
|
-
|
|
60896
|
-
case 46 /* DereferencedVariableSetterDeclaration */: {
|
|
60794
|
+
case 46 /* DereferencedVariableSetterDeclaration */:
|
|
60897
60795
|
this.checkDereferencedVariableSetterDeclaration(node);
|
|
60898
60796
|
break;
|
|
60899
|
-
|
|
60900
|
-
case 53 /* NestedFunctionDeclaration */: {
|
|
60797
|
+
case 53 /* NestedFunctionDeclaration */:
|
|
60901
60798
|
this.checkNestedFunctionDeclaration(node);
|
|
60902
60799
|
break;
|
|
60903
|
-
|
|
60904
|
-
case 92 /* StatementBlock */: {
|
|
60800
|
+
case 92 /* StatementBlock */:
|
|
60905
60801
|
this.checkStatementBlock(node);
|
|
60906
60802
|
break;
|
|
60907
|
-
|
|
60908
|
-
case 93 /* FunctionBlock */: {
|
|
60803
|
+
case 93 /* FunctionBlock */:
|
|
60909
60804
|
this.checkFunctionBlock(node);
|
|
60910
60805
|
break;
|
|
60911
|
-
|
|
60912
|
-
|
|
60913
|
-
const checkResult = this.analyzer.checkExpressionCanBeUsedInForLoop(node.enumeratedExpression);
|
|
60914
|
-
if (checkResult.kind === "error") {
|
|
60915
|
-
this.addDiagnostics(checkResult.value);
|
|
60916
|
-
}
|
|
60917
|
-
this.analyzer.semanticContext.ofForStatement(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
60806
|
+
case 105 /* ForStatement */:
|
|
60807
|
+
this.checkForStatement(node);
|
|
60918
60808
|
break;
|
|
60919
|
-
|
|
60920
|
-
|
|
60921
|
-
this.analyzer.semanticContext.ofCatchClause(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
60809
|
+
case 99 /* CatchClause */:
|
|
60810
|
+
this.checkCatchClause(node);
|
|
60922
60811
|
break;
|
|
60923
|
-
|
|
60924
|
-
|
|
60925
|
-
this.analyzer.resolvePrefixUnaryExpressionUserDefinableOperator(node);
|
|
60812
|
+
case 72 /* PrefixUnaryExpression */:
|
|
60813
|
+
this.checkPrefixUnaryExpression(node);
|
|
60926
60814
|
break;
|
|
60927
|
-
|
|
60928
|
-
case 61 /* BinaryExpression */: {
|
|
60815
|
+
case 61 /* BinaryExpression */:
|
|
60929
60816
|
this.checkBinaryExpression(node);
|
|
60930
60817
|
break;
|
|
60931
|
-
|
|
60932
|
-
|
|
60933
|
-
if (this.checkAssignmentIsValid(node)) {
|
|
60934
|
-
if (node.operator.tokenKind === 64 /* Equals */) {
|
|
60935
|
-
this.checkExpressionTypeIsAssignableToTargetType(node.right, this.analyzer.type.ofExpression(node.left));
|
|
60936
|
-
}
|
|
60937
|
-
}
|
|
60938
|
-
const operatorKind = this.analyzer.getBinaryOperatorKindIfCompoundAssignmentOperator(node.operator);
|
|
60939
|
-
if (operatorKind !== void 0) {
|
|
60940
|
-
const operator = this.analyzer.resolveCompoundAssignmentStatementOperator(node, operatorKind);
|
|
60941
|
-
if (operator !== void 0) {
|
|
60942
|
-
const returnType = operator.getReturnType();
|
|
60943
|
-
const leftType = this.analyzer.type.ofExpression(node.left);
|
|
60944
|
-
if (!this.analyzer.isTypeAssignableTo(returnType, leftType)) {
|
|
60945
|
-
this.addTypeAssignabilityDiagnosticIfBothTypesResolved(
|
|
60946
|
-
returnType,
|
|
60947
|
-
leftType,
|
|
60948
|
-
node.right,
|
|
60949
|
-
2032 /* Type0IsNotAssignableToType1 */
|
|
60950
|
-
);
|
|
60951
|
-
}
|
|
60952
|
-
}
|
|
60953
|
-
}
|
|
60818
|
+
case 90 /* AssignmentStatement */:
|
|
60819
|
+
this.checkAssignmentStatement(node);
|
|
60954
60820
|
break;
|
|
60955
|
-
|
|
60956
|
-
|
|
60957
|
-
const entity = this.analyzer.entity.ofTypeExtensionDeclaration(node);
|
|
60958
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
60959
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
60960
|
-
node.memberBlock.memberList,
|
|
60961
|
-
6 /* TypeExtension */,
|
|
60962
|
-
false,
|
|
60963
|
-
false
|
|
60964
|
-
);
|
|
60965
|
-
this.overrideChecker.checkMembers(entity.getMembers());
|
|
60966
|
-
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
60821
|
+
case 35 /* TypeExtensionDeclaration */:
|
|
60822
|
+
this.checkTypeExtensionDeclaration(node);
|
|
60967
60823
|
break;
|
|
60968
|
-
|
|
60969
|
-
|
|
60970
|
-
this.analyzer.resolveObjectExpression(node);
|
|
60824
|
+
case 84 /* ObjectExpression */:
|
|
60825
|
+
this.checkObjectExpression(node);
|
|
60971
60826
|
break;
|
|
60972
|
-
|
|
60973
|
-
|
|
60974
|
-
const meaning = this.analyzer.resolveBaseExpression(node);
|
|
60975
|
-
if (meaning.kind === "base-object-access") {
|
|
60976
|
-
let parent = node.getParentSkippingParenthesizedExpressions();
|
|
60977
|
-
if (parent.kind === 60 /* AsExpression */) {
|
|
60978
|
-
parent = parent.getParentSkippingParenthesizedExpressions();
|
|
60979
|
-
}
|
|
60980
|
-
if (!(parent.kind === 73 /* MemberAccessExpression */ || parent.kind === 67 /* IndexedAccessExpression */ || parent.kind === 75 /* DereferenceExpression */)) {
|
|
60981
|
-
this.createAndAddDiagnostic(2059 /* BaseCannotBeUsedAsAnExpressionInItself */, node);
|
|
60982
|
-
}
|
|
60983
|
-
} else if (meaning.kind === "overridden-method-access" && meaning.method.kind === "substituted-function") {
|
|
60984
|
-
const typeArgumentClause = getParentGenericSpecializationExpression(node)?.typeArgumentClause;
|
|
60985
|
-
this.checkTypeArgumentTypesAreAssignableToConstraints(
|
|
60986
|
-
meaning.method.getTypeParameters(),
|
|
60987
|
-
meaning.method.value.getSubstitutions(),
|
|
60988
|
-
meaning.method.value.getOuterSubstitutions(),
|
|
60989
|
-
typeArgumentClause ?? node
|
|
60990
|
-
);
|
|
60991
|
-
}
|
|
60827
|
+
case 85 /* BaseExpression */:
|
|
60828
|
+
this.checkBaseExpression(node);
|
|
60992
60829
|
break;
|
|
60993
|
-
|
|
60994
|
-
case 114 /* ReturnStatement */: {
|
|
60830
|
+
case 114 /* ReturnStatement */:
|
|
60995
60831
|
this.checkReturnStatement(node);
|
|
60996
60832
|
break;
|
|
60997
|
-
|
|
60998
|
-
case 120 /* YieldStatement */: {
|
|
60833
|
+
case 120 /* YieldStatement */:
|
|
60999
60834
|
this.checkYieldStatement(node);
|
|
61000
60835
|
break;
|
|
61001
|
-
|
|
61002
|
-
|
|
61003
|
-
const entity = this.analyzer.entity.ofPackageAliasTypeDeclaration(node);
|
|
61004
|
-
if (entity.getAliasedType().causesCycle) {
|
|
61005
|
-
this.createAndAddDiagnostic(2080 /* TypeAliasReferencesItself */, node.name);
|
|
61006
|
-
}
|
|
61007
|
-
if (node.typeParameterClause !== void 0) {
|
|
61008
|
-
this.analyzer.semanticContext.ofTypeDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61009
|
-
}
|
|
61010
|
-
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61011
|
-
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
61012
|
-
const semanticContext = this.analyzer.semanticContext.outermostSemanticContextOfTypeDeclaration(node);
|
|
61013
|
-
new BaseMemberConflictsValidator(
|
|
61014
|
-
this.analyzer,
|
|
61015
|
-
entity,
|
|
61016
|
-
semanticContext.getDiagnosticArgumentFactory(),
|
|
61017
|
-
this.diagnosticAcceptor,
|
|
61018
|
-
node.name
|
|
61019
|
-
).validate();
|
|
60836
|
+
case 19 /* PackageAliasTypeDeclaration */:
|
|
60837
|
+
this.checkPackageAliasTypeDeclaration(node);
|
|
61020
60838
|
break;
|
|
61021
|
-
|
|
61022
|
-
|
|
61023
|
-
const entity = this.analyzer.entity.ofPackageReducedTypeDeclaration(node);
|
|
61024
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61025
|
-
if (entity.getReductionSource().causesCycle) {
|
|
61026
|
-
this.createAndAddDiagnostic(2081 /* ReducedTypeReferencesItself */, node.name);
|
|
61027
|
-
}
|
|
61028
|
-
if (node.typeParameterClause !== void 0) {
|
|
61029
|
-
this.analyzer.semanticContext.ofTypeDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61030
|
-
}
|
|
61031
|
-
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61032
|
-
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
60839
|
+
case 30 /* PackageReducedTypeDeclaration */:
|
|
60840
|
+
this.checkPackageReducedTypeDeclaration(node);
|
|
61033
60841
|
break;
|
|
61034
|
-
|
|
61035
|
-
case 158 /* TypeParameterList */: {
|
|
60842
|
+
case 158 /* TypeParameterList */:
|
|
61036
60843
|
this.checkTypeParameterList(node);
|
|
61037
60844
|
break;
|
|
61038
|
-
|
|
61039
|
-
case 146 /* TypeParameterDeclaration */: {
|
|
60845
|
+
case 146 /* TypeParameterDeclaration */:
|
|
61040
60846
|
this.checkTypeParameterDeclaration(node);
|
|
61041
60847
|
break;
|
|
61042
|
-
|
|
61043
|
-
case 87 /* GenericSpecializationExpression */: {
|
|
60848
|
+
case 87 /* GenericSpecializationExpression */:
|
|
61044
60849
|
this.checkGenericSpecializationExpression(node);
|
|
61045
60850
|
break;
|
|
61046
|
-
|
|
61047
|
-
|
|
61048
|
-
const entity = this.analyzer.entity.ofLocalVariableDeclaration(node);
|
|
61049
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61050
|
-
if (node.typeAnnotation === void 0 && node.initializer === void 0) {
|
|
61051
|
-
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
61052
|
-
} else if (node.initializer !== void 0 && node.typeAnnotation !== void 0) {
|
|
61053
|
-
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61054
|
-
node.initializer,
|
|
61055
|
-
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
61056
|
-
);
|
|
61057
|
-
}
|
|
61058
|
-
this.checkIfVariableIsUnused(entity, node.name);
|
|
60851
|
+
case 54 /* LocalVariableDeclaration */:
|
|
60852
|
+
this.checkLocalVariableDeclaration(node);
|
|
61059
60853
|
break;
|
|
61060
|
-
|
|
61061
|
-
|
|
61062
|
-
const entity = this.analyzer.entity.ofForStatementVariableDeclaration(node);
|
|
61063
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61064
|
-
this.checkIfVariableIsUnused(entity, node.name);
|
|
60854
|
+
case 55 /* ForStatementVariableDeclaration */:
|
|
60855
|
+
this.checkForStatementVariableDeclaration(node);
|
|
61065
60856
|
break;
|
|
61066
|
-
|
|
61067
|
-
|
|
61068
|
-
const entity = this.analyzer.entity.ofErrorVariableDeclaration(node);
|
|
61069
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61070
|
-
this.checkIfVariableIsUnused(entity, node.name);
|
|
60857
|
+
case 100 /* ErrorVariableDeclaration */:
|
|
60858
|
+
this.checkErrorVariableDeclaration(node);
|
|
61071
60859
|
break;
|
|
61072
|
-
|
|
61073
|
-
case 154 /* ParameterList */: {
|
|
60860
|
+
case 154 /* ParameterList */:
|
|
61074
60861
|
this.checkParameterList(node);
|
|
61075
60862
|
break;
|
|
61076
|
-
|
|
61077
|
-
case 147 /* ParameterDeclaration */: {
|
|
60863
|
+
case 147 /* ParameterDeclaration */:
|
|
61078
60864
|
this.checkParameterDeclaration(node);
|
|
61079
60865
|
break;
|
|
61080
|
-
|
|
61081
|
-
case 62 /* FunctionLiteral */: {
|
|
60866
|
+
case 62 /* FunctionLiteral */:
|
|
61082
60867
|
this.checkFunctionLiteral(node);
|
|
61083
60868
|
break;
|
|
61084
|
-
|
|
61085
|
-
case 63 /* FunctionBlockLiteral */: {
|
|
60869
|
+
case 63 /* FunctionBlockLiteral */:
|
|
61086
60870
|
this.checkFunctionBlockLiteral(node);
|
|
61087
60871
|
break;
|
|
61088
|
-
|
|
61089
|
-
|
|
61090
|
-
this.analyzer.semanticContext.ofFunctionTypeDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
60872
|
+
case 17 /* AnonymousFunctionTypeDeclaration */:
|
|
60873
|
+
this.checkAnonymousFunctionTypeDeclaration(node);
|
|
61091
60874
|
break;
|
|
61092
|
-
|
|
61093
|
-
|
|
61094
|
-
const entity = this.analyzer.entity.ofAnonymousStructuredTypeDeclaration(node);
|
|
61095
|
-
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61096
|
-
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
61097
|
-
const semanticContext = this.analyzer.semanticContext.outermostSemanticContextOfTypeDeclaration(node);
|
|
61098
|
-
new BaseMemberConflictsValidator(
|
|
61099
|
-
this.analyzer,
|
|
61100
|
-
entity,
|
|
61101
|
-
semanticContext.getDiagnosticArgumentFactory(),
|
|
61102
|
-
this.diagnosticAcceptor,
|
|
61103
|
-
node.classKeyword
|
|
61104
|
-
).validate();
|
|
61105
|
-
const typeMemberImplementationCheckResult = this.analyzer.getTypeMemberImplementationCheckResult(entity);
|
|
61106
|
-
this.attachNodeLocationAndAddDiagnostics(
|
|
61107
|
-
typeMemberImplementationCheckResult.diagnosticsData,
|
|
61108
|
-
node.classKeyword
|
|
61109
|
-
);
|
|
61110
|
-
if (!this.isInterfacePackageFile) {
|
|
61111
|
-
this.addDiagnostics(this.analyzer.getOwnAndBaseConstructorCallsCheckResult(node).diagnostics);
|
|
61112
|
-
new InstanceFieldsInitializationValidator(
|
|
61113
|
-
this.analyzer,
|
|
61114
|
-
node,
|
|
61115
|
-
this.namedDeclarationsUsageMap,
|
|
61116
|
-
this.diagnosticAcceptor
|
|
61117
|
-
).validate();
|
|
61118
|
-
}
|
|
60875
|
+
case 18 /* AnonymousClassDeclaration */:
|
|
60876
|
+
this.checkAnonymousClassDeclaration(node);
|
|
61119
60877
|
break;
|
|
61120
|
-
|
|
61121
|
-
case 26 /* TypeMemberDeclarationBlock */: {
|
|
60878
|
+
case 26 /* TypeMemberDeclarationBlock */:
|
|
61122
60879
|
this.checkTypeMemberDeclarationBlock(node);
|
|
61123
60880
|
break;
|
|
61124
|
-
|
|
61125
|
-
|
|
61126
|
-
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61127
|
-
node.value,
|
|
61128
|
-
this.analyzer.getTargetTypeOfExpression(node.value)
|
|
61129
|
-
);
|
|
60881
|
+
case 148 /* Argument */:
|
|
60882
|
+
this.checkArgument(node);
|
|
61130
60883
|
break;
|
|
61131
|
-
|
|
61132
|
-
case 102 /* ErrorStatement */: {
|
|
60884
|
+
case 102 /* ErrorStatement */:
|
|
61133
60885
|
this.checkErrorStatement(node);
|
|
61134
60886
|
break;
|
|
61135
|
-
|
|
61136
|
-
|
|
61137
|
-
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
60887
|
+
case 106 /* IfStatement */:
|
|
60888
|
+
this.checkIfStatement(node);
|
|
61138
60889
|
break;
|
|
61139
|
-
|
|
61140
|
-
|
|
61141
|
-
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
60890
|
+
case 108 /* ElseIfClause */:
|
|
60891
|
+
this.checkElseIfClause(node);
|
|
61142
60892
|
break;
|
|
61143
|
-
|
|
61144
|
-
|
|
61145
|
-
if (node.condition !== void 0) {
|
|
61146
|
-
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
61147
|
-
}
|
|
60893
|
+
case 113 /* LoopStatement */:
|
|
60894
|
+
this.checkLoopStatement(node);
|
|
61148
60895
|
break;
|
|
61149
|
-
|
|
61150
|
-
|
|
61151
|
-
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
60896
|
+
case 119 /* WhileStatement */:
|
|
60897
|
+
this.checkWhileStatement(node);
|
|
61152
60898
|
break;
|
|
61153
|
-
|
|
61154
|
-
|
|
61155
|
-
const matchedExpressionType = this.analyzer.type.ofExpression(node.parent.parent.parent.expression);
|
|
61156
|
-
for (const expression of node.matchExpressions) {
|
|
61157
|
-
this.checkExpressionTypeIsAssignableToTargetType(expression, matchedExpressionType);
|
|
61158
|
-
}
|
|
60899
|
+
case 117 /* MatchExpressionList */:
|
|
60900
|
+
this.checkMatchExpressionList(node);
|
|
61159
60901
|
break;
|
|
61160
|
-
|
|
61161
|
-
|
|
61162
|
-
if (!this.analyzer.expressionCanBeReferenced(node.expression)) {
|
|
61163
|
-
this.createAndAddDiagnostic(2189 /* ExpressionCannotBeReferenced */, node.expression);
|
|
61164
|
-
}
|
|
60902
|
+
case 74 /* ReferenceExpression */:
|
|
60903
|
+
this.checkReferenceExpression(node);
|
|
61165
60904
|
break;
|
|
61166
|
-
}
|
|
61167
60905
|
case 94 /* BreakLoopStatement */:
|
|
61168
|
-
case 95 /* ContinueLoopStatement */:
|
|
60906
|
+
case 95 /* ContinueLoopStatement */:
|
|
61169
60907
|
this.checkBreakLoopOrContinueLoopStatement(node);
|
|
61170
60908
|
break;
|
|
61171
|
-
|
|
61172
|
-
|
|
61173
|
-
this.analyzer.resolveOwnConstructorCallExpression(node);
|
|
60909
|
+
case 89 /* OwnConstructorCallExpression */:
|
|
60910
|
+
this.checkOwnConstructorCallExpression(node);
|
|
61174
60911
|
break;
|
|
61175
|
-
|
|
61176
|
-
case 59 /* AssumptionExpression */: {
|
|
60912
|
+
case 59 /* AssumptionExpression */:
|
|
61177
60913
|
this.checkAssumptionExpression(node);
|
|
61178
60914
|
break;
|
|
60915
|
+
}
|
|
60916
|
+
return result;
|
|
60917
|
+
}
|
|
60918
|
+
checkTag(node) {
|
|
60919
|
+
this.analyzer.resolveTag(node);
|
|
60920
|
+
}
|
|
60921
|
+
checkPackageReducedTypeDeclaration(node) {
|
|
60922
|
+
const entity = this.analyzer.entity.ofPackageReducedTypeDeclaration(node);
|
|
60923
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
60924
|
+
if (entity.getReductionSource().causesCycle) {
|
|
60925
|
+
this.createAndAddDiagnostic(2081 /* ReducedTypeReferencesItself */, node.name);
|
|
60926
|
+
}
|
|
60927
|
+
if (node.typeParameterClause !== void 0) {
|
|
60928
|
+
this.analyzer.semanticContext.ofTypeDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
60929
|
+
}
|
|
60930
|
+
this.overrideChecker.checkMembers(entity.getMembers());
|
|
60931
|
+
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
60932
|
+
}
|
|
60933
|
+
checkPackageAliasTypeDeclaration(node) {
|
|
60934
|
+
const entity = this.analyzer.entity.ofPackageAliasTypeDeclaration(node);
|
|
60935
|
+
if (entity.getAliasedType().causesCycle) {
|
|
60936
|
+
this.createAndAddDiagnostic(2080 /* TypeAliasReferencesItself */, node.name);
|
|
60937
|
+
}
|
|
60938
|
+
if (node.typeParameterClause !== void 0) {
|
|
60939
|
+
this.analyzer.semanticContext.ofTypeDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
60940
|
+
}
|
|
60941
|
+
this.overrideChecker.checkMembers(entity.getMembers());
|
|
60942
|
+
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
60943
|
+
const semanticContext = this.analyzer.semanticContext.outermostSemanticContextOfTypeDeclaration(node);
|
|
60944
|
+
new BaseMemberConflictsValidator(
|
|
60945
|
+
this.analyzer,
|
|
60946
|
+
entity,
|
|
60947
|
+
semanticContext.getDiagnosticArgumentFactory(),
|
|
60948
|
+
this.diagnosticAcceptor,
|
|
60949
|
+
node.name
|
|
60950
|
+
).validate();
|
|
60951
|
+
}
|
|
60952
|
+
checkPackageEntryPointDeclaration(node) {
|
|
60953
|
+
if (this.isInterfacePackageFile) {
|
|
60954
|
+
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, node.runKeyword);
|
|
60955
|
+
}
|
|
60956
|
+
}
|
|
60957
|
+
checkPackageConstructorDeclaration(node) {
|
|
60958
|
+
if (this.isInterfacePackageFile) {
|
|
60959
|
+
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, node);
|
|
60960
|
+
}
|
|
60961
|
+
}
|
|
60962
|
+
checkTranslationsDeclaration(node, controller) {
|
|
60963
|
+
if (this.sourceFile.package.kind === "program") {
|
|
60964
|
+
this.createAndAddDiagnostic(
|
|
60965
|
+
2051 /* TranslationsCanOnlyBeDeclaredInTranslationPackage */,
|
|
60966
|
+
node.translationsKeyword
|
|
60967
|
+
);
|
|
60968
|
+
controller.skipChildrenTraverse();
|
|
60969
|
+
} else if (this.sourceFile.package.kind === "translation") {
|
|
60970
|
+
if (this.resolvedTranslationPackage === void 0) {
|
|
60971
|
+
this.createAndAddDiagnostic(
|
|
60972
|
+
2052 /* UnknownTranslatingPackage0 */,
|
|
60973
|
+
node.translationsKeyword,
|
|
60974
|
+
[this.sourceFile.package.configuration.targetPackageName.toString()]
|
|
60975
|
+
);
|
|
60976
|
+
controller.skipChildrenTraverse();
|
|
60977
|
+
}
|
|
60978
|
+
} else if (this.sourceFile.package.kind === "text-translation") {
|
|
60979
|
+
const textTranslationPackage = this.textTranslationPackage;
|
|
60980
|
+
const targetPackage = textTranslationPackage?.getTargetPackage();
|
|
60981
|
+
if (targetPackage === void 0 || textTranslationPackage === void 0) {
|
|
60982
|
+
this.createAndAddDiagnostic(
|
|
60983
|
+
2052 /* UnknownTranslatingPackage0 */,
|
|
60984
|
+
node.translationsKeyword,
|
|
60985
|
+
[this.sourceFile.package.configuration.targetPackageName.toString()]
|
|
60986
|
+
);
|
|
60987
|
+
controller.skipChildrenTraverse();
|
|
60988
|
+
} else {
|
|
60989
|
+
if (textTranslationPackage.isPrimary()) {
|
|
60990
|
+
const packages = this.analyzer.getTextTranslationPackagesOfTargetPackage(targetPackage);
|
|
60991
|
+
if (packages !== void 0 && packages.some((p) => p.isPrimary() && p !== textTranslationPackage)) {
|
|
60992
|
+
this.createAndAddDiagnostic(
|
|
60993
|
+
2196 /* OnlyOneTextTranslationPackageShouldBeMarkedAsPrimary */,
|
|
60994
|
+
node.translationsKeyword,
|
|
60995
|
+
[]
|
|
60996
|
+
);
|
|
60997
|
+
}
|
|
60998
|
+
}
|
|
60999
|
+
if (this.sourceFile.package.sourceFiles[0] === this.sourceFile) {
|
|
61000
|
+
this.addNotTranslatedTextsDiagnostics(textTranslationPackage, node.translationsKeyword);
|
|
61001
|
+
}
|
|
61179
61002
|
}
|
|
61180
61003
|
}
|
|
61181
|
-
return void 0;
|
|
61182
61004
|
}
|
|
61183
|
-
|
|
61184
|
-
const
|
|
61185
|
-
|
|
61186
|
-
|
|
61187
|
-
|
|
61188
|
-
|
|
61189
|
-
|
|
61190
|
-
|
|
61191
|
-
|
|
61192
|
-
|
|
61193
|
-
|
|
61194
|
-
|
|
61195
|
-
|
|
61196
|
-
|
|
61197
|
-
|
|
61198
|
-
|
|
61199
|
-
|
|
61200
|
-
|
|
61201
|
-
|
|
61005
|
+
addNotTranslatedTextsDiagnostics(translationPackage, diagnosticLocation) {
|
|
61006
|
+
const notTranslatedEntities = this.collectNotTranslatedTexts(translationPackage);
|
|
61007
|
+
if (notTranslatedEntities.length > 0) {
|
|
61008
|
+
const diagnostic = this.createNotTranslatedTextsDiagnostic(notTranslatedEntities, diagnosticLocation);
|
|
61009
|
+
this.addDiagnostic(diagnostic);
|
|
61010
|
+
}
|
|
61011
|
+
}
|
|
61012
|
+
collectNotTranslatedTexts(translationPackage) {
|
|
61013
|
+
return [];
|
|
61014
|
+
}
|
|
61015
|
+
createNotTranslatedTextsDiagnostic(entities, diagnosticLocation) {
|
|
61016
|
+
const maxDisplayedEntitiesCount = 10;
|
|
61017
|
+
let result;
|
|
61018
|
+
if (entities.length <= maxDisplayedEntitiesCount) {
|
|
61019
|
+
const displayableEntities = entities.map((e) => this.diagnosticArgumentFactory.createDisplayableEntity(e));
|
|
61020
|
+
result = this.analyzer.createDiagnostic(
|
|
61021
|
+
2095 /* TheFollowingTextsAreNotTranslated0 */,
|
|
61022
|
+
diagnosticLocation,
|
|
61023
|
+
[new DisplayableArray(displayableEntities, "\n\n")],
|
|
61024
|
+
1 /* Warning */
|
|
61025
|
+
);
|
|
61026
|
+
} else {
|
|
61027
|
+
const displayableEntities = entities.slice(0, maxDisplayedEntitiesCount + 1).map((e) => this.diagnosticArgumentFactory.createDisplayableEntity(e));
|
|
61028
|
+
result = this.analyzer.createDiagnostic(
|
|
61029
|
+
2096 /* TheFollowingTextsAreNotTranslated0And1More */,
|
|
61030
|
+
diagnosticLocation,
|
|
61031
|
+
[new DisplayableArray(displayableEntities, "\n\n"), entities.length - maxDisplayedEntitiesCount],
|
|
61032
|
+
1 /* Warning */
|
|
61033
|
+
);
|
|
61034
|
+
}
|
|
61035
|
+
return result;
|
|
61036
|
+
}
|
|
61037
|
+
checkTextTranslationDeclaration(node) {
|
|
61038
|
+
const sourceText = node.sourceText;
|
|
61039
|
+
if (sourceText.kind === 141 /* TranslationTextTemplate */) {
|
|
61040
|
+
const semanticContext = this.analyzer.semanticContext.ofTextTranslationDeclarationParameters(sourceText);
|
|
61041
|
+
semanticContext.validateNameConflicts(this.diagnosticAcceptor);
|
|
61042
|
+
}
|
|
61043
|
+
const pkg2 = this.textTranslationPackage;
|
|
61044
|
+
if (pkg2 !== void 0 && !pkg2.isPrimary()) {
|
|
61045
|
+
const targetPackage = pkg2.getTargetPackage();
|
|
61046
|
+
if (targetPackage !== void 0) {
|
|
61047
|
+
const primaryPkg = this.analyzer.getPrimaryTextTranslationPackageOfTargetPackage(targetPackage);
|
|
61048
|
+
if (primaryPkg !== void 0) {
|
|
61049
|
+
const textKey = TextIdentity.keyFromTextTranslationSource(sourceText);
|
|
61050
|
+
const textTranslation = primaryPkg.getMembers().getTextTranslationsByTextKey(textKey);
|
|
61051
|
+
if (textTranslation.length === 0) {
|
|
61052
|
+
this.createAndAddDiagnostic(
|
|
61053
|
+
2190 /* TextIsMissingAmongPrimaryTextTranslationDefinitions */,
|
|
61054
|
+
sourceText,
|
|
61055
|
+
void 0,
|
|
61056
|
+
1 /* Warning */
|
|
61057
|
+
);
|
|
61058
|
+
}
|
|
61202
61059
|
}
|
|
61203
|
-
break;
|
|
61204
61060
|
}
|
|
61205
|
-
|
|
61206
|
-
|
|
61207
|
-
|
|
61208
|
-
|
|
61061
|
+
}
|
|
61062
|
+
if (node.kind === 139 /* TextTranslationFunctionDeclaration */) {
|
|
61063
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61064
|
+
node,
|
|
61065
|
+
node.sourceText,
|
|
61066
|
+
this.analyzer.returnType.ofTextTranslationFunctionDeclaration(node),
|
|
61067
|
+
this.analyzer.resultLocalVariableEntity.ofTextTranslationFunctionDeclaration(node)
|
|
61068
|
+
);
|
|
61209
61069
|
}
|
|
61210
61070
|
}
|
|
61211
61071
|
checkPackageVariantDeclaration(node) {
|
|
@@ -61213,6 +61073,9 @@ var SourceFileAnalyzer = class {
|
|
|
61213
61073
|
this.analyzer.semanticContext.ofTypeDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61214
61074
|
}
|
|
61215
61075
|
const entity = this.analyzer.entity.ofPackageVariantDeclaration(node);
|
|
61076
|
+
if (node.extendsClause !== void 0) {
|
|
61077
|
+
this.checkAspectsHaveNotBeenExtendedWithDifferentTypeArguments(entity, node.extendsClause.baseTypeList, node.name);
|
|
61078
|
+
}
|
|
61216
61079
|
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61217
61080
|
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
61218
61081
|
const semanticContext = this.analyzer.semanticContext.outermostSemanticContextOfTypeDeclaration(node);
|
|
@@ -61237,105 +61100,6 @@ var SourceFileAnalyzer = class {
|
|
|
61237
61100
|
}
|
|
61238
61101
|
}
|
|
61239
61102
|
}
|
|
61240
|
-
checkTypeMemberDeclarationBlock(node) {
|
|
61241
|
-
const parent = node.parent;
|
|
61242
|
-
if (isTypeDeclaration(parent)) {
|
|
61243
|
-
switch (parent.kind) {
|
|
61244
|
-
case 27 /* PackageClassDeclaration */: {
|
|
61245
|
-
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(parent);
|
|
61246
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61247
|
-
node.memberList,
|
|
61248
|
-
0 /* Class */,
|
|
61249
|
-
entity.isAbstract(),
|
|
61250
|
-
entity.markedBasic()
|
|
61251
|
-
);
|
|
61252
|
-
break;
|
|
61253
|
-
}
|
|
61254
|
-
case 28 /* PackageStructureDeclaration */: {
|
|
61255
|
-
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(parent);
|
|
61256
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61257
|
-
node.memberList,
|
|
61258
|
-
1 /* Structure */,
|
|
61259
|
-
entity.isAbstract(),
|
|
61260
|
-
entity.markedBasic()
|
|
61261
|
-
);
|
|
61262
|
-
break;
|
|
61263
|
-
}
|
|
61264
|
-
case 29 /* PackageAspectDeclaration */: {
|
|
61265
|
-
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(parent);
|
|
61266
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61267
|
-
node.memberList,
|
|
61268
|
-
2 /* Aspect */,
|
|
61269
|
-
entity.isAbstract(),
|
|
61270
|
-
entity.markedBasic()
|
|
61271
|
-
);
|
|
61272
|
-
break;
|
|
61273
|
-
}
|
|
61274
|
-
case 18 /* AnonymousClassDeclaration */: {
|
|
61275
|
-
const entity = this.analyzer.entity.ofAnonymousStructuredTypeDeclaration(parent);
|
|
61276
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61277
|
-
node.memberList,
|
|
61278
|
-
2 /* Aspect */,
|
|
61279
|
-
entity.isAbstract(),
|
|
61280
|
-
entity.markedBasic()
|
|
61281
|
-
);
|
|
61282
|
-
break;
|
|
61283
|
-
}
|
|
61284
|
-
case 30 /* PackageReducedTypeDeclaration */: {
|
|
61285
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61286
|
-
node.memberList,
|
|
61287
|
-
5 /* ReducedType */,
|
|
61288
|
-
false,
|
|
61289
|
-
false
|
|
61290
|
-
);
|
|
61291
|
-
break;
|
|
61292
|
-
}
|
|
61293
|
-
case 31 /* PackageVariantDeclaration */: {
|
|
61294
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61295
|
-
node.memberList,
|
|
61296
|
-
3 /* Variant */,
|
|
61297
|
-
false,
|
|
61298
|
-
false
|
|
61299
|
-
);
|
|
61300
|
-
break;
|
|
61301
|
-
}
|
|
61302
|
-
case 19 /* PackageAliasTypeDeclaration */: {
|
|
61303
|
-
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61304
|
-
node.memberList,
|
|
61305
|
-
4 /* AliasType */,
|
|
61306
|
-
false,
|
|
61307
|
-
false
|
|
61308
|
-
);
|
|
61309
|
-
break;
|
|
61310
|
-
}
|
|
61311
|
-
default:
|
|
61312
|
-
Debug.never(parent);
|
|
61313
|
-
}
|
|
61314
|
-
}
|
|
61315
|
-
}
|
|
61316
|
-
checkAssumptionExpression(node) {
|
|
61317
|
-
const parent = node.getParentSkippingParenthesizedExpressions();
|
|
61318
|
-
switch (parent.kind) {
|
|
61319
|
-
case 73 /* MemberAccessExpression */:
|
|
61320
|
-
case 65 /* CallExpression */:
|
|
61321
|
-
case 67 /* IndexedAccessExpression */:
|
|
61322
|
-
case 75 /* DereferenceExpression */:
|
|
61323
|
-
break;
|
|
61324
|
-
default:
|
|
61325
|
-
this.createAndAddDiagnostic(
|
|
61326
|
-
2225 /* QuestionOperatorCanBeUsedOnlyInSpecificExpressions */,
|
|
61327
|
-
node.questionToken
|
|
61328
|
-
);
|
|
61329
|
-
}
|
|
61330
|
-
}
|
|
61331
|
-
checkStatementBlock(node) {
|
|
61332
|
-
const semanticContext = this.analyzer.semanticContext.ofStatementBlock(node);
|
|
61333
|
-
semanticContext.validateNameConflicts(this.diagnosticAcceptor);
|
|
61334
|
-
}
|
|
61335
|
-
checkFunctionBlock(node) {
|
|
61336
|
-
const semanticContext = this.analyzer.semanticContext.ofFunctionBlock(node);
|
|
61337
|
-
semanticContext.validateNameConflicts(this.diagnosticAcceptor);
|
|
61338
|
-
}
|
|
61339
61103
|
checkPackageStructuredTypeDeclaration(node, controller) {
|
|
61340
61104
|
return __async(this, null, function* () {
|
|
61341
61105
|
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(node);
|
|
@@ -61346,6 +61110,9 @@ var SourceFileAnalyzer = class {
|
|
|
61346
61110
|
if (node.typeParameterClause !== void 0) {
|
|
61347
61111
|
this.analyzer.semanticContext.ofTypeDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61348
61112
|
}
|
|
61113
|
+
if (node.extendsClause !== void 0) {
|
|
61114
|
+
this.checkAspectsHaveNotBeenExtendedWithDifferentTypeArguments(entity, node.extendsClause.baseTypeList, node.name);
|
|
61115
|
+
}
|
|
61349
61116
|
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61350
61117
|
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
61351
61118
|
const semanticContext = this.analyzer.semanticContext.outermostSemanticContextOfTypeDeclaration(node);
|
|
@@ -61585,6 +61352,805 @@ var SourceFileAnalyzer = class {
|
|
|
61585
61352
|
return result;
|
|
61586
61353
|
});
|
|
61587
61354
|
}
|
|
61355
|
+
checkAspectsHaveNotBeenExtendedWithDifferentTypeArguments(entity, baseTypeList, fallbackDiagnosticLocation) {
|
|
61356
|
+
const type = this.analyzer.instantiateTypeByIdentitySubstitution(entity);
|
|
61357
|
+
const baseAspectTypes = this.analyzer.typeUtils.getPossiblyAliasedBaseAspectTypes(type);
|
|
61358
|
+
if (baseAspectTypes !== void 0 && baseAspectTypes.length > 0) {
|
|
61359
|
+
let allBaseTypes;
|
|
61360
|
+
for (const baseAspectType of baseAspectTypes) {
|
|
61361
|
+
const unaliasedBaseAspectType = baseAspectType.unalias();
|
|
61362
|
+
if (unaliasedBaseAspectType.kind === "structured" && unaliasedBaseAspectType.getTypeParameters().length === 0) {
|
|
61363
|
+
continue;
|
|
61364
|
+
}
|
|
61365
|
+
allBaseTypes ??= this.analyzer.typeUtils.getBaseAndAliasedTypesRecursively(type);
|
|
61366
|
+
const extendedAspect = allBaseTypes.find((t) => t.kind === "structured" && t.getEntity().getOriginalEntity() === unaliasedBaseAspectType.getEntity()?.getOriginalEntity() && !t.getSubstitutions().equals(unaliasedBaseAspectType.getSubstitutions()));
|
|
61367
|
+
if (extendedAspect !== void 0) {
|
|
61368
|
+
const diagnosticLocation = baseTypeList.baseTypes.first((n) => this.analyzer.type.ofTypeSpecifier(n).equals(baseAspectType)) ?? fallbackDiagnosticLocation;
|
|
61369
|
+
this.createAndAddDiagnostic(
|
|
61370
|
+
2246 /* AspectHasAlreadyBeenExtendedWithDifferentTypeArguments0 */,
|
|
61371
|
+
diagnosticLocation,
|
|
61372
|
+
[this.diagnosticArgumentFactory.createDisplayableType(extendedAspect)]
|
|
61373
|
+
);
|
|
61374
|
+
}
|
|
61375
|
+
}
|
|
61376
|
+
}
|
|
61377
|
+
}
|
|
61378
|
+
checkPackageVariableDeclaration(node) {
|
|
61379
|
+
const entity = this.analyzer.entity.ofPackageVariableDeclaration(node);
|
|
61380
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61381
|
+
if (this.isInterfacePackageFile) {
|
|
61382
|
+
if (node.initializer !== void 0) {
|
|
61383
|
+
this.createAndAddDiagnostic(2061 /* InterfacePackageVariablesMustNotHaveInitializers */, node.name);
|
|
61384
|
+
}
|
|
61385
|
+
}
|
|
61386
|
+
if (node.typeAnnotation === void 0 && node.initializer === void 0) {
|
|
61387
|
+
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
61388
|
+
} else if (node.initializer !== void 0 && node.typeAnnotation !== void 0) {
|
|
61389
|
+
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61390
|
+
node.initializer,
|
|
61391
|
+
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
61392
|
+
);
|
|
61393
|
+
}
|
|
61394
|
+
}
|
|
61395
|
+
checkPackageFunctionDeclaration(node) {
|
|
61396
|
+
const entity = this.analyzer.entity.ofPackageFunctionDeclaration(node);
|
|
61397
|
+
this.checkPackageMemberBodyPresence(entity, node.block, node.name);
|
|
61398
|
+
if (node.block !== void 0) {
|
|
61399
|
+
this.checkPossibleGeneratorFunctionReturnType(entity, node, node.name);
|
|
61400
|
+
}
|
|
61401
|
+
if (node.typeParameterClause !== void 0) {
|
|
61402
|
+
this.analyzer.semanticContext.ofFunctionDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61403
|
+
}
|
|
61404
|
+
this.analyzer.semanticContext.ofFunctionDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61405
|
+
if (!this.analyzer.isFunctionGenerator(node)) {
|
|
61406
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61407
|
+
node,
|
|
61408
|
+
node.name,
|
|
61409
|
+
this.analyzer.returnType.ofPackageFunctionDeclaration(node),
|
|
61410
|
+
this.analyzer.resultLocalVariableEntity.ofPackageFunctionDeclaration(node)
|
|
61411
|
+
);
|
|
61412
|
+
}
|
|
61413
|
+
}
|
|
61414
|
+
checkPackageVariableGetterDeclaration(node) {
|
|
61415
|
+
const entity = this.analyzer.entity.ofComputedPackageVariableDeclaration(node);
|
|
61416
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61417
|
+
this.checkPackageMemberBodyPresence(entity, node.block, node.name);
|
|
61418
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61419
|
+
node,
|
|
61420
|
+
node.name,
|
|
61421
|
+
this.analyzer.returnType.ofPackageVariableGetterDeclaration(node),
|
|
61422
|
+
this.analyzer.resultLocalVariableEntity.ofPackageVariableGetterDeclaration(node)
|
|
61423
|
+
);
|
|
61424
|
+
}
|
|
61425
|
+
checkPackageVariableSetterDeclaration(node) {
|
|
61426
|
+
const entity = this.analyzer.entity.ofComputedPackageVariableDeclaration(node);
|
|
61427
|
+
this.checkPackageMemberBodyPresence(entity, node.block, node.name);
|
|
61428
|
+
}
|
|
61429
|
+
checkPackageMemberBodyPresence(entity, body, diagnosticLocation) {
|
|
61430
|
+
if (this.isInterfacePackageFile) {
|
|
61431
|
+
if (body !== void 0) {
|
|
61432
|
+
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, diagnosticLocation);
|
|
61433
|
+
}
|
|
61434
|
+
} else if (findTag(this.analyzer.originalWellKnownDeclarations.builtIntoPlatform, entity.getTags()) !== void 0) {
|
|
61435
|
+
if (body !== void 0) {
|
|
61436
|
+
this.createAndAddDiagnostic(
|
|
61437
|
+
2066 /* DeclarationsMarkedWithBuiltIntoPlatformTagMustNotHaveBody */,
|
|
61438
|
+
diagnosticLocation
|
|
61439
|
+
);
|
|
61440
|
+
}
|
|
61441
|
+
} else {
|
|
61442
|
+
if (body === void 0) {
|
|
61443
|
+
this.createAndAddDiagnostic(2062 /* BodyIsMissing */, diagnosticLocation);
|
|
61444
|
+
}
|
|
61445
|
+
}
|
|
61446
|
+
}
|
|
61447
|
+
checkTypeExtensionDeclaration(node) {
|
|
61448
|
+
const entity = this.analyzer.entity.ofTypeExtensionDeclaration(node);
|
|
61449
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61450
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61451
|
+
node.memberBlock.memberList,
|
|
61452
|
+
6 /* TypeExtension */,
|
|
61453
|
+
false,
|
|
61454
|
+
false
|
|
61455
|
+
);
|
|
61456
|
+
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61457
|
+
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
61458
|
+
}
|
|
61459
|
+
checkTypeMemberDeclarationBlock(node) {
|
|
61460
|
+
const parent = node.parent;
|
|
61461
|
+
if (isTypeDeclaration(parent)) {
|
|
61462
|
+
switch (parent.kind) {
|
|
61463
|
+
case 27 /* PackageClassDeclaration */: {
|
|
61464
|
+
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(parent);
|
|
61465
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61466
|
+
node.memberList,
|
|
61467
|
+
0 /* Class */,
|
|
61468
|
+
entity.isAbstract(),
|
|
61469
|
+
entity.markedBasic()
|
|
61470
|
+
);
|
|
61471
|
+
break;
|
|
61472
|
+
}
|
|
61473
|
+
case 28 /* PackageStructureDeclaration */: {
|
|
61474
|
+
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(parent);
|
|
61475
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61476
|
+
node.memberList,
|
|
61477
|
+
1 /* Structure */,
|
|
61478
|
+
entity.isAbstract(),
|
|
61479
|
+
entity.markedBasic()
|
|
61480
|
+
);
|
|
61481
|
+
break;
|
|
61482
|
+
}
|
|
61483
|
+
case 29 /* PackageAspectDeclaration */: {
|
|
61484
|
+
const entity = this.analyzer.entity.ofPackageStructuredTypeDeclaration(parent);
|
|
61485
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61486
|
+
node.memberList,
|
|
61487
|
+
2 /* Aspect */,
|
|
61488
|
+
entity.isAbstract(),
|
|
61489
|
+
entity.markedBasic()
|
|
61490
|
+
);
|
|
61491
|
+
break;
|
|
61492
|
+
}
|
|
61493
|
+
case 18 /* AnonymousClassDeclaration */: {
|
|
61494
|
+
const entity = this.analyzer.entity.ofAnonymousStructuredTypeDeclaration(parent);
|
|
61495
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61496
|
+
node.memberList,
|
|
61497
|
+
2 /* Aspect */,
|
|
61498
|
+
entity.isAbstract(),
|
|
61499
|
+
entity.markedBasic()
|
|
61500
|
+
);
|
|
61501
|
+
break;
|
|
61502
|
+
}
|
|
61503
|
+
case 30 /* PackageReducedTypeDeclaration */: {
|
|
61504
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61505
|
+
node.memberList,
|
|
61506
|
+
5 /* ReducedType */,
|
|
61507
|
+
false,
|
|
61508
|
+
false
|
|
61509
|
+
);
|
|
61510
|
+
break;
|
|
61511
|
+
}
|
|
61512
|
+
case 31 /* PackageVariantDeclaration */: {
|
|
61513
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61514
|
+
node.memberList,
|
|
61515
|
+
3 /* Variant */,
|
|
61516
|
+
false,
|
|
61517
|
+
false
|
|
61518
|
+
);
|
|
61519
|
+
break;
|
|
61520
|
+
}
|
|
61521
|
+
case 19 /* PackageAliasTypeDeclaration */: {
|
|
61522
|
+
this.modifierValidator.validateTopLevelTypeMembers(
|
|
61523
|
+
node.memberList,
|
|
61524
|
+
4 /* AliasType */,
|
|
61525
|
+
false,
|
|
61526
|
+
false
|
|
61527
|
+
);
|
|
61528
|
+
break;
|
|
61529
|
+
}
|
|
61530
|
+
default:
|
|
61531
|
+
Debug.never(parent);
|
|
61532
|
+
}
|
|
61533
|
+
}
|
|
61534
|
+
}
|
|
61535
|
+
checkConstructorDeclaration(node) {
|
|
61536
|
+
const entity = this.analyzer.entity.ofConstructorDeclaration(node);
|
|
61537
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61538
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.creationKeyword);
|
|
61539
|
+
this.analyzer.semanticContext.ofConstructorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61540
|
+
}
|
|
61541
|
+
checkDestructorDeclaration(node) {
|
|
61542
|
+
const entity = this.analyzer.entity.ofDestructorDeclaration(node);
|
|
61543
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61544
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.destructionKeyword);
|
|
61545
|
+
this.analyzer.semanticContext.ofDestructorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61546
|
+
}
|
|
61547
|
+
checkMethodDeclaration(node) {
|
|
61548
|
+
const entity = this.analyzer.entity.ofMethodDeclaration(node);
|
|
61549
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61550
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.name);
|
|
61551
|
+
if (node.block !== void 0) {
|
|
61552
|
+
this.checkPossibleGeneratorFunctionReturnType(entity, node, node.name);
|
|
61553
|
+
const containingEntity = entity.getContainingEntity();
|
|
61554
|
+
if (entity.markedBasic() && containingEntity.kind === 2 /* Type */ && containingEntity.typeEntityKind === 4 /* Alias */) {
|
|
61555
|
+
this.analyzer.checkBodyOfBasicAliasTypeMethod(node, this.diagnosticAcceptor);
|
|
61556
|
+
}
|
|
61557
|
+
}
|
|
61558
|
+
if (entity.methodKind === 3 /* Operator */) {
|
|
61559
|
+
if (node.typeParameterClause !== void 0) {
|
|
61560
|
+
this.createAndAddDiagnostic(
|
|
61561
|
+
2231 /* OperatorCannotContainTypeParameterDeclarations */,
|
|
61562
|
+
node.typeParameterClause
|
|
61563
|
+
);
|
|
61564
|
+
}
|
|
61565
|
+
const syntacticalOperatorKind = node.name.operatorKind;
|
|
61566
|
+
if (syntacticalOperatorKind !== void 0) {
|
|
61567
|
+
const requiredParameterCount = requiredParameterCountBySyntacticalOperatorKind[syntacticalOperatorKind];
|
|
61568
|
+
const actualParameterCount = node.parameterClause.parameterList.parameters.count();
|
|
61569
|
+
switch (requiredParameterCount) {
|
|
61570
|
+
case 0 /* Zero */: {
|
|
61571
|
+
if (actualParameterCount !== 0) {
|
|
61572
|
+
const operatorText = LocalizationHelperA.localizeSyntacticalOperatorKind(
|
|
61573
|
+
syntacticalOperatorKind,
|
|
61574
|
+
this.sourceFile.locale
|
|
61575
|
+
);
|
|
61576
|
+
this.createAndAddDiagnostic(
|
|
61577
|
+
2097 /* OperatorFunction0MustNotHaveParameters */,
|
|
61578
|
+
node.name,
|
|
61579
|
+
[operatorText]
|
|
61580
|
+
);
|
|
61581
|
+
}
|
|
61582
|
+
break;
|
|
61583
|
+
}
|
|
61584
|
+
case 1 /* ZeroOrOne */: {
|
|
61585
|
+
if (!(actualParameterCount === 0 || actualParameterCount === 1)) {
|
|
61586
|
+
const operatorText = LocalizationHelperA.localizeSyntacticalOperatorKind(
|
|
61587
|
+
syntacticalOperatorKind,
|
|
61588
|
+
this.sourceFile.locale
|
|
61589
|
+
);
|
|
61590
|
+
this.createAndAddDiagnostic(
|
|
61591
|
+
2099 /* OperatorFunction0MustHaveNoMoreThanOneParameter */,
|
|
61592
|
+
node.name,
|
|
61593
|
+
[operatorText]
|
|
61594
|
+
);
|
|
61595
|
+
}
|
|
61596
|
+
break;
|
|
61597
|
+
}
|
|
61598
|
+
case 2 /* One */: {
|
|
61599
|
+
if (actualParameterCount !== 1) {
|
|
61600
|
+
const operatorText = LocalizationHelperA.localizeSyntacticalOperatorKind(
|
|
61601
|
+
syntacticalOperatorKind,
|
|
61602
|
+
this.sourceFile.locale
|
|
61603
|
+
);
|
|
61604
|
+
this.createAndAddDiagnostic(
|
|
61605
|
+
2098 /* OperatorFunction0MustHaveOneParameter */,
|
|
61606
|
+
node.name,
|
|
61607
|
+
[operatorText]
|
|
61608
|
+
);
|
|
61609
|
+
}
|
|
61610
|
+
break;
|
|
61611
|
+
}
|
|
61612
|
+
default:
|
|
61613
|
+
Debug.never(requiredParameterCount);
|
|
61614
|
+
}
|
|
61615
|
+
}
|
|
61616
|
+
}
|
|
61617
|
+
if (node.typeParameterClause !== void 0) {
|
|
61618
|
+
this.analyzer.semanticContext.ofFunctionDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61619
|
+
}
|
|
61620
|
+
this.analyzer.semanticContext.ofFunctionDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61621
|
+
if (!this.analyzer.isFunctionGenerator(node)) {
|
|
61622
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61623
|
+
node,
|
|
61624
|
+
node.name,
|
|
61625
|
+
this.analyzer.returnType.ofMethodDeclaration(node),
|
|
61626
|
+
this.analyzer.resultLocalVariableEntity.ofMethodDeclaration(node)
|
|
61627
|
+
);
|
|
61628
|
+
}
|
|
61629
|
+
}
|
|
61630
|
+
checkFieldDeclaration(node) {
|
|
61631
|
+
const entity = this.analyzer.entity.ofFieldDeclaration(node);
|
|
61632
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61633
|
+
if (TypeMemberEntity.isAspectMember(entity) && !entity.isStatic() && !entity.markedAbstract()) {
|
|
61634
|
+
this.createAndAddDiagnostic(2065 /* AspectTypeFieldsMustBeAbstract */, node.name);
|
|
61635
|
+
}
|
|
61636
|
+
if (this.isInterfacePackageFile) {
|
|
61637
|
+
if (node.initializer !== void 0) {
|
|
61638
|
+
this.createAndAddDiagnostic(2061 /* InterfacePackageVariablesMustNotHaveInitializers */, node.name);
|
|
61639
|
+
}
|
|
61640
|
+
} else if (TypeMemberEntity.isReducedTypeMember(entity)) {
|
|
61641
|
+
if (node.initializer !== void 0) {
|
|
61642
|
+
this.createAndAddDiagnostic(2069 /* ReducedTypeFieldsMustNotHaveInitializers */, node.name);
|
|
61643
|
+
}
|
|
61644
|
+
} else if (entity.markedAbstract()) {
|
|
61645
|
+
if (node.initializer !== void 0) {
|
|
61646
|
+
this.createAndAddDiagnostic(2068 /* AbstractFieldsMustNotHaveInitializers */, node.name);
|
|
61647
|
+
}
|
|
61648
|
+
}
|
|
61649
|
+
if (node.typeAnnotation === void 0 && node.initializer === void 0) {
|
|
61650
|
+
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
61651
|
+
} else if (node.initializer !== void 0 && node.typeAnnotation !== void 0) {
|
|
61652
|
+
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61653
|
+
node.initializer,
|
|
61654
|
+
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
61655
|
+
);
|
|
61656
|
+
}
|
|
61657
|
+
}
|
|
61658
|
+
checkFieldGetterDeclaration(node) {
|
|
61659
|
+
const entity = this.analyzer.entity.ofComputedFieldDeclaration(node);
|
|
61660
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61661
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.name);
|
|
61662
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61663
|
+
node,
|
|
61664
|
+
node.name,
|
|
61665
|
+
this.analyzer.returnType.ofFieldGetterDeclaration(node),
|
|
61666
|
+
this.analyzer.resultLocalVariableEntity.ofFieldGetterDeclaration(node)
|
|
61667
|
+
);
|
|
61668
|
+
}
|
|
61669
|
+
checkFieldSetterDeclaration(node) {
|
|
61670
|
+
const entity = this.analyzer.entity.ofComputedFieldDeclaration(node);
|
|
61671
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61672
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.name);
|
|
61673
|
+
}
|
|
61674
|
+
checkIndexedElementGetterDeclaration(node) {
|
|
61675
|
+
const entity = this.analyzer.entity.ofIndexerDeclaration(node);
|
|
61676
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61677
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.parameterClause);
|
|
61678
|
+
this.analyzer.semanticContext.ofIndexedElementAccessorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61679
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61680
|
+
node,
|
|
61681
|
+
node.parameterClause,
|
|
61682
|
+
this.analyzer.returnType.ofIndexedElementGetterDeclaration(node),
|
|
61683
|
+
this.analyzer.resultLocalVariableEntity.ofIndexedElementGetterDeclaration(node)
|
|
61684
|
+
);
|
|
61685
|
+
}
|
|
61686
|
+
checkIndexedElementSetterDeclaration(node) {
|
|
61687
|
+
const entity = this.analyzer.entity.ofIndexerDeclaration(node);
|
|
61688
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61689
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.parameterClause);
|
|
61690
|
+
this.analyzer.semanticContext.ofIndexedElementAccessorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61691
|
+
}
|
|
61692
|
+
checkDereferencedVariableGetterDeclaration(node) {
|
|
61693
|
+
const entity = this.analyzer.entity.ofDereferenceOperatorDeclaration(node);
|
|
61694
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61695
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.caretToken);
|
|
61696
|
+
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61697
|
+
node,
|
|
61698
|
+
node.caretToken,
|
|
61699
|
+
this.analyzer.returnType.ofDereferencedVariableGetterDeclaration(node),
|
|
61700
|
+
this.analyzer.resultLocalVariableEntity.ofDereferencedVariableGetterDeclaration(node)
|
|
61701
|
+
);
|
|
61702
|
+
}
|
|
61703
|
+
checkDereferencedVariableSetterDeclaration(node) {
|
|
61704
|
+
const entity = this.analyzer.entity.ofDereferenceOperatorDeclaration(node);
|
|
61705
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61706
|
+
this.checkTypeMemberBodyPresence(entity, node.block, node.caretToken);
|
|
61707
|
+
}
|
|
61708
|
+
checkTypeMemberBodyPresence(entity, body, diagnosticLocation) {
|
|
61709
|
+
if (this.isInterfacePackageFile) {
|
|
61710
|
+
if (body !== void 0) {
|
|
61711
|
+
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, diagnosticLocation);
|
|
61712
|
+
}
|
|
61713
|
+
} else if (findTag(this.analyzer.originalWellKnownDeclarations.builtIntoPlatform, entity.getTags()) !== void 0) {
|
|
61714
|
+
if (body !== void 0) {
|
|
61715
|
+
this.createAndAddDiagnostic(
|
|
61716
|
+
2066 /* DeclarationsMarkedWithBuiltIntoPlatformTagMustNotHaveBody */,
|
|
61717
|
+
diagnosticLocation
|
|
61718
|
+
);
|
|
61719
|
+
}
|
|
61720
|
+
} else if (TypeMemberEntity.isReducedTypeMember(entity)) {
|
|
61721
|
+
if (body !== void 0) {
|
|
61722
|
+
this.createAndAddDiagnostic(
|
|
61723
|
+
2067 /* ReducedTypeMembersMustNotHaveBody */,
|
|
61724
|
+
diagnosticLocation
|
|
61725
|
+
);
|
|
61726
|
+
}
|
|
61727
|
+
} else if (entity.isStatic()) {
|
|
61728
|
+
if (body === void 0) {
|
|
61729
|
+
this.createAndAddDiagnostic(2062 /* BodyIsMissing */, diagnosticLocation);
|
|
61730
|
+
}
|
|
61731
|
+
} else if (entity.markedAbstract()) {
|
|
61732
|
+
if (body !== void 0) {
|
|
61733
|
+
this.createAndAddDiagnostic(
|
|
61734
|
+
2063 /* AbstractTypeMembersMustNotHaveBody */,
|
|
61735
|
+
diagnosticLocation
|
|
61736
|
+
);
|
|
61737
|
+
}
|
|
61738
|
+
} else {
|
|
61739
|
+
if (body === void 0) {
|
|
61740
|
+
this.createAndAddDiagnostic(2062 /* BodyIsMissing */, diagnosticLocation);
|
|
61741
|
+
}
|
|
61742
|
+
}
|
|
61743
|
+
}
|
|
61744
|
+
checkTypeParameterList(node) {
|
|
61745
|
+
const typeParameterDeclarations = node.typeParameters.toArray();
|
|
61746
|
+
if (typeParameterDeclarations.some((d) => d.defaultType !== void 0)) {
|
|
61747
|
+
const notYetDeclaredParameters = /* @__PURE__ */ new Set();
|
|
61748
|
+
for (const typeParameterDeclaration of typeParameterDeclarations) {
|
|
61749
|
+
notYetDeclaredParameters.add(this.analyzer.entity.ofTypeParameterDeclaration(typeParameterDeclaration));
|
|
61750
|
+
}
|
|
61751
|
+
const visitor = (node2) => {
|
|
61752
|
+
if (node2.kind === 26 /* TypeMemberDeclarationBlock */) {
|
|
61753
|
+
return;
|
|
61754
|
+
}
|
|
61755
|
+
if (node2.kind === 10 /* NamedTypeSpecifier */) {
|
|
61756
|
+
const type = this.analyzer.resolveNamedTypeSpecifier(node2).type;
|
|
61757
|
+
if (type?.kind === "parameter" && notYetDeclaredParameters.has(type.getEntity().getOriginalEntity())) {
|
|
61758
|
+
this.createAndAddDiagnostic(
|
|
61759
|
+
2186 /* TypeParameterDefaultCanReferenceOnlyPreviouslyDeclaredTypeParameters */,
|
|
61760
|
+
node2
|
|
61761
|
+
);
|
|
61762
|
+
}
|
|
61763
|
+
}
|
|
61764
|
+
forEachChild(node2, false, visitor);
|
|
61765
|
+
};
|
|
61766
|
+
for (const typeParameterDeclaration of typeParameterDeclarations) {
|
|
61767
|
+
if (typeParameterDeclaration.defaultType !== void 0) {
|
|
61768
|
+
visitor(typeParameterDeclaration.defaultType);
|
|
61769
|
+
}
|
|
61770
|
+
notYetDeclaredParameters.delete(this.analyzer.entity.ofTypeParameterDeclaration(typeParameterDeclaration));
|
|
61771
|
+
}
|
|
61772
|
+
}
|
|
61773
|
+
let seenOptionalTypeParameter = false;
|
|
61774
|
+
for (const typeParameterDeclaration of typeParameterDeclarations) {
|
|
61775
|
+
if (typeParameterDeclaration.defaultType !== void 0) {
|
|
61776
|
+
seenOptionalTypeParameter = true;
|
|
61777
|
+
} else if (seenOptionalTypeParameter) {
|
|
61778
|
+
this.createAndAddDiagnostic(
|
|
61779
|
+
2187 /* RequiredTypeParametersCannotFollowTypeParametersWithDefaults */,
|
|
61780
|
+
typeParameterDeclaration
|
|
61781
|
+
);
|
|
61782
|
+
break;
|
|
61783
|
+
}
|
|
61784
|
+
}
|
|
61785
|
+
}
|
|
61786
|
+
checkTypeParameterDeclaration(node) {
|
|
61787
|
+
const entity = this.analyzer.entity.ofTypeParameterDeclaration(node);
|
|
61788
|
+
const constraint = entity.getConstraint();
|
|
61789
|
+
if (constraint.causesCycle) {
|
|
61790
|
+
this.createAndAddDiagnostic(2082 /* TypeParameterHasCircularConstraint */, node.name);
|
|
61791
|
+
}
|
|
61792
|
+
if (constraint.cycleFree !== void 0) {
|
|
61793
|
+
const defaultType = entity.getDefaultType();
|
|
61794
|
+
if (defaultType !== void 0 && !this.analyzer.isTypeAssignableTo(defaultType, constraint.cycleFree)) {
|
|
61795
|
+
this.addTypeAssignabilityDiagnosticIfBothTypesResolved(
|
|
61796
|
+
defaultType,
|
|
61797
|
+
constraint.cycleFree,
|
|
61798
|
+
node.defaultType ?? node,
|
|
61799
|
+
2087 /* Type0IsNotAssignableToConstraint1 */
|
|
61800
|
+
);
|
|
61801
|
+
}
|
|
61802
|
+
}
|
|
61803
|
+
this.checkIfTypeParameterIsUnused(entity, node.name);
|
|
61804
|
+
}
|
|
61805
|
+
checkNamedTypeSpecifier(node) {
|
|
61806
|
+
const resolutionResult = this.analyzer.resolveNamedTypeSpecifier(node);
|
|
61807
|
+
if (resolutionResult.type !== void 0) {
|
|
61808
|
+
const entity = resolutionResult.type.getEntity();
|
|
61809
|
+
if (entity !== void 0) {
|
|
61810
|
+
const typeArgumentCount = node.typeArgumentClause?.typeArgumentList.typeArguments.count() ?? 0;
|
|
61811
|
+
this.analyzer.checkTypeArgumentCount(
|
|
61812
|
+
typeArgumentCount,
|
|
61813
|
+
entity.getTypeParameters(),
|
|
61814
|
+
this.diagnosticAcceptor,
|
|
61815
|
+
node.typeArgumentClause ?? node.qualifiedName
|
|
61816
|
+
);
|
|
61817
|
+
const substitutions = resolutionResult.type.getSubstitutions();
|
|
61818
|
+
this.checkTypeArgumentTypesAreAssignableToConstraints(
|
|
61819
|
+
entity.getTypeParameters(),
|
|
61820
|
+
substitutions,
|
|
61821
|
+
void 0,
|
|
61822
|
+
node.typeArgumentClause ?? node
|
|
61823
|
+
);
|
|
61824
|
+
}
|
|
61825
|
+
}
|
|
61826
|
+
}
|
|
61827
|
+
checkAnonymousClassDeclaration(node) {
|
|
61828
|
+
const entity = this.analyzer.entity.ofAnonymousStructuredTypeDeclaration(node);
|
|
61829
|
+
if (node.extendsClause !== void 0) {
|
|
61830
|
+
this.checkAspectsHaveNotBeenExtendedWithDifferentTypeArguments(
|
|
61831
|
+
entity,
|
|
61832
|
+
node.extendsClause.baseTypeList,
|
|
61833
|
+
node.classKeyword
|
|
61834
|
+
);
|
|
61835
|
+
}
|
|
61836
|
+
this.overrideChecker.checkMembers(entity.getMembers());
|
|
61837
|
+
new TypeMemberConflictsValidator(this.analyzer, entity.getMembers(), this.diagnosticAcceptor).validate();
|
|
61838
|
+
const semanticContext = this.analyzer.semanticContext.outermostSemanticContextOfTypeDeclaration(node);
|
|
61839
|
+
new BaseMemberConflictsValidator(
|
|
61840
|
+
this.analyzer,
|
|
61841
|
+
entity,
|
|
61842
|
+
semanticContext.getDiagnosticArgumentFactory(),
|
|
61843
|
+
this.diagnosticAcceptor,
|
|
61844
|
+
node.classKeyword
|
|
61845
|
+
).validate();
|
|
61846
|
+
const typeMemberImplementationCheckResult = this.analyzer.getTypeMemberImplementationCheckResult(entity);
|
|
61847
|
+
this.attachNodeLocationAndAddDiagnostics(
|
|
61848
|
+
typeMemberImplementationCheckResult.diagnosticsData,
|
|
61849
|
+
node.classKeyword
|
|
61850
|
+
);
|
|
61851
|
+
if (!this.isInterfacePackageFile) {
|
|
61852
|
+
this.addDiagnostics(this.analyzer.getOwnAndBaseConstructorCallsCheckResult(node).diagnostics);
|
|
61853
|
+
new InstanceFieldsInitializationValidator(
|
|
61854
|
+
this.analyzer,
|
|
61855
|
+
node,
|
|
61856
|
+
this.namedDeclarationsUsageMap,
|
|
61857
|
+
this.diagnosticAcceptor
|
|
61858
|
+
).validate();
|
|
61859
|
+
}
|
|
61860
|
+
}
|
|
61861
|
+
checkAnonymousFunctionTypeDeclaration(node) {
|
|
61862
|
+
this.analyzer.semanticContext.ofFunctionTypeDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61863
|
+
}
|
|
61864
|
+
checkParameterList(node) {
|
|
61865
|
+
const parameters = node.parameters.toArray();
|
|
61866
|
+
if (parameters.length > 0) {
|
|
61867
|
+
this.checkRequiredParametersDoNotFollowOptionalParameters(parameters);
|
|
61868
|
+
const firstParameter = parameters[0];
|
|
61869
|
+
const firstParameterEntity = this.analyzer.entity.ofParameterDeclaration(firstParameter);
|
|
61870
|
+
if (firstParameterEntity.isObjectParameter() && !this.parameterListCanDeclareObjectParameter(node)) {
|
|
61871
|
+
this.createAndAddDiagnostic(2228 /* ObjectParameterCannotBeDeclaredHere */, firstParameter.name);
|
|
61872
|
+
}
|
|
61873
|
+
this.checkObjectParameterIsTheFirstParameter(parameters);
|
|
61874
|
+
}
|
|
61875
|
+
}
|
|
61876
|
+
checkRequiredParametersDoNotFollowOptionalParameters(parameters) {
|
|
61877
|
+
let seenOptionalParameter = false;
|
|
61878
|
+
for (const parameter of parameters) {
|
|
61879
|
+
if (parameter.defaultValue !== void 0) {
|
|
61880
|
+
seenOptionalParameter = true;
|
|
61881
|
+
} else if (seenOptionalParameter) {
|
|
61882
|
+
this.createAndAddDiagnostic(2188 /* RequiredParametersCannotFollowOptionalParameters */, parameter.name);
|
|
61883
|
+
break;
|
|
61884
|
+
}
|
|
61885
|
+
}
|
|
61886
|
+
}
|
|
61887
|
+
parameterListCanDeclareObjectParameter(node) {
|
|
61888
|
+
const parent = node.parent.parent;
|
|
61889
|
+
switch (parent.kind) {
|
|
61890
|
+
case 17 /* AnonymousFunctionTypeDeclaration */:
|
|
61891
|
+
case 23 /* PackageFunctionDeclaration */:
|
|
61892
|
+
case 53 /* NestedFunctionDeclaration */:
|
|
61893
|
+
case 62 /* FunctionLiteral */:
|
|
61894
|
+
return true;
|
|
61895
|
+
case 47 /* MethodDeclaration */: {
|
|
61896
|
+
const containingDeclaration = TypeMemberQuery.getContainingDeclaration(parent);
|
|
61897
|
+
switch (containingDeclaration.kind) {
|
|
61898
|
+
case 18 /* AnonymousClassDeclaration */:
|
|
61899
|
+
case 27 /* PackageClassDeclaration */:
|
|
61900
|
+
case 28 /* PackageStructureDeclaration */:
|
|
61901
|
+
case 29 /* PackageAspectDeclaration */:
|
|
61902
|
+
case 30 /* PackageReducedTypeDeclaration */:
|
|
61903
|
+
case 31 /* PackageVariantDeclaration */:
|
|
61904
|
+
return true;
|
|
61905
|
+
case 19 /* PackageAliasTypeDeclaration */:
|
|
61906
|
+
case 35 /* TypeExtensionDeclaration */:
|
|
61907
|
+
return false;
|
|
61908
|
+
default:
|
|
61909
|
+
Debug.never(containingDeclaration);
|
|
61910
|
+
}
|
|
61911
|
+
}
|
|
61912
|
+
case 40 /* ConstructorDeclaration */:
|
|
61913
|
+
case 41 /* DestructorDeclaration */:
|
|
61914
|
+
case 42 /* IndexedElementGetterDeclaration */:
|
|
61915
|
+
case 43 /* IndexedElementSetterDeclaration */:
|
|
61916
|
+
return false;
|
|
61917
|
+
default:
|
|
61918
|
+
Debug.never(parent);
|
|
61919
|
+
}
|
|
61920
|
+
}
|
|
61921
|
+
checkObjectParameterIsTheFirstParameter(parameters) {
|
|
61922
|
+
for (let i = 1; i < parameters.length; i++) {
|
|
61923
|
+
const parameterDeclaration2 = parameters[i];
|
|
61924
|
+
if ((parameterDeclaration2.name.flags & 512 /* ObjectParameterName */) !== 0) {
|
|
61925
|
+
this.createAndAddDiagnostic(2227 /* ObjectParameterMustBeTheFirstParameter */, parameterDeclaration2.name);
|
|
61926
|
+
break;
|
|
61927
|
+
}
|
|
61928
|
+
}
|
|
61929
|
+
}
|
|
61930
|
+
checkParameterDeclaration(node) {
|
|
61931
|
+
const entity = this.analyzer.entity.ofParameterDeclaration(node);
|
|
61932
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
61933
|
+
const isFunctionLiteralParameter = node.parent.parent.parent.kind === 62 /* FunctionLiteral */;
|
|
61934
|
+
if (!isFunctionLiteralParameter && node.typeAnnotation === void 0 && node.defaultValue === void 0) {
|
|
61935
|
+
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
61936
|
+
} else if (node.defaultValue !== void 0 && node.typeAnnotation !== void 0) {
|
|
61937
|
+
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61938
|
+
node.defaultValue,
|
|
61939
|
+
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
61940
|
+
);
|
|
61941
|
+
} else if (isFunctionLiteralParameter && node.defaultValue !== void 0) {
|
|
61942
|
+
this.checkExpressionTypeIsAssignableToTargetType(node.defaultValue, entity.getType());
|
|
61943
|
+
}
|
|
61944
|
+
let parentHasBody;
|
|
61945
|
+
const parent = node.parent.parent.parent;
|
|
61946
|
+
switch (parent.kind) {
|
|
61947
|
+
case 23 /* PackageFunctionDeclaration */:
|
|
61948
|
+
case 40 /* ConstructorDeclaration */:
|
|
61949
|
+
case 41 /* DestructorDeclaration */:
|
|
61950
|
+
case 42 /* IndexedElementGetterDeclaration */:
|
|
61951
|
+
case 43 /* IndexedElementSetterDeclaration */:
|
|
61952
|
+
case 47 /* MethodDeclaration */:
|
|
61953
|
+
case 53 /* NestedFunctionDeclaration */:
|
|
61954
|
+
case 62 /* FunctionLiteral */:
|
|
61955
|
+
parentHasBody = parent.block !== void 0;
|
|
61956
|
+
break;
|
|
61957
|
+
case 17 /* AnonymousFunctionTypeDeclaration */:
|
|
61958
|
+
parentHasBody = false;
|
|
61959
|
+
break;
|
|
61960
|
+
default:
|
|
61961
|
+
Debug.never(parent);
|
|
61962
|
+
}
|
|
61963
|
+
if (parentHasBody) {
|
|
61964
|
+
this.checkIfVariableIsUnused(entity, node.name);
|
|
61965
|
+
}
|
|
61966
|
+
}
|
|
61967
|
+
checkOwnConstructorCallExpression(node) {
|
|
61968
|
+
this.analyzer.resolveOwnConstructorCallExpression(node);
|
|
61969
|
+
}
|
|
61970
|
+
checkReferenceExpression(node) {
|
|
61971
|
+
if (!this.analyzer.expressionCanBeReferenced(node.expression)) {
|
|
61972
|
+
this.createAndAddDiagnostic(2189 /* ExpressionCannotBeReferenced */, node.expression);
|
|
61973
|
+
}
|
|
61974
|
+
}
|
|
61975
|
+
checkMatchExpressionList(node) {
|
|
61976
|
+
const matchedExpressionType = this.analyzer.type.ofExpression(node.parent.parent.parent.expression);
|
|
61977
|
+
for (const expression of node.matchExpressions) {
|
|
61978
|
+
this.checkExpressionTypeIsAssignableToTargetType(expression, matchedExpressionType);
|
|
61979
|
+
}
|
|
61980
|
+
}
|
|
61981
|
+
checkWhileStatement(node) {
|
|
61982
|
+
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
61983
|
+
}
|
|
61984
|
+
checkLoopStatement(node) {
|
|
61985
|
+
if (node.condition !== void 0) {
|
|
61986
|
+
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
61987
|
+
}
|
|
61988
|
+
}
|
|
61989
|
+
checkElseIfClause(node) {
|
|
61990
|
+
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
61991
|
+
}
|
|
61992
|
+
checkIfStatement(node) {
|
|
61993
|
+
this.checkExpressionTypeIsAssignableToTargetType(node.condition, this.standardTypes.yesNo);
|
|
61994
|
+
}
|
|
61995
|
+
checkArgument(node) {
|
|
61996
|
+
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61997
|
+
node.value,
|
|
61998
|
+
this.analyzer.getTargetTypeOfExpression(node.value)
|
|
61999
|
+
);
|
|
62000
|
+
}
|
|
62001
|
+
checkErrorVariableDeclaration(node) {
|
|
62002
|
+
const entity = this.analyzer.entity.ofErrorVariableDeclaration(node);
|
|
62003
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
62004
|
+
this.checkIfVariableIsUnused(entity, node.name);
|
|
62005
|
+
}
|
|
62006
|
+
checkForStatementVariableDeclaration(node) {
|
|
62007
|
+
const entity = this.analyzer.entity.ofForStatementVariableDeclaration(node);
|
|
62008
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
62009
|
+
this.checkIfVariableIsUnused(entity, node.name);
|
|
62010
|
+
}
|
|
62011
|
+
checkLocalVariableDeclaration(node) {
|
|
62012
|
+
const entity = this.analyzer.entity.ofLocalVariableDeclaration(node);
|
|
62013
|
+
entity.ensureAllDiagnosticsReported?.();
|
|
62014
|
+
if (node.typeAnnotation === void 0 && node.initializer === void 0) {
|
|
62015
|
+
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
62016
|
+
} else if (node.initializer !== void 0 && node.typeAnnotation !== void 0) {
|
|
62017
|
+
this.checkExpressionTypeIsAssignableToTargetType(
|
|
62018
|
+
node.initializer,
|
|
62019
|
+
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
62020
|
+
);
|
|
62021
|
+
}
|
|
62022
|
+
this.checkIfVariableIsUnused(entity, node.name);
|
|
62023
|
+
}
|
|
62024
|
+
checkBaseExpression(node) {
|
|
62025
|
+
const meaning = this.analyzer.resolveBaseExpression(node);
|
|
62026
|
+
if (meaning.kind === "base-object-access") {
|
|
62027
|
+
let parent = node.getParentSkippingParenthesizedExpressions();
|
|
62028
|
+
if (parent.kind === 60 /* AsExpression */) {
|
|
62029
|
+
parent = parent.getParentSkippingParenthesizedExpressions();
|
|
62030
|
+
}
|
|
62031
|
+
if (!(parent.kind === 73 /* MemberAccessExpression */ || parent.kind === 67 /* IndexedAccessExpression */ || parent.kind === 75 /* DereferenceExpression */)) {
|
|
62032
|
+
this.createAndAddDiagnostic(2059 /* BaseCannotBeUsedAsAnExpressionInItself */, node);
|
|
62033
|
+
}
|
|
62034
|
+
} else if (meaning.kind === "overridden-method-access" && meaning.method.kind === "substituted-function") {
|
|
62035
|
+
const typeArgumentClause = getParentGenericSpecializationExpression(node)?.typeArgumentClause;
|
|
62036
|
+
this.checkTypeArgumentTypesAreAssignableToConstraints(
|
|
62037
|
+
meaning.method.getTypeParameters(),
|
|
62038
|
+
meaning.method.value.getSubstitutions(),
|
|
62039
|
+
meaning.method.value.getOuterSubstitutions(),
|
|
62040
|
+
typeArgumentClause ?? node
|
|
62041
|
+
);
|
|
62042
|
+
}
|
|
62043
|
+
}
|
|
62044
|
+
checkObjectExpression(node) {
|
|
62045
|
+
this.analyzer.resolveObjectExpression(node);
|
|
62046
|
+
}
|
|
62047
|
+
checkAssignmentStatement(node) {
|
|
62048
|
+
if (this.checkAssignmentIsValid(node)) {
|
|
62049
|
+
if (node.operator.tokenKind === 64 /* Equals */) {
|
|
62050
|
+
this.checkExpressionTypeIsAssignableToTargetType(node.right, this.analyzer.type.ofExpression(node.left));
|
|
62051
|
+
}
|
|
62052
|
+
}
|
|
62053
|
+
const operatorKind = this.analyzer.getBinaryOperatorKindIfCompoundAssignmentOperator(node.operator);
|
|
62054
|
+
if (operatorKind !== void 0) {
|
|
62055
|
+
const operator = this.analyzer.resolveCompoundAssignmentStatementOperator(node, operatorKind);
|
|
62056
|
+
if (operator !== void 0) {
|
|
62057
|
+
const returnType = operator.getReturnType();
|
|
62058
|
+
const leftType = this.analyzer.type.ofExpression(node.left);
|
|
62059
|
+
if (!this.analyzer.isTypeAssignableTo(returnType, leftType)) {
|
|
62060
|
+
this.addTypeAssignabilityDiagnosticIfBothTypesResolved(
|
|
62061
|
+
returnType,
|
|
62062
|
+
leftType,
|
|
62063
|
+
node.right,
|
|
62064
|
+
2032 /* Type0IsNotAssignableToType1 */
|
|
62065
|
+
);
|
|
62066
|
+
}
|
|
62067
|
+
}
|
|
62068
|
+
}
|
|
62069
|
+
}
|
|
62070
|
+
checkPrefixUnaryExpression(node) {
|
|
62071
|
+
this.analyzer.resolvePrefixUnaryExpressionUserDefinableOperator(node);
|
|
62072
|
+
}
|
|
62073
|
+
checkCatchClause(node) {
|
|
62074
|
+
this.analyzer.semanticContext.ofCatchClause(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
62075
|
+
}
|
|
62076
|
+
checkForStatement(node) {
|
|
62077
|
+
const checkResult = this.analyzer.checkExpressionCanBeUsedInForLoop(node.enumeratedExpression);
|
|
62078
|
+
if (checkResult.kind === "error") {
|
|
62079
|
+
this.addDiagnostics(checkResult.value);
|
|
62080
|
+
}
|
|
62081
|
+
this.analyzer.semanticContext.ofForStatement(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
62082
|
+
}
|
|
62083
|
+
checkLocalizableTextTemplateLiteral(node) {
|
|
62084
|
+
const resolved = this.analyzer.resolveLocalizableTextOrTextTemplate(node);
|
|
62085
|
+
if (resolved !== void 0) {
|
|
62086
|
+
const spans = node.spanList.spans;
|
|
62087
|
+
const parameters = resolved.getParameters();
|
|
62088
|
+
if (spans.length === parameters.length) {
|
|
62089
|
+
for (let i = 0; i < spans.length; i++) {
|
|
62090
|
+
const argument2 = spans[i].expression;
|
|
62091
|
+
const parameter = parameters[i];
|
|
62092
|
+
this.checkExpressionTypeIsAssignableToTargetType(argument2, parameter.getType());
|
|
62093
|
+
}
|
|
62094
|
+
}
|
|
62095
|
+
}
|
|
62096
|
+
}
|
|
62097
|
+
checkLocalizableTextLiteral(node) {
|
|
62098
|
+
this.analyzer.resolveLocalizableTextOrTextTemplate(node);
|
|
62099
|
+
}
|
|
62100
|
+
checkAutotypeCallExpression(node) {
|
|
62101
|
+
this.analyzer.resolveAutotypeCallExpression(node);
|
|
62102
|
+
}
|
|
62103
|
+
checkBinaryExpression(node) {
|
|
62104
|
+
const classificationResult = this.analyzer.classifyBinaryExpressionOperator(node.operator);
|
|
62105
|
+
switch (classificationResult.kind) {
|
|
62106
|
+
case "user-definable":
|
|
62107
|
+
this.analyzer.resolveBinaryExpressionUserDefinableOperator(node, classificationResult.operatorKind);
|
|
62108
|
+
break;
|
|
62109
|
+
case "equals":
|
|
62110
|
+
case "not-equals": {
|
|
62111
|
+
const leftType = this.analyzer.type.ofExpression(node.left);
|
|
62112
|
+
const rightType = this.analyzer.type.ofExpression(node.right);
|
|
62113
|
+
if (!this.analyzer.expressionsOfTypesCanBeCompared(leftType, rightType)) {
|
|
62114
|
+
this.createAndAddDiagnostic(
|
|
62115
|
+
2233 /* ExpressionsWithTypes0And1CannotBeCompared */,
|
|
62116
|
+
node.operator,
|
|
62117
|
+
[
|
|
62118
|
+
this.diagnosticArgumentFactory.createDisplayableType(leftType),
|
|
62119
|
+
this.diagnosticArgumentFactory.createDisplayableType(rightType)
|
|
62120
|
+
]
|
|
62121
|
+
);
|
|
62122
|
+
}
|
|
62123
|
+
break;
|
|
62124
|
+
}
|
|
62125
|
+
case "question-question":
|
|
62126
|
+
break;
|
|
62127
|
+
default:
|
|
62128
|
+
Debug.never(classificationResult);
|
|
62129
|
+
}
|
|
62130
|
+
}
|
|
62131
|
+
checkAssumptionExpression(node) {
|
|
62132
|
+
const parent = node.getParentSkippingParenthesizedExpressions();
|
|
62133
|
+
switch (parent.kind) {
|
|
62134
|
+
case 73 /* MemberAccessExpression */:
|
|
62135
|
+
case 65 /* CallExpression */:
|
|
62136
|
+
case 67 /* IndexedAccessExpression */:
|
|
62137
|
+
case 75 /* DereferenceExpression */:
|
|
62138
|
+
break;
|
|
62139
|
+
default:
|
|
62140
|
+
this.createAndAddDiagnostic(
|
|
62141
|
+
2225 /* QuestionOperatorCanBeUsedOnlyInSpecificExpressions */,
|
|
62142
|
+
node.questionToken
|
|
62143
|
+
);
|
|
62144
|
+
}
|
|
62145
|
+
}
|
|
62146
|
+
checkStatementBlock(node) {
|
|
62147
|
+
const semanticContext = this.analyzer.semanticContext.ofStatementBlock(node);
|
|
62148
|
+
semanticContext.validateNameConflicts(this.diagnosticAcceptor);
|
|
62149
|
+
}
|
|
62150
|
+
checkFunctionBlock(node) {
|
|
62151
|
+
const semanticContext = this.analyzer.semanticContext.ofFunctionBlock(node);
|
|
62152
|
+
semanticContext.validateNameConflicts(this.diagnosticAcceptor);
|
|
62153
|
+
}
|
|
61588
62154
|
checkErrorStatement(node) {
|
|
61589
62155
|
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61590
62156
|
node.expression,
|
|
@@ -61670,67 +62236,6 @@ var SourceFileAnalyzer = class {
|
|
|
61670
62236
|
}
|
|
61671
62237
|
return { isUsedInsideLoop, isUsedInsideFinallyBlock };
|
|
61672
62238
|
}
|
|
61673
|
-
checkTypeParameterList(node) {
|
|
61674
|
-
const typeParameterDeclarations = node.typeParameters.toArray();
|
|
61675
|
-
if (typeParameterDeclarations.some((d) => d.defaultType !== void 0)) {
|
|
61676
|
-
const notYetDeclaredParameters = /* @__PURE__ */ new Set();
|
|
61677
|
-
for (const typeParameterDeclaration of typeParameterDeclarations) {
|
|
61678
|
-
notYetDeclaredParameters.add(this.analyzer.entity.ofTypeParameterDeclaration(typeParameterDeclaration));
|
|
61679
|
-
}
|
|
61680
|
-
const visitor = (node2) => {
|
|
61681
|
-
if (node2.kind === 26 /* TypeMemberDeclarationBlock */) {
|
|
61682
|
-
return;
|
|
61683
|
-
}
|
|
61684
|
-
if (node2.kind === 10 /* NamedTypeSpecifier */) {
|
|
61685
|
-
const type = this.analyzer.resolveNamedTypeSpecifier(node2).type;
|
|
61686
|
-
if (type?.kind === "parameter" && notYetDeclaredParameters.has(type.getEntity().getOriginalEntity())) {
|
|
61687
|
-
this.createAndAddDiagnostic(
|
|
61688
|
-
2186 /* TypeParameterDefaultCanReferenceOnlyPreviouslyDeclaredTypeParameters */,
|
|
61689
|
-
node2
|
|
61690
|
-
);
|
|
61691
|
-
}
|
|
61692
|
-
}
|
|
61693
|
-
forEachChild(node2, false, visitor);
|
|
61694
|
-
};
|
|
61695
|
-
for (const typeParameterDeclaration of typeParameterDeclarations) {
|
|
61696
|
-
if (typeParameterDeclaration.defaultType !== void 0) {
|
|
61697
|
-
visitor(typeParameterDeclaration.defaultType);
|
|
61698
|
-
}
|
|
61699
|
-
notYetDeclaredParameters.delete(this.analyzer.entity.ofTypeParameterDeclaration(typeParameterDeclaration));
|
|
61700
|
-
}
|
|
61701
|
-
}
|
|
61702
|
-
let seenOptionalTypeParameter = false;
|
|
61703
|
-
for (const typeParameterDeclaration of typeParameterDeclarations) {
|
|
61704
|
-
if (typeParameterDeclaration.defaultType !== void 0) {
|
|
61705
|
-
seenOptionalTypeParameter = true;
|
|
61706
|
-
} else if (seenOptionalTypeParameter) {
|
|
61707
|
-
this.createAndAddDiagnostic(
|
|
61708
|
-
2187 /* RequiredTypeParametersCannotFollowTypeParametersWithDefaults */,
|
|
61709
|
-
typeParameterDeclaration
|
|
61710
|
-
);
|
|
61711
|
-
break;
|
|
61712
|
-
}
|
|
61713
|
-
}
|
|
61714
|
-
}
|
|
61715
|
-
checkTypeParameterDeclaration(node) {
|
|
61716
|
-
const entity = this.analyzer.entity.ofTypeParameterDeclaration(node);
|
|
61717
|
-
const constraint = entity.getConstraint();
|
|
61718
|
-
if (constraint.causesCycle) {
|
|
61719
|
-
this.createAndAddDiagnostic(2082 /* TypeParameterHasCircularConstraint */, node.name);
|
|
61720
|
-
}
|
|
61721
|
-
if (constraint.cycleFree !== void 0) {
|
|
61722
|
-
const defaultType = entity.getDefaultType();
|
|
61723
|
-
if (defaultType !== void 0 && !this.analyzer.isTypeAssignableTo(defaultType, constraint.cycleFree)) {
|
|
61724
|
-
this.addTypeAssignabilityDiagnosticIfBothTypesResolved(
|
|
61725
|
-
defaultType,
|
|
61726
|
-
constraint.cycleFree,
|
|
61727
|
-
node.defaultType ?? node,
|
|
61728
|
-
2087 /* Type0IsNotAssignableToConstraint1 */
|
|
61729
|
-
);
|
|
61730
|
-
}
|
|
61731
|
-
}
|
|
61732
|
-
this.checkIfTypeParameterIsUnused(entity, node.name);
|
|
61733
|
-
}
|
|
61734
62239
|
checkFunctionLiteral(node) {
|
|
61735
62240
|
this.analyzer.semanticContext.ofRegularOrBlockFunctionLiteralParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61736
62241
|
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
@@ -61806,38 +62311,6 @@ var SourceFileAnalyzer = class {
|
|
|
61806
62311
|
}
|
|
61807
62312
|
}
|
|
61808
62313
|
}
|
|
61809
|
-
addNotTranslatedTextsDiagnostics(translationPackage, diagnosticLocation) {
|
|
61810
|
-
const notTranslatedEntities = this.collectNotTranslatedTexts(translationPackage);
|
|
61811
|
-
if (notTranslatedEntities.length > 0) {
|
|
61812
|
-
const diagnostic = this.createNotTranslatedTextsDiagnostic(notTranslatedEntities, diagnosticLocation);
|
|
61813
|
-
this.addDiagnostic(diagnostic);
|
|
61814
|
-
}
|
|
61815
|
-
}
|
|
61816
|
-
collectNotTranslatedTexts(translationPackage) {
|
|
61817
|
-
return [];
|
|
61818
|
-
}
|
|
61819
|
-
createNotTranslatedTextsDiagnostic(entities, diagnosticLocation) {
|
|
61820
|
-
const maxDisplayedEntitiesCount = 10;
|
|
61821
|
-
let result;
|
|
61822
|
-
if (entities.length <= maxDisplayedEntitiesCount) {
|
|
61823
|
-
const displayableEntities = entities.map((e) => this.diagnosticArgumentFactory.createDisplayableEntity(e));
|
|
61824
|
-
result = this.analyzer.createDiagnostic(
|
|
61825
|
-
2095 /* TheFollowingTextsAreNotTranslated0 */,
|
|
61826
|
-
diagnosticLocation,
|
|
61827
|
-
[new DisplayableArray(displayableEntities, "\n\n")],
|
|
61828
|
-
1 /* Warning */
|
|
61829
|
-
);
|
|
61830
|
-
} else {
|
|
61831
|
-
const displayableEntities = entities.slice(0, maxDisplayedEntitiesCount + 1).map((e) => this.diagnosticArgumentFactory.createDisplayableEntity(e));
|
|
61832
|
-
result = this.analyzer.createDiagnostic(
|
|
61833
|
-
2096 /* TheFollowingTextsAreNotTranslated0And1More */,
|
|
61834
|
-
diagnosticLocation,
|
|
61835
|
-
[new DisplayableArray(displayableEntities, "\n\n"), entities.length - maxDisplayedEntitiesCount],
|
|
61836
|
-
1 /* Warning */
|
|
61837
|
-
);
|
|
61838
|
-
}
|
|
61839
|
-
return result;
|
|
61840
|
-
}
|
|
61841
62314
|
checkAllDefaultConstructorArgumentsAreNamed(node) {
|
|
61842
62315
|
for (const argument2 of node.argumentList.arguments) {
|
|
61843
62316
|
if (argument2.name === void 0) {
|
|
@@ -61846,224 +62319,6 @@ var SourceFileAnalyzer = class {
|
|
|
61846
62319
|
}
|
|
61847
62320
|
}
|
|
61848
62321
|
}
|
|
61849
|
-
checkPackageVariableDeclaration(node) {
|
|
61850
|
-
const entity = this.analyzer.entity.ofPackageVariableDeclaration(node);
|
|
61851
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61852
|
-
if (this.isInterfacePackageFile) {
|
|
61853
|
-
if (node.initializer !== void 0) {
|
|
61854
|
-
this.createAndAddDiagnostic(2061 /* InterfacePackageVariablesMustNotHaveInitializers */, node.name);
|
|
61855
|
-
}
|
|
61856
|
-
}
|
|
61857
|
-
if (node.typeAnnotation === void 0 && node.initializer === void 0) {
|
|
61858
|
-
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
61859
|
-
} else if (node.initializer !== void 0 && node.typeAnnotation !== void 0) {
|
|
61860
|
-
this.checkExpressionTypeIsAssignableToTargetType(
|
|
61861
|
-
node.initializer,
|
|
61862
|
-
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
61863
|
-
);
|
|
61864
|
-
}
|
|
61865
|
-
}
|
|
61866
|
-
checkPackageFunctionDeclaration(node) {
|
|
61867
|
-
const entity = this.analyzer.entity.ofPackageFunctionDeclaration(node);
|
|
61868
|
-
this.checkPackageMemberBodyPresence(entity, node.block, node.name);
|
|
61869
|
-
if (node.block !== void 0) {
|
|
61870
|
-
this.checkPossibleGeneratorFunctionReturnType(entity, node, node.name);
|
|
61871
|
-
}
|
|
61872
|
-
if (node.typeParameterClause !== void 0) {
|
|
61873
|
-
this.analyzer.semanticContext.ofFunctionDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61874
|
-
}
|
|
61875
|
-
this.analyzer.semanticContext.ofFunctionDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61876
|
-
if (!this.analyzer.isFunctionGenerator(node)) {
|
|
61877
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61878
|
-
node,
|
|
61879
|
-
node.name,
|
|
61880
|
-
this.analyzer.returnType.ofPackageFunctionDeclaration(node),
|
|
61881
|
-
this.analyzer.resultLocalVariableEntity.ofPackageFunctionDeclaration(node)
|
|
61882
|
-
);
|
|
61883
|
-
}
|
|
61884
|
-
}
|
|
61885
|
-
checkPackageVariableGetterDeclaration(node) {
|
|
61886
|
-
const entity = this.analyzer.entity.ofComputedPackageVariableDeclaration(node);
|
|
61887
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61888
|
-
this.checkPackageMemberBodyPresence(entity, node.block, node.name);
|
|
61889
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61890
|
-
node,
|
|
61891
|
-
node.name,
|
|
61892
|
-
this.analyzer.returnType.ofPackageVariableGetterDeclaration(node),
|
|
61893
|
-
this.analyzer.resultLocalVariableEntity.ofPackageVariableGetterDeclaration(node)
|
|
61894
|
-
);
|
|
61895
|
-
}
|
|
61896
|
-
checkPackageVariableSetterDeclaration(node) {
|
|
61897
|
-
const entity = this.analyzer.entity.ofComputedPackageVariableDeclaration(node);
|
|
61898
|
-
this.checkPackageMemberBodyPresence(entity, node.block, node.name);
|
|
61899
|
-
}
|
|
61900
|
-
checkConstructorDeclaration(node) {
|
|
61901
|
-
const entity = this.analyzer.entity.ofConstructorDeclaration(node);
|
|
61902
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61903
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.creationKeyword);
|
|
61904
|
-
this.analyzer.semanticContext.ofConstructorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61905
|
-
}
|
|
61906
|
-
checkMethodDeclaration(node) {
|
|
61907
|
-
const entity = this.analyzer.entity.ofMethodDeclaration(node);
|
|
61908
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61909
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.name);
|
|
61910
|
-
if (node.block !== void 0) {
|
|
61911
|
-
this.checkPossibleGeneratorFunctionReturnType(entity, node, node.name);
|
|
61912
|
-
const containingEntity = entity.getContainingEntity();
|
|
61913
|
-
if (entity.markedBasic() && containingEntity.kind === 2 /* Type */ && containingEntity.typeEntityKind === 4 /* Alias */) {
|
|
61914
|
-
this.analyzer.checkBodyOfBasicAliasTypeMethod(node, this.diagnosticAcceptor);
|
|
61915
|
-
}
|
|
61916
|
-
}
|
|
61917
|
-
if (entity.methodKind === 3 /* Operator */) {
|
|
61918
|
-
if (node.typeParameterClause !== void 0) {
|
|
61919
|
-
this.createAndAddDiagnostic(
|
|
61920
|
-
2231 /* OperatorCannotContainTypeParameterDeclarations */,
|
|
61921
|
-
node.typeParameterClause
|
|
61922
|
-
);
|
|
61923
|
-
}
|
|
61924
|
-
const syntacticalOperatorKind = node.name.operatorKind;
|
|
61925
|
-
if (syntacticalOperatorKind !== void 0) {
|
|
61926
|
-
const requiredParameterCount = requiredParameterCountBySyntacticalOperatorKind[syntacticalOperatorKind];
|
|
61927
|
-
const actualParameterCount = node.parameterClause.parameterList.parameters.count();
|
|
61928
|
-
switch (requiredParameterCount) {
|
|
61929
|
-
case 0 /* Zero */: {
|
|
61930
|
-
if (actualParameterCount !== 0) {
|
|
61931
|
-
const operatorText = LocalizationHelperA.localizeSyntacticalOperatorKind(
|
|
61932
|
-
syntacticalOperatorKind,
|
|
61933
|
-
this.sourceFile.locale
|
|
61934
|
-
);
|
|
61935
|
-
this.createAndAddDiagnostic(
|
|
61936
|
-
2097 /* OperatorFunction0MustNotHaveParameters */,
|
|
61937
|
-
node.name,
|
|
61938
|
-
[operatorText]
|
|
61939
|
-
);
|
|
61940
|
-
}
|
|
61941
|
-
break;
|
|
61942
|
-
}
|
|
61943
|
-
case 1 /* ZeroOrOne */: {
|
|
61944
|
-
if (!(actualParameterCount === 0 || actualParameterCount === 1)) {
|
|
61945
|
-
const operatorText = LocalizationHelperA.localizeSyntacticalOperatorKind(
|
|
61946
|
-
syntacticalOperatorKind,
|
|
61947
|
-
this.sourceFile.locale
|
|
61948
|
-
);
|
|
61949
|
-
this.createAndAddDiagnostic(
|
|
61950
|
-
2099 /* OperatorFunction0MustHaveNoMoreThanOneParameter */,
|
|
61951
|
-
node.name,
|
|
61952
|
-
[operatorText]
|
|
61953
|
-
);
|
|
61954
|
-
}
|
|
61955
|
-
break;
|
|
61956
|
-
}
|
|
61957
|
-
case 2 /* One */: {
|
|
61958
|
-
if (actualParameterCount !== 1) {
|
|
61959
|
-
const operatorText = LocalizationHelperA.localizeSyntacticalOperatorKind(
|
|
61960
|
-
syntacticalOperatorKind,
|
|
61961
|
-
this.sourceFile.locale
|
|
61962
|
-
);
|
|
61963
|
-
this.createAndAddDiagnostic(
|
|
61964
|
-
2098 /* OperatorFunction0MustHaveOneParameter */,
|
|
61965
|
-
node.name,
|
|
61966
|
-
[operatorText]
|
|
61967
|
-
);
|
|
61968
|
-
}
|
|
61969
|
-
break;
|
|
61970
|
-
}
|
|
61971
|
-
default:
|
|
61972
|
-
Debug.never(requiredParameterCount);
|
|
61973
|
-
}
|
|
61974
|
-
}
|
|
61975
|
-
}
|
|
61976
|
-
if (node.typeParameterClause !== void 0) {
|
|
61977
|
-
this.analyzer.semanticContext.ofFunctionDeclarationTypeParameters(node, node.typeParameterClause).validateNameConflicts(this.diagnosticAcceptor);
|
|
61978
|
-
}
|
|
61979
|
-
this.analyzer.semanticContext.ofFunctionDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
61980
|
-
if (!this.analyzer.isFunctionGenerator(node)) {
|
|
61981
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
61982
|
-
node,
|
|
61983
|
-
node.name,
|
|
61984
|
-
this.analyzer.returnType.ofMethodDeclaration(node),
|
|
61985
|
-
this.analyzer.resultLocalVariableEntity.ofMethodDeclaration(node)
|
|
61986
|
-
);
|
|
61987
|
-
}
|
|
61988
|
-
}
|
|
61989
|
-
checkFieldDeclaration(node) {
|
|
61990
|
-
const entity = this.analyzer.entity.ofFieldDeclaration(node);
|
|
61991
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
61992
|
-
if (TypeMemberEntity.isAspectMember(entity) && !entity.isStatic() && !entity.markedAbstract()) {
|
|
61993
|
-
this.createAndAddDiagnostic(2065 /* AspectTypeFieldsMustBeAbstract */, node.name);
|
|
61994
|
-
}
|
|
61995
|
-
if (this.isInterfacePackageFile) {
|
|
61996
|
-
if (node.initializer !== void 0) {
|
|
61997
|
-
this.createAndAddDiagnostic(2061 /* InterfacePackageVariablesMustNotHaveInitializers */, node.name);
|
|
61998
|
-
}
|
|
61999
|
-
} else if (TypeMemberEntity.isReducedTypeMember(entity)) {
|
|
62000
|
-
if (node.initializer !== void 0) {
|
|
62001
|
-
this.createAndAddDiagnostic(2069 /* ReducedTypeFieldsMustNotHaveInitializers */, node.name);
|
|
62002
|
-
}
|
|
62003
|
-
} else if (entity.markedAbstract()) {
|
|
62004
|
-
if (node.initializer !== void 0) {
|
|
62005
|
-
this.createAndAddDiagnostic(2068 /* AbstractFieldsMustNotHaveInitializers */, node.name);
|
|
62006
|
-
}
|
|
62007
|
-
}
|
|
62008
|
-
if (node.typeAnnotation === void 0 && node.initializer === void 0) {
|
|
62009
|
-
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
62010
|
-
} else if (node.initializer !== void 0 && node.typeAnnotation !== void 0) {
|
|
62011
|
-
this.checkExpressionTypeIsAssignableToTargetType(
|
|
62012
|
-
node.initializer,
|
|
62013
|
-
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
62014
|
-
);
|
|
62015
|
-
}
|
|
62016
|
-
}
|
|
62017
|
-
checkFieldGetterDeclaration(node) {
|
|
62018
|
-
const entity = this.analyzer.entity.ofComputedFieldDeclaration(node);
|
|
62019
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62020
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.name);
|
|
62021
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
62022
|
-
node,
|
|
62023
|
-
node.name,
|
|
62024
|
-
this.analyzer.returnType.ofFieldGetterDeclaration(node),
|
|
62025
|
-
this.analyzer.resultLocalVariableEntity.ofFieldGetterDeclaration(node)
|
|
62026
|
-
);
|
|
62027
|
-
}
|
|
62028
|
-
checkFieldSetterDeclaration(node) {
|
|
62029
|
-
const entity = this.analyzer.entity.ofComputedFieldDeclaration(node);
|
|
62030
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62031
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.name);
|
|
62032
|
-
}
|
|
62033
|
-
checkIndexedElementGetterDeclaration(node) {
|
|
62034
|
-
const entity = this.analyzer.entity.ofIndexerDeclaration(node);
|
|
62035
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62036
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.parameterClause);
|
|
62037
|
-
this.analyzer.semanticContext.ofIndexedElementAccessorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
62038
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
62039
|
-
node,
|
|
62040
|
-
node.parameterClause,
|
|
62041
|
-
this.analyzer.returnType.ofIndexedElementGetterDeclaration(node),
|
|
62042
|
-
this.analyzer.resultLocalVariableEntity.ofIndexedElementGetterDeclaration(node)
|
|
62043
|
-
);
|
|
62044
|
-
}
|
|
62045
|
-
checkIndexedElementSetterDeclaration(node) {
|
|
62046
|
-
const entity = this.analyzer.entity.ofIndexerDeclaration(node);
|
|
62047
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62048
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.parameterClause);
|
|
62049
|
-
this.analyzer.semanticContext.ofIndexedElementAccessorDeclarationParameters(node).validateNameConflicts(this.diagnosticAcceptor);
|
|
62050
|
-
}
|
|
62051
|
-
checkDereferencedVariableGetterDeclaration(node) {
|
|
62052
|
-
const entity = this.analyzer.entity.ofDereferenceOperatorDeclaration(node);
|
|
62053
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62054
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.caretToken);
|
|
62055
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
62056
|
-
node,
|
|
62057
|
-
node.caretToken,
|
|
62058
|
-
this.analyzer.returnType.ofDereferencedVariableGetterDeclaration(node),
|
|
62059
|
-
this.analyzer.resultLocalVariableEntity.ofDereferencedVariableGetterDeclaration(node)
|
|
62060
|
-
);
|
|
62061
|
-
}
|
|
62062
|
-
checkDereferencedVariableSetterDeclaration(node) {
|
|
62063
|
-
const entity = this.analyzer.entity.ofDereferenceOperatorDeclaration(node);
|
|
62064
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62065
|
-
this.checkTypeMemberBodyPresence(entity, node.block, node.caretToken);
|
|
62066
|
-
}
|
|
62067
62322
|
checkNestedFunctionDeclaration(node) {
|
|
62068
62323
|
const entity = this.analyzer.entity.ofNestedFunctionDeclaration(node);
|
|
62069
62324
|
if (node.block !== void 0) {
|
|
@@ -62135,60 +62390,6 @@ var SourceFileAnalyzer = class {
|
|
|
62135
62390
|
}
|
|
62136
62391
|
}
|
|
62137
62392
|
}
|
|
62138
|
-
checkPackageMemberBodyPresence(entity, body, diagnosticLocation) {
|
|
62139
|
-
if (this.isInterfacePackageFile) {
|
|
62140
|
-
if (body !== void 0) {
|
|
62141
|
-
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, diagnosticLocation);
|
|
62142
|
-
}
|
|
62143
|
-
} else if (findTag(this.analyzer.originalWellKnownDeclarations.builtIntoPlatform, entity.getTags()) !== void 0) {
|
|
62144
|
-
if (body !== void 0) {
|
|
62145
|
-
this.createAndAddDiagnostic(
|
|
62146
|
-
2066 /* DeclarationsMarkedWithBuiltIntoPlatformTagMustNotHaveBody */,
|
|
62147
|
-
diagnosticLocation
|
|
62148
|
-
);
|
|
62149
|
-
}
|
|
62150
|
-
} else {
|
|
62151
|
-
if (body === void 0) {
|
|
62152
|
-
this.createAndAddDiagnostic(2062 /* BodyIsMissing */, diagnosticLocation);
|
|
62153
|
-
}
|
|
62154
|
-
}
|
|
62155
|
-
}
|
|
62156
|
-
checkTypeMemberBodyPresence(entity, body, diagnosticLocation) {
|
|
62157
|
-
if (this.isInterfacePackageFile) {
|
|
62158
|
-
if (body !== void 0) {
|
|
62159
|
-
this.createAndAddDiagnostic(2060 /* InterfacePackageMustNotContainImplementation */, diagnosticLocation);
|
|
62160
|
-
}
|
|
62161
|
-
} else if (findTag(this.analyzer.originalWellKnownDeclarations.builtIntoPlatform, entity.getTags()) !== void 0) {
|
|
62162
|
-
if (body !== void 0) {
|
|
62163
|
-
this.createAndAddDiagnostic(
|
|
62164
|
-
2066 /* DeclarationsMarkedWithBuiltIntoPlatformTagMustNotHaveBody */,
|
|
62165
|
-
diagnosticLocation
|
|
62166
|
-
);
|
|
62167
|
-
}
|
|
62168
|
-
} else if (TypeMemberEntity.isReducedTypeMember(entity)) {
|
|
62169
|
-
if (body !== void 0) {
|
|
62170
|
-
this.createAndAddDiagnostic(
|
|
62171
|
-
2067 /* ReducedTypeMembersMustNotHaveBody */,
|
|
62172
|
-
diagnosticLocation
|
|
62173
|
-
);
|
|
62174
|
-
}
|
|
62175
|
-
} else if (entity.isStatic()) {
|
|
62176
|
-
if (body === void 0) {
|
|
62177
|
-
this.createAndAddDiagnostic(2062 /* BodyIsMissing */, diagnosticLocation);
|
|
62178
|
-
}
|
|
62179
|
-
} else if (entity.markedAbstract()) {
|
|
62180
|
-
if (body !== void 0) {
|
|
62181
|
-
this.createAndAddDiagnostic(
|
|
62182
|
-
2063 /* AbstractTypeMembersMustNotHaveBody */,
|
|
62183
|
-
diagnosticLocation
|
|
62184
|
-
);
|
|
62185
|
-
}
|
|
62186
|
-
} else {
|
|
62187
|
-
if (body === void 0) {
|
|
62188
|
-
this.createAndAddDiagnostic(2062 /* BodyIsMissing */, diagnosticLocation);
|
|
62189
|
-
}
|
|
62190
|
-
}
|
|
62191
|
-
}
|
|
62192
62393
|
// TODO: учесть константы времени компиляции.
|
|
62193
62394
|
// private validateVariantInitializer(expression: tree.Expression): void {
|
|
62194
62395
|
// if (expression.kind === tree.NodeKind.TokenExpression) {
|
|
@@ -62686,109 +62887,6 @@ var SourceFileAnalyzer = class {
|
|
|
62686
62887
|
}
|
|
62687
62888
|
}
|
|
62688
62889
|
}
|
|
62689
|
-
checkParameterList(node) {
|
|
62690
|
-
const parameters = node.parameters.toArray();
|
|
62691
|
-
if (parameters.length > 0) {
|
|
62692
|
-
this.checkRequiredParametersDoNotFollowOptionalParameters(parameters);
|
|
62693
|
-
const firstParameter = parameters[0];
|
|
62694
|
-
const firstParameterEntity = this.analyzer.entity.ofParameterDeclaration(firstParameter);
|
|
62695
|
-
if (firstParameterEntity.isObjectParameter() && !this.parameterListCanDeclareObjectParameter(node)) {
|
|
62696
|
-
this.createAndAddDiagnostic(2228 /* ObjectParameterCannotBeDeclaredHere */, firstParameter.name);
|
|
62697
|
-
}
|
|
62698
|
-
this.checkObjectParameterIsTheFirstParameter(parameters);
|
|
62699
|
-
}
|
|
62700
|
-
}
|
|
62701
|
-
checkRequiredParametersDoNotFollowOptionalParameters(parameters) {
|
|
62702
|
-
let seenOptionalParameter = false;
|
|
62703
|
-
for (const parameter of parameters) {
|
|
62704
|
-
if (parameter.defaultValue !== void 0) {
|
|
62705
|
-
seenOptionalParameter = true;
|
|
62706
|
-
} else if (seenOptionalParameter) {
|
|
62707
|
-
this.createAndAddDiagnostic(2188 /* RequiredParametersCannotFollowOptionalParameters */, parameter.name);
|
|
62708
|
-
break;
|
|
62709
|
-
}
|
|
62710
|
-
}
|
|
62711
|
-
}
|
|
62712
|
-
parameterListCanDeclareObjectParameter(node) {
|
|
62713
|
-
const parent = node.parent.parent;
|
|
62714
|
-
switch (parent.kind) {
|
|
62715
|
-
case 17 /* AnonymousFunctionTypeDeclaration */:
|
|
62716
|
-
case 23 /* PackageFunctionDeclaration */:
|
|
62717
|
-
case 53 /* NestedFunctionDeclaration */:
|
|
62718
|
-
case 62 /* FunctionLiteral */:
|
|
62719
|
-
return true;
|
|
62720
|
-
case 47 /* MethodDeclaration */: {
|
|
62721
|
-
const containingDeclaration = TypeMemberQuery.getContainingDeclaration(parent);
|
|
62722
|
-
switch (containingDeclaration.kind) {
|
|
62723
|
-
case 18 /* AnonymousClassDeclaration */:
|
|
62724
|
-
case 27 /* PackageClassDeclaration */:
|
|
62725
|
-
case 28 /* PackageStructureDeclaration */:
|
|
62726
|
-
case 29 /* PackageAspectDeclaration */:
|
|
62727
|
-
case 30 /* PackageReducedTypeDeclaration */:
|
|
62728
|
-
case 31 /* PackageVariantDeclaration */:
|
|
62729
|
-
return true;
|
|
62730
|
-
case 19 /* PackageAliasTypeDeclaration */:
|
|
62731
|
-
case 35 /* TypeExtensionDeclaration */:
|
|
62732
|
-
return false;
|
|
62733
|
-
default:
|
|
62734
|
-
Debug.never(containingDeclaration);
|
|
62735
|
-
}
|
|
62736
|
-
}
|
|
62737
|
-
case 40 /* ConstructorDeclaration */:
|
|
62738
|
-
case 41 /* DestructorDeclaration */:
|
|
62739
|
-
case 42 /* IndexedElementGetterDeclaration */:
|
|
62740
|
-
case 43 /* IndexedElementSetterDeclaration */:
|
|
62741
|
-
return false;
|
|
62742
|
-
default:
|
|
62743
|
-
Debug.never(parent);
|
|
62744
|
-
}
|
|
62745
|
-
}
|
|
62746
|
-
checkObjectParameterIsTheFirstParameter(parameters) {
|
|
62747
|
-
for (let i = 1; i < parameters.length; i++) {
|
|
62748
|
-
const parameterDeclaration2 = parameters[i];
|
|
62749
|
-
if ((parameterDeclaration2.name.flags & 512 /* ObjectParameterName */) !== 0) {
|
|
62750
|
-
this.createAndAddDiagnostic(2227 /* ObjectParameterMustBeTheFirstParameter */, parameterDeclaration2.name);
|
|
62751
|
-
break;
|
|
62752
|
-
}
|
|
62753
|
-
}
|
|
62754
|
-
}
|
|
62755
|
-
checkParameterDeclaration(node) {
|
|
62756
|
-
const entity = this.analyzer.entity.ofParameterDeclaration(node);
|
|
62757
|
-
entity.ensureAllDiagnosticsReported?.();
|
|
62758
|
-
const isFunctionLiteralParameter = node.parent.parent.parent.kind === 62 /* FunctionLiteral */;
|
|
62759
|
-
if (!isFunctionLiteralParameter && node.typeAnnotation === void 0 && node.defaultValue === void 0) {
|
|
62760
|
-
this.createAndAddDiagnostic(2184 /* VariableTypeIsNotSpecified */, node.name);
|
|
62761
|
-
} else if (node.defaultValue !== void 0 && node.typeAnnotation !== void 0) {
|
|
62762
|
-
this.checkExpressionTypeIsAssignableToTargetType(
|
|
62763
|
-
node.defaultValue,
|
|
62764
|
-
this.analyzer.type.ofTypeSpecifier(node.typeAnnotation.typeSpecifier)
|
|
62765
|
-
);
|
|
62766
|
-
} else if (isFunctionLiteralParameter && node.defaultValue !== void 0) {
|
|
62767
|
-
this.checkExpressionTypeIsAssignableToTargetType(node.defaultValue, entity.getType());
|
|
62768
|
-
}
|
|
62769
|
-
let parentHasBody;
|
|
62770
|
-
const parent = node.parent.parent.parent;
|
|
62771
|
-
switch (parent.kind) {
|
|
62772
|
-
case 23 /* PackageFunctionDeclaration */:
|
|
62773
|
-
case 40 /* ConstructorDeclaration */:
|
|
62774
|
-
case 41 /* DestructorDeclaration */:
|
|
62775
|
-
case 42 /* IndexedElementGetterDeclaration */:
|
|
62776
|
-
case 43 /* IndexedElementSetterDeclaration */:
|
|
62777
|
-
case 47 /* MethodDeclaration */:
|
|
62778
|
-
case 53 /* NestedFunctionDeclaration */:
|
|
62779
|
-
case 62 /* FunctionLiteral */:
|
|
62780
|
-
parentHasBody = parent.block !== void 0;
|
|
62781
|
-
break;
|
|
62782
|
-
case 17 /* AnonymousFunctionTypeDeclaration */:
|
|
62783
|
-
parentHasBody = false;
|
|
62784
|
-
break;
|
|
62785
|
-
default:
|
|
62786
|
-
Debug.never(parent);
|
|
62787
|
-
}
|
|
62788
|
-
if (parentHasBody) {
|
|
62789
|
-
this.checkIfVariableIsUnused(entity, node.name);
|
|
62790
|
-
}
|
|
62791
|
-
}
|
|
62792
62890
|
checkIfVariableIsUnused(entity, diagnosticLocation) {
|
|
62793
62891
|
const usageInfo = this.namedDeclarationsUsageMap.getUsageInfo(entity);
|
|
62794
62892
|
if (usageInfo.usageCount === 0 || !usageInfo.hasGetAccess) {
|
|
@@ -62858,43 +62956,6 @@ var SourceFileAnalyzer = class {
|
|
|
62858
62956
|
}
|
|
62859
62957
|
return receiver.kind === 85 /* BaseExpression */;
|
|
62860
62958
|
}
|
|
62861
|
-
overridingMemberHasCorrectHiding(overridingMemberHiding, overriddenMemberHiding) {
|
|
62862
|
-
return overriddenMemberHiding === void 0 ? overridingMemberHiding === void 0 : overriddenMemberHiding.kind === overridingMemberHiding?.kind;
|
|
62863
|
-
}
|
|
62864
|
-
checkTextTranslationDeclaration(node) {
|
|
62865
|
-
const sourceText = node.sourceText;
|
|
62866
|
-
if (sourceText.kind === 141 /* TranslationTextTemplate */) {
|
|
62867
|
-
const semanticContext = this.analyzer.semanticContext.ofTextTranslationDeclarationParameters(sourceText);
|
|
62868
|
-
semanticContext.validateNameConflicts(this.diagnosticAcceptor);
|
|
62869
|
-
}
|
|
62870
|
-
const pkg2 = this.textTranslationPackage;
|
|
62871
|
-
if (pkg2 !== void 0 && !pkg2.isPrimary()) {
|
|
62872
|
-
const targetPackage = pkg2.getTargetPackage();
|
|
62873
|
-
if (targetPackage !== void 0) {
|
|
62874
|
-
const primaryPkg = this.analyzer.getPrimaryTextTranslationPackageOfTargetPackage(targetPackage);
|
|
62875
|
-
if (primaryPkg !== void 0) {
|
|
62876
|
-
const textKey = TextIdentity.keyFromTextTranslationSource(sourceText);
|
|
62877
|
-
const textTranslation = primaryPkg.getMembers().getTextTranslationsByTextKey(textKey);
|
|
62878
|
-
if (textTranslation.length === 0) {
|
|
62879
|
-
this.createAndAddDiagnostic(
|
|
62880
|
-
2190 /* TextIsMissingAmongPrimaryTextTranslationDefinitions */,
|
|
62881
|
-
sourceText,
|
|
62882
|
-
void 0,
|
|
62883
|
-
1 /* Warning */
|
|
62884
|
-
);
|
|
62885
|
-
}
|
|
62886
|
-
}
|
|
62887
|
-
}
|
|
62888
|
-
}
|
|
62889
|
-
if (node.kind === 139 /* TextTranslationFunctionDeclaration */) {
|
|
62890
|
-
this.checkAllCodePathsReturnOrResultVariableIsAssigned(
|
|
62891
|
-
node,
|
|
62892
|
-
node.sourceText,
|
|
62893
|
-
this.analyzer.returnType.ofTextTranslationFunctionDeclaration(node),
|
|
62894
|
-
this.analyzer.resultLocalVariableEntity.ofTextTranslationFunctionDeclaration(node)
|
|
62895
|
-
);
|
|
62896
|
-
}
|
|
62897
|
-
}
|
|
62898
62959
|
attachNodeLocationAndAddDiagnostics(diagnosticsData, node) {
|
|
62899
62960
|
for (const diagnosticData of diagnosticsData) {
|
|
62900
62961
|
const location = this.analyzer.getNodeDiagnosticLocation(node);
|