@artel/artc 0.6.25254 → 0.6.25255

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.
Files changed (96) hide show
  1. package/build/Cli.js +3 -3
  2. package/build/api/Api.js +12 -6
  3. package/build/api/ApiNodeJS.js +3 -3
  4. package/build/api/ApiServices.js +568 -365
  5. package/build/{chunk-JTDPRR7O.js → chunk-R2AFVF7W.js} +2 -2
  6. package/build/{chunk-JV2EK6MS.js → chunk-SSG7MY2R.js} +1 -1
  7. package/build/{chunk-3JS4YG6N.js → chunk-Y23FSWAN.js} +13016 -14906
  8. package/build/types/analysis/AccessedFunction.d.ts +11 -5
  9. package/build/types/analysis/AnalyzedTranslationPackage.d.ts +2 -1
  10. package/build/types/analysis/Analyzer.d.ts +116 -40
  11. package/build/types/analysis/ArgumentToParameterMatchResult.d.ts +1 -4
  12. package/build/types/analysis/ArgumentsToParametersMatcher.d.ts +9 -15
  13. package/build/types/analysis/AutotypeCallExpressionMeaning.d.ts +12 -6
  14. package/build/types/analysis/BaseExpressionMeaning.d.ts +43 -15
  15. package/build/types/analysis/CallExpressionMeaning.d.ts +41 -22
  16. package/build/types/analysis/ConstructorCallResolver.d.ts +22 -0
  17. package/build/types/analysis/DiagnosticCollector.d.ts +5 -9
  18. package/build/types/analysis/FunctionAccessResolver.d.ts +15 -0
  19. package/build/types/analysis/IdentifierExpressionMeaning.d.ts +56 -22
  20. package/build/types/analysis/IndexedAccessExpressionMeaning.d.ts +3 -2
  21. package/build/types/analysis/MemberAccessExpressionMeaning.d.ts +76 -27
  22. package/build/types/analysis/NamedTypeSpecifierResolver.d.ts +0 -1
  23. package/build/types/analysis/NodeTypeUtils.d.ts +1 -0
  24. package/build/types/analysis/ObjectExpressionMeaning.d.ts +1 -0
  25. package/build/types/analysis/OperatorAccessResolver.d.ts +9 -0
  26. package/build/types/analysis/OverloadResolver.d.ts +91 -5
  27. package/build/types/analysis/ReturnTypeInferrer.d.ts +13 -0
  28. package/build/types/analysis/SubstitutedFunction.d.ts +10 -4
  29. package/build/types/analysis/TagMeaning.d.ts +16 -15
  30. package/build/types/analysis/TypeArgumentInferrer.d.ts +49 -0
  31. package/build/types/analysis/TypeNarrower.d.ts +6 -4
  32. package/build/types/analysis/TypeOverloadResolver.d.ts +4 -2
  33. package/build/types/analysis/UserDefinableBinaryOperatorResolver.d.ts +2 -6
  34. package/build/types/analysis/UserDefinableUnaryOperatorResolver.d.ts +2 -2
  35. package/build/types/analysis/Utils.d.ts +2 -0
  36. package/build/types/analysis/index.d.ts +0 -2
  37. package/build/types/analysis/semantic-context/Declarations.d.ts +4 -4
  38. package/build/types/analysis/semantic-context/SemanticContextBuilder.d.ts +1 -0
  39. package/build/types/api/Api.d.ts +0 -2
  40. package/build/types/common/ArrayUtils.d.ts +3 -2
  41. package/build/types/common/Cached.d.ts +2 -0
  42. package/build/types/common/Query.d.ts +1 -1
  43. package/build/types/common/TreeQuery.d.ts +1 -2
  44. package/build/types/diagnostic/Diagnostic.d.ts +7 -0
  45. package/build/types/diagnostic/DiagnosticCode.d.ts +180 -173
  46. package/build/types/entities/AliasTypeEntity.d.ts +1 -0
  47. package/build/types/entities/AliasedType.d.ts +2 -2
  48. package/build/types/entities/FunctionEntity.d.ts +6 -3
  49. package/build/types/entities/FunctionTypeEntity.d.ts +2 -1
  50. package/build/types/entities/PackageAliasEntity.d.ts +2 -2
  51. package/build/types/entities/StructuredTypeEntity.d.ts +1 -0
  52. package/build/types/entities/TypeParameterEntity.d.ts +1 -0
  53. package/build/types/entities/VariableEntity.d.ts +23 -11
  54. package/build/types/entities/VariantTypeEntity.d.ts +1 -0
  55. package/build/types/entities/index.d.ts +2 -1
  56. package/build/types/parser/CharacterCodes.d.ts +0 -8
  57. package/build/types/parser/Parser.d.ts +2 -2
  58. package/build/types/parser/TriviaInterner.d.ts +8 -0
  59. package/build/types/services/AddPropertyAssignmentService.d.ts +0 -7
  60. package/build/types/services/NodeSemanticInfo.d.ts +3 -1
  61. package/build/types/services/TreeUtils.d.ts +1 -1
  62. package/build/types/services/signature-help/SignatureWithValueParameters.d.ts +9 -1
  63. package/build/types/services/signature-help/TypeParameterSignatureHelpProvider.d.ts +1 -1
  64. package/build/types/services/source-generation/EntityToSyntax.d.ts +1 -1
  65. package/build/types/tree/BaseNode.d.ts +26 -0
  66. package/build/types/tree/{green/Nodes.d.ts → Nodes.d.ts} +408 -356
  67. package/build/types/tree/{green/SyntaxToCode.d.ts → SyntaxToCode.d.ts} +1 -1
  68. package/build/types/tree/{green/Token.d.ts → Token.d.ts} +26 -10
  69. package/build/types/tree/{red/Utils.d.ts → Utils.d.ts} +4 -3
  70. package/build/types/tree/index.d.ts +10 -1
  71. package/build/types/ts-interop/Entities.d.ts +14 -0
  72. package/build/types/types/AliasType.d.ts +2 -2
  73. package/build/types/types/FunctionType.d.ts +2 -2
  74. package/build/types/types/IntersectionType.d.ts +2 -2
  75. package/build/types/types/ParameterType.d.ts +2 -2
  76. package/build/types/types/StructuredType.d.ts +2 -2
  77. package/build/types/types/Substitutions.d.ts +2 -2
  78. package/build/types/types/Type.d.ts +3 -3
  79. package/build/types/types/TypeMembers.d.ts +1 -0
  80. package/build/types/types/UnionType.d.ts +2 -2
  81. package/build/types/types/UnresolvedType.d.ts +2 -2
  82. package/build/types/types/VariantType.d.ts +2 -2
  83. package/package.json +1 -1
  84. package/build/types/analysis/ConstructorOverloadResolver.d.ts +0 -31
  85. package/build/types/analysis/FunctionOverloadResolver.d.ts +0 -21
  86. package/build/types/analysis/TargetTypeHint.d.ts +0 -5
  87. package/build/types/tree/green/BaseNode.d.ts +0 -14
  88. package/build/types/tree/green/Utils.d.ts +0 -2
  89. package/build/types/tree/green/index.d.ts +0 -8
  90. package/build/types/tree/red/BaseNode.d.ts +0 -16
  91. package/build/types/tree/red/Internal.d.ts +0 -2
  92. package/build/types/tree/red/Nodes.d.ts +0 -2271
  93. package/build/types/tree/red/Token.d.ts +0 -30
  94. package/build/types/tree/red/index.d.ts +0 -10
  95. /package/build/types/tree/{red/NodePath.d.ts → NodePath.d.ts} +0 -0
  96. /package/build/types/tree/{green/SyntaxFactory.d.ts → SyntaxFactory.d.ts} +0 -0
