@@ -240,6 +240,7 @@ namespace ts {
240
240
SetAccessor = 2,
241
241
PropertyAssignment = 4,
242
242
Method = 8,
243
+ PrivateStatic = 16,
243
244
GetOrSetAccessor = GetAccessor | SetAccessor,
244
245
PropertyAssignmentOrMethod = PropertyAssignment | Method,
245
246
}
@@ -32131,29 +32132,32 @@ namespace ts {
32131
32132
const isStatic = hasSyntacticModifier(member, ModifierFlags.Static);
32132
32133
const name = member.name;
32133
32134
if (!name) {
32134
- return ;
32135
+ continue ;
32135
32136
}
32137
+ const isPrivate = isPrivateIdentifier(name);
32138
+ const isPrivateStatic = isPrivate && isStatic ? DeclarationMeaning.PrivateStatic : 0;
32136
32139
const names =
32137
- isPrivateIdentifier(name) ? privateIdentifiers :
32140
+ isPrivate ? privateIdentifiers :
32138
32141
isStatic ? staticNames :
32139
32142
instanceNames;
32143
+
32140
32144
const memberName = name && getPropertyNameForPropertyNameNode(name);
32141
32145
if (memberName) {
32142
32146
switch (member.kind) {
32143
32147
case SyntaxKind.GetAccessor:
32144
- addName(names, name, memberName, DeclarationMeaning.GetAccessor);
32148
+ addName(names, name, memberName, DeclarationMeaning.GetAccessor | isPrivateStatic );
32145
32149
break;
32146
32150
32147
32151
case SyntaxKind.SetAccessor:
32148
- addName(names, name, memberName, DeclarationMeaning.SetAccessor);
32152
+ addName(names, name, memberName, DeclarationMeaning.SetAccessor | isPrivateStatic );
32149
32153
break;
32150
32154
32151
32155
case SyntaxKind.PropertyDeclaration:
32152
- addName(names, name, memberName, DeclarationMeaning.GetOrSetAccessor);
32156
+ addName(names, name, memberName, DeclarationMeaning.GetOrSetAccessor | isPrivateStatic );
32153
32157
break;
32154
32158
32155
32159
case SyntaxKind.MethodDeclaration:
32156
- addName(names, name, memberName, DeclarationMeaning.Method);
32160
+ addName(names, name, memberName, DeclarationMeaning.Method | isPrivateStatic );
32157
32161
break;
32158
32162
}
32159
32163
}
@@ -32163,16 +32167,25 @@ namespace ts {
32163
32167
function addName(names: UnderscoreEscapedMap<DeclarationMeaning>, location: Node, name: __String, meaning: DeclarationMeaning) {
32164
32168
const prev = names.get(name);
32165
32169
if (prev) {
32166
- if (prev & DeclarationMeaning.Method) {
32167
- if (meaning !== DeclarationMeaning.Method) {
32168
- error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location));
32169
- }
32170
- }
32171
- else if (prev & meaning) {
32172
- error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location));
32170
+ // For private identifiers, do not allow mixing of static and instance members with the same name
32171
+ if((prev & DeclarationMeaning.PrivateStatic) !== (meaning & DeclarationMeaning.PrivateStatic)) {
32172
+ error(location, Diagnostics.Duplicate_identifier_0_Private_elements_with_the_same_private_name_must_all_be_either_static_or_instance, getTextOfNode(location));
32173
32173
}
32174
32174
else {
32175
- names.set(name, prev | meaning);
32175
+ const prevIsMethod = !!(prev & DeclarationMeaning.Method);
32176
+ const isMethod = !!(meaning & DeclarationMeaning.Method);
32177
+ if (prevIsMethod || isMethod) {
32178
+ if (prevIsMethod !== isMethod) {
32179
+ error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location));
32180
+ }
32181
+ // If this is a method/method duplication is might be an overload, so this will be handled when overloads are considered
32182
+ }
32183
+ else if (prev & meaning & ~DeclarationMeaning.PrivateStatic) {
32184
+ error(location, Diagnostics.Duplicate_identifier_0, getTextOfNode(location));
32185
+ }
32186
+ else {
32187
+ names.set(name, prev | meaning);
32188
+ }
32176
32189
}
32177
32190
}
32178
32191
else {
0 commit comments