@@ -1,36 +1,55 @@
1
1
  import { Diagnostic } from '../diagnostic/Diagnostic.js';
2
- import { CallExpression } from '../tree/index.js';
2
+ import { NamedTypeEntity } from '../entities/index.js';
3
+ import * as tree from '../tree/index.js';
3
4
  import * as types from '../types/index.js';
4
- import { AccessedFunction } from './AccessedFunction.js';
5
- import { Analyzer } from './index.js';
5
+ import { AccessedFunction, NotSubstitutedAccessedFunction } from './AccessedFunction.js';
6
+ import { Analyzer, InferenceOptions } from './index.js';
6
7
  export declare class Resolver {
7
8
  private readonly _analyzer;
8
9
  private readonly _node;
9
- constructor(_analyzer: Analyzer, _node: CallExpression);
10
+ private readonly _inferenceOptions;
11
+ constructor(_analyzer: Analyzer, _node: tree.CallExpression, _inferenceOptions: InferenceOptions | undefined);
10
12
  private get callee();
11
- resolve(): Meaning;
12
- resolveType(meaning: Meaning | undefined): types.Type;
13
- private resolveConstructorCallExpressionMeaning;
13
+ resolve(): ResolutionResult;
14
+ private checkExpressionDenotesType;
15
+ private checkExpressionDenotesFunction;
16
+ private checkExpressionDenotesOperator;
17
+ private resolveFunctionCallExpression;
18
+ private resolveOperatorCallExpression;
19
+ private resolveConstructorCallExpression;
20
+ private resolveObjectFunctionCallExpression;
14
21
  private getNodeForDiagnostics;
15
- private getTypeFromMeaning;
22
+ }
23
+ export declare class ResolutionResult {
24
+ readonly meaning: Meaning;
25
+ readonly diagnostics?: readonly Diagnostic[] | undefined;
26
+ constructor(meaning: Meaning, diagnostics?: readonly Diagnostic[] | undefined);
27
+ static unresolved(diagnostics: readonly Diagnostic[] | undefined): ResolutionResult;
16
28
  }
17
29
  export type Meaning = Meaning_functionCall | Meaning_operatorCall | Meaning_objectFunctionCall | Meaning_constructorCall | Meaning_unresolved;
18
- declare class Meaning_functionCall {
19
- readonly func: AccessedFunction;
30
+ export declare class Meaning_functionCall {
31
+ readonly candidates: readonly NotSubstitutedAccessedFunction[];
32
+ readonly suitableFunctions: readonly AccessedFunction[];
33
+ readonly singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined;
20
34
  readonly kind = "function-call";
21
- constructor(func: AccessedFunction);
35
+ get singleSuitableFunction(): AccessedFunction | undefined;
36
+ get singleFunction(): AccessedFunction | undefined;
37
+ constructor(candidates: readonly NotSubstitutedAccessedFunction[], suitableFunctions: readonly AccessedFunction[], singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined);
22
38
  }
23
- declare class Meaning_operatorCall {
24
- readonly operator: types.Operator;
39
+ export declare class Meaning_operatorCall {
40
+ readonly candidates: readonly types.Operator[];
41
+ readonly suitableOperators: readonly types.Operator[];
25
42
  readonly kind = "operator-call";
26
- constructor(operator: types.Operator);
43
+ get singleSuitableOperator(): types.Operator | undefined;
44
+ get singleOperator(): types.Operator | undefined;
45
+ constructor(candidates: readonly types.Operator[], suitableOperators: readonly types.Operator[]);
27
46
  }
28
- declare class Meaning_objectFunctionCall {
47
+ export declare class Meaning_objectFunctionCall {
29
48
  readonly type: types.FunctionType;
30
49
  readonly kind = "object-function-call";
31
50
  constructor(type: types.FunctionType);
32
51
  }
33
- declare class Meaning_constructorCall {
52
+ export declare class Meaning_constructorCall {
34
53
  /**
35
54
  * Тип объекта, получаемого в результате вызова конструктора.
36
55
  *
@@ -38,11 +57,14 @@ declare class Meaning_constructorCall {
38
57
  * создаваемый найденным конструктором, будет отличаться от результирующего типа, хранимого в этом поле, но будет
39
58
  * с ним совместим.
40
59
  */
41
- readonly type: types.Type;
60
+ readonly type: types.Type | undefined;
61
+ readonly typeEntity: NamedTypeEntity | undefined;
42
62
  readonly candidates: readonly types.Constructor[];
43
63
  readonly suitableConstructors: readonly types.Constructor[];
64
+ readonly singleNotSuitableSubstitutedCandidate: types.Constructor | undefined;
44
65
  readonly kind = "constructor-call";
45
66
  get singleSuitableConstructor(): types.Constructor | undefined;
67
+ get singleConstructor(): types.Constructor | undefined;
46
68
  constructor(
47
69
  /**
48
70
  * Тип объекта, получаемого в результате вызова конструктора.
@@ -51,11 +73,8 @@ declare class Meaning_constructorCall {
51
73
  * создаваемый найденным конструктором, будет отличаться от результирующего типа, хранимого в этом поле, но будет
52
74
  * с ним совместим.
53
75
  */
54
- type: types.Type, candidates: readonly types.Constructor[], suitableConstructors: readonly types.Constructor[]);
76
+ type: types.Type | undefined, typeEntity: NamedTypeEntity | undefined, candidates: readonly types.Constructor[], suitableConstructors: readonly types.Constructor[], singleNotSuitableSubstitutedCandidate: types.Constructor | undefined);
55
77
  }
56
- declare class Meaning_unresolved {
57
- readonly diagnostics: readonly Diagnostic[];
78
+ export declare class Meaning_unresolved {
58
79
  readonly kind = "unresolved";
59
- constructor(diagnostics: readonly Diagnostic[]);
60
80
  }
61
- export {};
@@ -0,0 +1,22 @@
1
+ import { PackageLocale } from '../common/index.js';
2
+ import { DiagnosticAcceptorWithArgumentFactory } from '../diagnostic/Diagnostic.js';
3
+ import { IEntityHidingMatcher, NamedTypeEntity } from '../entities/index.js';
4
+ import * as tree from '../tree/index.js';
5
+ import * as types from '../types/index.js';
6
+ import { Analyzer, InferenceOptions } from './Analyzer.js';
7
+ import { SemanticContext } from './semantic-context/SemanticContext.js';
8
+ export declare class Resolver {
9
+ static resolve(analyzer: Analyzer, candidates: readonly types.Constructor[], argumentList: tree.ArgumentList | undefined, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined, nodeForDiagnostic: tree.Node | undefined): readonly types.Constructor[];
10
+ static resolveByNamedTypes(analyzer: Analyzer, typeEntities: readonly NamedTypeEntity[], argumentList: tree.ArgumentList | undefined, typeArgumentClause: tree.TypeArgumentClause | undefined, inferenceOptions: InferenceOptions, locale: PackageLocale, hidingMatcher: IEntityHidingMatcher | undefined, typeExtensionLookup: SemanticContext | undefined, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined, nodeForDiagnostic: tree.Node | undefined): ResolutionResult;
11
+ private static typeCanBeConstructed;
12
+ }
13
+ export declare class ResolutionResult {
14
+ readonly candidates: readonly types.Constructor[];
15
+ readonly suitableConstructors: readonly types.Constructor[];
16
+ readonly typeEntity: NamedTypeEntity | undefined;
17
+ readonly type: types.Type | undefined;
18
+ readonly singleNotSuitableSubstitutedCandidate: types.Constructor | undefined;
19
+ private static _empty;
20
+ static get empty(): ResolutionResult;
21
+ constructor(candidates: readonly types.Constructor[], suitableConstructors: readonly types.Constructor[], typeEntity: NamedTypeEntity | undefined, type: types.Type | undefined, singleNotSuitableSubstitutedCandidate: types.Constructor | undefined);
22
+ }
@@ -12,8 +12,10 @@ export declare class DiagnosticCollector {
12
12
  private readonly _diagnosticAcceptor;
13
13
  private _namedDeclarationsUsageMap;
14
14
  private readonly _modifierValidator;
15
+ private readonly _standardTypes;
15
16
  private get translationPackage();
16
17
  private get isInterfacePackageFile();
18
+ private get standardTypes();
17
19
  constructor(analyzer: Analyzer, sourceFile: project.SourceFile);
18
20
  collect(cancellationToken?: CancellationToken | undefined): Promise<Diagnostic[]>;
19
21
  private collectNodeDiagnostics;
@@ -29,6 +31,7 @@ export declare class DiagnosticCollector {
29
31
  private isNotTranslatedEntity;
30
32
  private createNotTranslatedEntitiesDiagnostic;
31
33
  private checkAllDefaultConstructorArgumentsAreNamed;
34
+ private checkPackageVariableDeclaration;
32
35
  private checkPackageFunctionDeclaration;
33
36
  private checkPackageVariableGetterDeclaration;
34
37
  private checkPackageVariableSetterDeclaration;
@@ -52,8 +55,7 @@ export declare class DiagnosticCollector {
52
55
  private checkLocalVariableUsedBeforeDeclaration;
53
56
  private checkLocalVariableIsUsedBeforeBeingAssigned;
54
57
  private checkMemberAccessExpression;
55
- private addDiagnosticsFromMatchResult;
56
- private checkExpressionTypeAssignableToTargetType;
58
+ private checkExpressionTypeIsAssignableToTargetType;
57
59
  private addTypeAssignabilityDiagnosticIfBothTypesResolved;
58
60
  private checkAssignmentIsValid;
59
61
  private checkAssignmentToIdentifierExpression;
@@ -66,13 +68,7 @@ export declare class DiagnosticCollector {
66
68
  private checkAssignmentToIndexedAccessExpression;
67
69
  private checkOptionalChainingIsUsedOnTheLeftSideOfAssignment;
68
70
  private checkGenericSpecializationExpression;
69
- private checkFunctionSpecialization;
70
- private checkTypeSpecialization;
71
- private checkSpecializationOfDeclarationWithParameters;
72
- /**
73
- * @returns `true` если не было ошибки, иначе `false`.
74
- */
75
- private checkTypeArgumentCount;
71
+ private checkTypeArgumentTypesAreAssignableToConstraints;
76
72
  private checkParameterDeclaration;
77
73
  private checkIfVariableIsUnused;
78
74
  private checkIfNestedFunctionIsUnused;
@@ -0,0 +1,15 @@
1
+ import { DiagnosticAcceptorWithArgumentFactory } from '../diagnostic/Diagnostic.js';
2
+ import * as tree from '../tree/index.js';
3
+ import { AccessedFunction, NotSubstitutedAccessedFunction } from './AccessedFunction.js';
4
+ import { Analyzer, InferenceOptions } from './Analyzer.js';
5
+ export declare class Resolver {
6
+ static resolveByCallExpression(analyzer: Analyzer, candidates: readonly NotSubstitutedAccessedFunction[], node: tree.CallExpression, inferenceOptions: InferenceOptions, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined): ResolutionResult;
7
+ static resolveByCallExpressionParts(analyzer: Analyzer, candidates: readonly NotSubstitutedAccessedFunction[], argumentList: tree.ArgumentList | undefined, typeArgumentClause: tree.TypeArgumentClause | undefined, inferenceOptions: InferenceOptions, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined, nodeForDiagnostic: tree.Node | undefined): ResolutionResult;
8
+ static resolveByTargetType(analyzer: Analyzer, candidates: readonly NotSubstitutedAccessedFunction[], typeArgumentClause: tree.TypeArgumentClause | undefined, inferenceOptions: InferenceOptions, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined, nodeForDiagnostic: tree.Node | undefined): ResolutionResult;
9
+ private static convertProcessedSignature;
10
+ private static reportAmbiguousAccessDiagnostic;
11
+ }
12
+ export interface ResolutionResult {
13
+ suitableFunctions: readonly AccessedFunction[];
14
+ singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined;
15
+ }
@@ -3,37 +3,41 @@ import { Diagnostic } from '../diagnostic/Diagnostic.js';
3
3
  import { NamedTypeEntity, PackageAliasEntity, VariableEntity } from '../entities/index.js';
4
4
  import * as tree from '../tree/index.js';
5
5
  import * as types from '../types/index.js';
6
- import { AccessedFunction } from './AccessedFunction.js';
6
+ import { AccessedFunction, NotSubstitutedAccessedFunction } from './AccessedFunction.js';
7
+ import * as callExpressionMeaning from './CallExpressionMeaning.js';
7
8
  import { PackageNameTreeNode } from './ImportedPackageNameTree.js';
8
- import { Analyzer, TargetTypeHint } from './index.js';
9
+ import { Analyzer, InferenceOptions } from './index.js';
9
10
  import { NamedDeclaration } from './semantic-context/index.js';
10
- export declare class Resolver {
11
+ export declare class FirstStageResolver {
11
12
  private readonly _semanticContext;
12
13
  private readonly _analyzer;
13
14
  private readonly _node;
14
- private readonly _targetTypeHint;
15
15
  private get semanticContext();
16
- constructor(analyzer: Analyzer, node: tree.IdentifierExpression, targetTypeHint: TargetTypeHint | undefined);
17
- resolve(): ResolutionResult;
16
+ constructor(analyzer: Analyzer, node: tree.IdentifierExpression);
17
+ resolve(): FirstStageResolutionResult;
18
18
  private tryResolveOperatorAccessMeaning;
19
- private resolveFunctionOverload;
20
- private createAccessedFunction;
19
+ private resolveTypeAccess;
20
+ private createNotSubstitutedAccessedFunction;
21
21
  private convertSyntacticAccessKind;
22
22
  }
23
+ export declare class SecondStageResolver {
24
+ private readonly _analyzer;
25
+ private readonly _node;
26
+ private readonly _firstStageResolutionResult;
27
+ private readonly _inferenceOptions;
28
+ constructor(analyzer: Analyzer, node: tree.IdentifierExpression, firstStageResolutionResult: FirstStageResolutionResult, inferenceOptions: InferenceOptions | undefined);
29
+ resolve(): ResolutionResult;
30
+ private resolveTypeAccessAtCalleePosition;
31
+ private resolveFunctionAccess;
32
+ private resolveOperatorAccess;
33
+ private resolveNotCalledFunctionsAccess;
34
+ }
23
35
  export declare class ResolutionResult {
24
36
  readonly meaning: Meaning;
25
- readonly diagnostic?: Diagnostic | undefined;
26
- /**
27
- * Может ли измениться результат, если посчитать его с другим целевым типом?
28
- */
29
- readonly dependsOnTargetType: boolean;
30
- constructor(meaning: Meaning, diagnostic?: Diagnostic | undefined,
31
- /**
32
- * Может ли измениться результат, если посчитать его с другим целевым типом?
33
- */
34
- dependsOnTargetType?: boolean);
35
- }
36
- export type Meaning = Meaning_variableAccess | Meaning_functionAccess | Meaning_operatorAccess | Meaning_packageNameSegmentAccess | Meaning_packageAliasAccess | Meaning_typeAccess | Meaning_mixedAmbiguousAccess | Meaning_unresolved;
37
+ readonly diagnostics: readonly Diagnostic[] | undefined;
38
+ constructor(meaning: Meaning, diagnostics?: Diagnostic | readonly Diagnostic[]);
39
+ }
40
+ export type Meaning = Meaning_variableAccess | Meaning_functionAccess | Meaning_operatorAccess | Meaning_packageNameSegmentAccess | Meaning_packageAliasAccess | Meaning_typeAccess | Meaning_constructorAccess | Meaning_mixedAmbiguousAccess | Meaning_unresolved;
37
41
  declare class Meaning_variableAccess {
38
42
  readonly variable: AccessedVariable;
39
43
  readonly accessKind: AccessKind;
@@ -41,17 +45,20 @@ declare class Meaning_variableAccess {
41
45
  constructor(variable: AccessedVariable, accessKind: AccessKind);
42
46
  }
43
47
  declare class Meaning_functionAccess {
44
- readonly candidates: readonly AccessedFunction[];
48
+ readonly candidates: readonly NotSubstitutedAccessedFunction[];
45
49
  readonly suitableFunctions: readonly AccessedFunction[];
50
+ readonly singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined;
46
51
  readonly kind = "function-access";
47
52
  get singleSuitableFunction(): AccessedFunction | undefined;
48
- constructor(candidates: readonly AccessedFunction[], suitableFunctions: readonly AccessedFunction[]);
53
+ get singleFunction(): AccessedFunction | undefined;
54
+ constructor(candidates: readonly NotSubstitutedAccessedFunction[], suitableFunctions: readonly AccessedFunction[], singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined);
49
55
  }
50
56
  declare class Meaning_operatorAccess {
51
57
  readonly candidates: readonly types.Operator[];
52
58
  readonly suitableOperators: readonly types.Operator[];
53
59
  readonly kind = "operator-access";
54
60
  get singleSuitableOperator(): types.Operator | undefined;
61
+ get singleOperator(): types.Operator | undefined;
55
62
  constructor(candidates: readonly types.Operator[], suitableOperators: readonly types.Operator[]);
56
63
  }
57
64
  declare class Meaning_packageAliasAccess {
@@ -71,6 +78,12 @@ declare class Meaning_typeAccess {
71
78
  get singleSuitableType(): types.Type | undefined;
72
79
  constructor(candidates: readonly NamedTypeEntity[], suitableTypes: readonly types.Type[]);
73
80
  }
81
+ declare class Meaning_constructorAccess {
82
+ readonly typeCandidates: readonly NamedTypeEntity[];
83
+ readonly callExpressionMeaning: callExpressionMeaning.Meaning_constructorCall;
84
+ readonly kind = "constructor-access";
85
+ constructor(typeCandidates: readonly NamedTypeEntity[], callExpressionMeaning: callExpressionMeaning.Meaning_constructorCall);
86
+ }
74
87
  declare class Meaning_mixedAmbiguousAccess {
75
88
  readonly declarations: readonly NamedDeclaration[];
76
89
  readonly kind = "mixed-ambiguous-access";
@@ -79,6 +92,27 @@ declare class Meaning_mixedAmbiguousAccess {
79
92
  declare class Meaning_unresolved {
80
93
  readonly kind = "unresolved";
81
94
  }
95
+ export declare class FirstStageResolutionResult {
96
+ readonly meaning: MeaningStage1;
97
+ readonly diagnostics: readonly Diagnostic[] | undefined;
98
+ constructor(meaning: MeaningStage1, diagnostics?: Diagnostic | readonly Diagnostic[]);
99
+ }
100
+ export type MeaningStage1 = Meaning_variableAccess | MeaningStage1_functionAccess | MeaningStage1_operatorAccess | Meaning_packageNameSegmentAccess | Meaning_packageAliasAccess | MeaningStage1_typeAccessAtCalleePosition | Meaning_typeAccess | Meaning_mixedAmbiguousAccess | Meaning_unresolved;
101
+ declare class MeaningStage1_typeAccessAtCalleePosition {
102
+ readonly types: readonly NamedTypeEntity[];
103
+ readonly kind = "type-access-at-callee-position";
104
+ constructor(types: readonly NamedTypeEntity[]);
105
+ }
106
+ declare class MeaningStage1_functionAccess {
107
+ readonly functions: readonly NotSubstitutedAccessedFunction[];
108
+ readonly kind = "function-access";
109
+ constructor(functions: readonly NotSubstitutedAccessedFunction[]);
110
+ }
111
+ declare class MeaningStage1_operatorAccess {
112
+ readonly operators: readonly types.Operator[];
113
+ readonly kind = "operator-access";
114
+ constructor(operators: readonly types.Operator[]);
115
+ }
82
116
  export type AccessedVariable = AccessedVariable_entity | AccessedVariable_typeMember;
83
117
  export declare class AccessedVariable_entity implements IAccessedVariable {
84
118
  readonly value: VariableEntity;
@@ -15,8 +15,8 @@ export declare class Resolver {
15
15
  }
16
16
  export declare class ResolutionResult {
17
17
  readonly meaning: Meaning;
18
- readonly diagnostic?: Diagnostic | undefined;
19
- constructor(meaning: Meaning, diagnostic?: Diagnostic | undefined);
18
+ readonly diagnostics?: readonly Diagnostic[] | undefined;
19
+ constructor(meaning: Meaning, diagnostics?: readonly Diagnostic[] | undefined);
20
20
  }
21
21
  export type Meaning = Meaning_resolved | Meaning_unresolved;
22
22
  declare class Meaning_resolved {
@@ -25,6 +25,7 @@ declare class Meaning_resolved {
25
25
  readonly accessKind: AccessKind;
26
26
  readonly kind = "resolved";
27
27
  get singleSuitableIndexer(): types.Indexer | undefined;
28
+ get singleIndexer(): types.Indexer | undefined;
28
29
  constructor(candidates: readonly types.Indexer[], suitableIndexers: readonly types.Indexer[], accessKind: AccessKind);
29
30
  }
30
31
  declare class Meaning_unresolved {
@@ -3,44 +3,48 @@ import { Diagnostic } from '../diagnostic/Diagnostic.js';
3
3
  import { Entity, PackageTypeEntity, PackageVariableEntity } from '../entities/index.js';
4
4
  import * as tree from '../tree/index.js';
5
5
  import * as types from '../types/index.js';
6
- import { AccessedFunction } from './AccessedFunction.js';
6
+ import { AccessedFunction, NotSubstitutedAccessedFunction } from './AccessedFunction.js';
7
+ import * as callExpressionMeaning from './CallExpressionMeaning.js';
7
8
  import { PackageNameTreeNode } from './ImportedPackageNameTree.js';
8
- import { Analyzer, TargetTypeHint } from './index.js';
9
- export declare class Resolver {
9
+ import { Analyzer, InferenceOptions } from './index.js';
10
+ export declare class FirstStageResolver {
10
11
  private readonly _semanticContext;
11
12
  private readonly _analyzer;
12
13
  private readonly _node;
13
- private readonly _targetTypeHint;
14
14
  private get memberName();
15
15
  private get semanticContext();
16
16
  private get receiver();
17
- constructor(analyzer: Analyzer, node: tree.MemberAccessExpression, targetTypeHint: TargetTypeHint | undefined);
18
- resolve(): ResolutionResult;
17
+ constructor(analyzer: Analyzer, node: tree.MemberAccessExpression);
18
+ resolve(): FirstStageResolutionResult;
19
19
  private resolvePackageAliasMemberAccessMeaning;
20
20
  private resolvePackageMemberAccessMeaning;
21
+ private resolveTypeAccess;
21
22
  private resolvePackageNameSegmentAccessMeaning;
22
- private createAccessedFunctionFromPackageMember;
23
23
  private resolveStaticMemberOrVariantAccessMeaning;
24
- private createAccessedFunctionFromTypeMember;
25
24
  private resolveInstanceMemberAccessMeaning;
26
25
  private tryResolveInstanceOperatorAccessMeaning;
27
- private resolveFunctionOverload;
28
26
  private convertSyntacticAccessKind;
29
27
  }
28
+ export declare class SecondStageResolver {
29
+ private readonly _analyzer;
30
+ private readonly _node;
31
+ private readonly _firstStageResolutionResult;
32
+ private readonly _inferenceOptions;
33
+ constructor(analyzer: Analyzer, node: tree.MemberAccessExpression, firstStageResolutionResult: FirstStageResolutionResult, inferenceOptions: InferenceOptions | undefined);
34
+ resolve(): ResolutionResult;
35
+ private resolveTypeAccessAtCalleePosition;
36
+ private resolvePackageFunctionAccess;
37
+ private resolveStaticMethodAccess;
38
+ private resolveInstanceMethodAccess;
39
+ private resolveNotCalledFunctionsAccess;
40
+ private resolveOperatorAccess;
41
+ }
30
42
  export declare class ResolutionResult {
31
43
  readonly meaning: Meaning;
32
- readonly diagnostic?: Diagnostic | undefined;
33
- /**
34
- * Может ли измениться результат, если посчитать его с другим целевым типом?
35
- */
36
- readonly dependsOnTargetType: boolean;
37
- constructor(meaning: Meaning, diagnostic?: Diagnostic | undefined,
38
- /**
39
- * Может ли измениться результат, если посчитать его с другим целевым типом?
40
- */
41
- dependsOnTargetType?: boolean);
42
- }
43
- export type Meaning = Meaning_packageVariableAccess | Meaning_packageFunctionAccess | Meaning_packageTypeAccess | Meaning_packageNameSegmentAccess | Meaning_staticFieldAccess | Meaning_staticMethodAccess | Meaning_instanceFieldAccess | Meaning_instanceMethodAccess | Meaning_operatorAccess | Meaning_mixedAmbiguousAccess | Meaning_unresolved;
44
+ readonly diagnostics: readonly Diagnostic[] | undefined;
45
+ constructor(meaning: Meaning, diagnostics?: Diagnostic | readonly Diagnostic[]);
46
+ }
47
+ export type Meaning = Meaning_packageVariableAccess | Meaning_packageFunctionAccess | Meaning_packageTypeAccess | Meaning_constructorAccess | Meaning_packageNameSegmentAccess | Meaning_staticFieldAccess | Meaning_staticMethodAccess | Meaning_instanceFieldAccess | Meaning_instanceMethodAccess | Meaning_operatorAccess | Meaning_mixedAmbiguousAccess | Meaning_unresolved;
44
48
  declare class Meaning_packageVariableAccess {
45
49
  readonly variable: PackageVariableEntity;
46
50
  readonly accessKind: AccessKind;
@@ -48,11 +52,13 @@ declare class Meaning_packageVariableAccess {
48
52
  constructor(variable: PackageVariableEntity, accessKind: AccessKind);
49
53
  }
50
54
  declare class Meaning_packageFunctionAccess {
51
- readonly candidates: readonly AccessedFunction[];
55
+ readonly candidates: readonly NotSubstitutedAccessedFunction[];
52
56
  readonly suitableFunctions: readonly AccessedFunction[];
57
+ readonly singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined;
53
58
  readonly kind = "package-function-access";
54
59
  get singleSuitableFunction(): AccessedFunction | undefined;
55
- constructor(candidates: readonly AccessedFunction[], suitableFunctions: readonly AccessedFunction[]);
60
+ get singleFunction(): AccessedFunction | undefined;
61
+ constructor(candidates: readonly NotSubstitutedAccessedFunction[], suitableFunctions: readonly AccessedFunction[], singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined);
56
62
  }
57
63
  declare class Meaning_packageTypeAccess {
58
64
  readonly candidates: readonly PackageTypeEntity[];
@@ -61,6 +67,12 @@ declare class Meaning_packageTypeAccess {
61
67
  get singleSuitableType(): types.Type | undefined;
62
68
  constructor(candidates: readonly PackageTypeEntity[], suitableTypes: readonly types.Type[]);
63
69
  }
70
+ declare class Meaning_constructorAccess {
71
+ readonly typeCandidates: readonly PackageTypeEntity[];
72
+ readonly callExpressionMeaning: callExpressionMeaning.Meaning_constructorCall;
73
+ readonly kind = "constructor-access";
74
+ constructor(typeCandidates: readonly PackageTypeEntity[], callExpressionMeaning: callExpressionMeaning.Meaning_constructorCall);
75
+ }
64
76
  declare class Meaning_packageNameSegmentAccess {
65
77
  readonly packageTreeNode: PackageNameTreeNode;
66
78
  readonly kind = "package-name-segment-access";
@@ -75,11 +87,13 @@ declare class Meaning_staticFieldAccess {
75
87
  }
76
88
  declare class Meaning_staticMethodAccess {
77
89
  readonly type: types.Type;
78
- readonly candidates: readonly AccessedFunction[];
90
+ readonly candidates: readonly NotSubstitutedAccessedFunction[];
79
91
  readonly suitableFunctions: readonly AccessedFunction[];
92
+ readonly singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined;
80
93
  readonly kind = "static-method-access";
81
94
  get singleSuitableFunction(): AccessedFunction | undefined;
82
- constructor(type: types.Type, candidates: readonly AccessedFunction[], suitableFunctions: readonly AccessedFunction[]);
95
+ get singleFunction(): AccessedFunction | undefined;
96
+ constructor(type: types.Type, candidates: readonly NotSubstitutedAccessedFunction[], suitableFunctions: readonly AccessedFunction[], singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined);
83
97
  }
84
98
  declare class Meaning_instanceFieldAccess {
85
99
  readonly field: types.Field;
@@ -88,17 +102,20 @@ declare class Meaning_instanceFieldAccess {
88
102
  constructor(field: types.Field, accessKind: AccessKind);
89
103
  }
90
104
  declare class Meaning_instanceMethodAccess {
91
- readonly candidates: readonly AccessedFunction[];
105
+ readonly candidates: readonly NotSubstitutedAccessedFunction[];
92
106
  readonly suitableFunctions: readonly AccessedFunction[];
107
+ readonly singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined;
93
108
  readonly kind = "instance-method-access";
94
109
  get singleSuitableFunction(): AccessedFunction | undefined;
95
- constructor(candidates: readonly AccessedFunction[], suitableFunctions: readonly AccessedFunction[]);
110
+ get singleFunction(): AccessedFunction | undefined;
111
+ constructor(candidates: readonly NotSubstitutedAccessedFunction[], suitableFunctions: readonly AccessedFunction[], singleNotSuitableSubstitutedCandidate: AccessedFunction | undefined);
96
112
  }
97
113
  declare class Meaning_operatorAccess {
98
114
  readonly candidates: readonly types.Operator[];
99
115
  readonly suitableOperators: readonly types.Operator[];
100
116
  readonly kind = "operator-access";
101
117
  get singleSuitableOperator(): types.Operator | undefined;
118
+ get singleOperator(): types.Operator | undefined;
102
119
  constructor(candidates: readonly types.Operator[], suitableOperators: readonly types.Operator[]);
103
120
  }
104
121
  declare class Meaning_mixedAmbiguousAccess {
@@ -109,4 +126,36 @@ declare class Meaning_mixedAmbiguousAccess {
109
126
  declare class Meaning_unresolved {
110
127
  readonly kind = "unresolved";
111
128
  }
129
+ export declare class FirstStageResolutionResult {
130
+ readonly meaning: MeaningStage1;
131
+ readonly diagnostics: readonly Diagnostic[] | undefined;
132
+ constructor(meaning: MeaningStage1, diagnostics?: Diagnostic | readonly Diagnostic[]);
133
+ }
134
+ export type MeaningStage1 = Meaning_packageVariableAccess | MeaningStage1_packageFunctionAccess | Meaning_packageTypeAccess | MeaningStage1_typeAccessAtCalleePosition | Meaning_packageNameSegmentAccess | Meaning_staticFieldAccess | MeaningStage1_staticMethodAccess | Meaning_instanceFieldAccess | MeaningStage1_instanceMethodAccess | MeaningStage1_operatorAccess | Meaning_mixedAmbiguousAccess | Meaning_unresolved;
135
+ declare class MeaningStage1_typeAccessAtCalleePosition {
136
+ readonly types: readonly PackageTypeEntity[];
137
+ readonly kind = "type-access-at-callee-position";
138
+ constructor(types: readonly PackageTypeEntity[]);
139
+ }
140
+ declare class MeaningStage1_packageFunctionAccess {
141
+ readonly functions: readonly NotSubstitutedAccessedFunction[];
142
+ readonly kind = "package-function-access";
143
+ constructor(functions: readonly NotSubstitutedAccessedFunction[]);
144
+ }
145
+ declare class MeaningStage1_staticMethodAccess {
146
+ readonly type: types.Type;
147
+ readonly functions: readonly NotSubstitutedAccessedFunction[];
148
+ readonly kind = "static-method-access";
149
+ constructor(type: types.Type, functions: readonly NotSubstitutedAccessedFunction[]);
150
+ }
151
+ declare class MeaningStage1_instanceMethodAccess {
152
+ readonly functions: readonly NotSubstitutedAccessedFunction[];
153
+ readonly kind = "instance-method-access";
154
+ constructor(functions: readonly NotSubstitutedAccessedFunction[]);
155
+ }
156
+ declare class MeaningStage1_operatorAccess {
157
+ readonly operators: readonly types.Operator[];
158
+ readonly kind = "operator-access";
159
+ constructor(operators: readonly types.Operator[]);
160
+ }
112
161
  export {};
@@ -9,7 +9,6 @@ export declare class NamedTypeSpecifierResolver {
9
9
  private readonly _node;
10
10
  constructor(_analyzer: Analyzer, _node: NamedTypeSpecifier);
11
11
  resolve(): NamedTypeSpecifierResolutionResult;
12
- private resolveTypeOverload;
13
12
  }
14
13
  export declare class NamedTypeSpecifierResolutionResult {
15
14
  readonly type: types.Type | undefined;
@@ -14,6 +14,7 @@ export declare class NodeTypeUtils {
14
14
  static isVariantTypeDeclaration(node: tree.Node): node is VariantTypeDeclaration;
15
15
  static isNullLiteral(node: tree.Node): boolean;
16
16
  static isSubprogramDeclarationOrLiteral(node: tree.Node): node is SubprogramDeclarationOrLiteral;
17
+ static isRegularOrBlockFunctionLiteral(node: tree.Node): node is RegularOrBlockFunctionLiteral;
17
18
  }
18
19
  export type PackageTypeDeclaration = tree.PackageAliasTypeDeclaration | tree.PackageFunctionTypeDeclaration | tree.PackageStructuredTypeDeclaration | tree.PackageVariantTypeDeclaration;
19
20
  export type StructuredTypeDeclaration = tree.PackageStructuredTypeDeclaration | tree.AnonymousStructuredTypeDeclaration;
@@ -37,6 +37,7 @@ declare class Meaning_ownConstructorAccess {
37
37
  readonly suitableConstructors: readonly types.Constructor[];
38
38
  readonly kind = "own-constructor-access";
39
39
  get singleSuitableConstructor(): types.Constructor | undefined;
40
+ get singleConstructor(): types.Constructor | undefined;
40
41
  constructor(
41
42
  /**
42
43
  * Тип объекта, получаемого в результате вызова конструктора.
@@ -0,0 +1,9 @@
1
+ import { DiagnosticAcceptorWithArgumentFactory } from '../diagnostic/Diagnostic.js';
2
+ import * as tree from '../tree/index.js';
3
+ import * as types from '../types/index.js';
4
+ import { Analyzer } from './Analyzer.js';
5
+ export declare class Resolver {
6
+ static resolveByCallExpression(analyzer: Analyzer, candidates: readonly types.Operator[], node: tree.CallExpression, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined): readonly types.Operator[];
7
+ static resolveByTargetType(analyzer: Analyzer, candidates: readonly types.Operator[], targetType: types.Type | undefined, diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined, nodeForDiagnostic: tree.Node | undefined): readonly types.Operator[];
8
+ private static reportAmbiguousAccessDiagnostic;
9
+ }
@@ -1,12 +1,98 @@
1
- import { Analyzer } from '../analysis/index.js';
1
+ import { Analyzer, InferenceOptions } from '../analysis/index.js';
2
+ import { Displayable, Name } from '../common/index.js';
3
+ import { DiagnosticAcceptorWithArgumentFactory, DiagnosticLocation } from '../diagnostic/Diagnostic.js';
4
+ import { TypeParameterEntity } from '../entities/index.js';
5
+ import * as tree from '../tree/index.js';
6
+ import * as types from '../types/index.js';
2
7
  import * as matcher from './ArgumentsToParametersMatcher.js';
3
- export declare class OverloadResolver<TSignature extends matcher.ISignature<TParameter>, TParameter extends matcher.ISignatureParameter, TArgument extends matcher.IArgument> {
8
+ import { DiagnosticArgumentFactory } from './DiagnosticArgumentFactory.js';
9
+ import * as inferrer from './TypeArgumentInferrer.js';
10
+ export declare class OverloadResolver<TSignature extends ISignature<TParameter>, TParameter extends ISignatureParameter, TArgument extends Argument> {
4
11
  private readonly _analyzer;
12
+ private readonly _mode;
5
13
  private readonly _signatures;
6
14
  private readonly _arguments;
7
- constructor(_analyzer: Analyzer, _signatures: readonly TSignature[], _arguments: readonly TArgument[]);
8
- resolveOverload(): TSignature[];
15
+ private readonly _inferenceOptions;
16
+ private readonly _dataForTypeArgumentInference;
17
+ private readonly _diagnostics;
18
+ private readonly _nodesForDiagnostic;
19
+ constructor(_analyzer: Analyzer, _mode: ResolutionMode, _signatures: readonly TSignature[], _arguments: readonly TArgument[], _inferenceOptions: InferenceOptions, _dataForTypeArgumentInference: DataForTypeArgumentInference | undefined, _diagnostics: DiagnosticAcceptorWithArgumentFactory | undefined, _nodesForDiagnostic: NodesForDiagnostic | undefined);
20
+ resolveOverload(): ProcessedSignature<TSignature, TParameter, TArgument>[];
21
+ private areArgumentTypesAssignableToParameterTypes;
9
22
  private tryChooseBestSignature;
10
23
  private chooseBetterTargetType;
11
- private getDistanceBetweenTypesInHierarchy;
24
+ private functionLiteralCouldBeAssignableToType;
25
+ private reportAmbiguousAccessDiagnostic;
12
26
  }
27
+ export interface ISignature<TParameter extends ISignatureParameter> extends matcher.ISignature<TParameter> {
28
+ getTypeParameters(): readonly TypeParameterEntity[];
29
+ getParameters(): readonly TParameter[];
30
+ getReturnType(): types.Type | undefined;
31
+ getOuterSubstitutions(): types.Substitutions | undefined;
32
+ toDisplayable(factory: DiagnosticArgumentFactory): Displayable;
33
+ }
34
+ export interface ISignatureParameter extends matcher.ISignatureParameter {
35
+ getType(): types.Type;
36
+ getIndex(): number;
37
+ }
38
+ export type ResolutionMode = ResolutionByExplicitArguments | ResolutionByTargetType;
39
+ export declare class ResolutionByExplicitArguments {
40
+ readonly kind = "by-explicit-arguments";
41
+ }
42
+ export declare class ResolutionByTargetType {
43
+ readonly targetType: types.FunctionType;
44
+ readonly kind = "by-target-type";
45
+ constructor(targetType: types.FunctionType);
46
+ }
47
+ export type Argument = SourceArgument | IntrinsicArgument;
48
+ export interface SourceArgument extends matcher.IArgument, inferrer.SourceArgument, IArgument {
49
+ readonly kind: 'source';
50
+ readonly expression: tree.Expression;
51
+ }
52
+ export declare class IntrinsicArgument implements matcher.IArgument, inferrer.IntrinsicArgument, IArgument {
53
+ readonly kind = "intrinsic";
54
+ readonly type: types.Type;
55
+ get name(): Name | undefined;
56
+ constructor(type: types.Type);
57
+ getDiagnosticLocation(): DiagnosticLocation | undefined;
58
+ getType(_inferenceOptions: InferenceOptions | undefined): types.Type;
59
+ }
60
+ interface IArgument {
61
+ getType(inferenceOptions: InferenceOptions | undefined): types.Type;
62
+ }
63
+ export declare class SourceNodeArgument implements SourceArgument {
64
+ readonly kind = "source";
65
+ readonly node: tree.Argument;
66
+ readonly name: Name | undefined;
67
+ private readonly _analyzer;
68
+ get expression(): tree.Expression;
69
+ constructor(analyzer: Analyzer, node: tree.Argument);
70
+ getDiagnosticLocation(): DiagnosticLocation;
71
+ getType(inferenceOptions: InferenceOptions | undefined): types.Type;
72
+ }
73
+ export declare class SourceExpressionArgument implements SourceArgument {
74
+ private readonly _analyzer;
75
+ readonly expression: tree.Expression;
76
+ readonly kind = "source";
77
+ get name(): Name | undefined;
78
+ constructor(_analyzer: Analyzer, expression: tree.Expression);
79
+ getDiagnosticLocation(): DiagnosticLocation;
80
+ getType(inferenceOptions: InferenceOptions | undefined): types.Type;
81
+ }
82
+ export declare class DataForTypeArgumentInference {
83
+ readonly specifiedTypeArguments: readonly types.Type[];
84
+ readonly targetType: types.Type | undefined;
85
+ constructor(specifiedTypeArguments: readonly types.Type[], targetType: types.Type | undefined);
86
+ }
87
+ export interface NodesForDiagnostic {
88
+ readonly accessNode: tree.Node | undefined;
89
+ readonly typeArgumentClause: tree.Node | undefined;
90
+ readonly argumentList: tree.Node | undefined;
91
+ }
92
+ export interface ProcessedSignature<TSignature extends ISignature<TParameter>, TParameter extends ISignatureParameter, TArgument extends matcher.IArgument> {
93
+ readonly value: TSignature;
94
+ readonly matchResult: matcher.MatchResult<TParameter, TArgument>;
95
+ readonly typeArguments: readonly types.Type[] | undefined;
96
+ readonly isMatching: boolean;
97
+ }
98
+ export {};