@@ -5129,7 +5129,8 @@ namespace ts {
5129
5129
const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;
5130
5130
// Flags we want to propagate to the result if they exist in all source symbols
5131
5131
let commonFlags = isUnion ? SymbolFlags.None : SymbolFlags.Optional;
5132
- let checkFlags = CheckFlags.SyntheticProperty;
5132
+ let syntheticFlag = CheckFlags.SyntheticMethod;
5133
+ let checkFlags = 0;
5133
5134
for (const current of types) {
5134
5135
const type = getApparentType(current);
5135
5136
if (type !== unknownType) {
@@ -5148,6 +5149,9 @@ namespace ts {
5148
5149
(modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) |
5149
5150
(modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) |
5150
5151
(modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0);
5152
+ if (!isMethodLike(prop)) {
5153
+ syntheticFlag = CheckFlags.SyntheticProperty;
5154
+ }
5151
5155
}
5152
5156
else if (isUnion) {
5153
5157
checkFlags |= CheckFlags.Partial;
@@ -5177,7 +5181,7 @@ namespace ts {
5177
5181
propTypes.push(type);
5178
5182
}
5179
5183
const result = createSymbol(SymbolFlags.Property | commonFlags, name);
5180
- result.checkFlags = checkFlags;
5184
+ result.checkFlags = syntheticFlag | checkFlags;
5181
5185
result.containingType = containingType;
5182
5186
result.declarations = declarations;
5183
5187
result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
@@ -8630,7 +8634,7 @@ namespace ts {
8630
8634
// Invoke the callback for each underlying property symbol of the given symbol and return the first
8631
8635
// value that isn't undefined.
8632
8636
function forEachProperty<T>(prop: Symbol, callback: (p: Symbol) => T): T {
8633
- if (getCheckFlags(prop) & CheckFlags.SyntheticProperty ) {
8637
+ if (getCheckFlags(prop) & CheckFlags.Synthetic ) {
8634
8638
for (const t of (<TransientSymbol>prop).containingType.types) {
8635
8639
const p = getPropertyOfType(t, prop.name);
8636
8640
const result = p && forEachProperty(p, callback);
@@ -13112,7 +13116,7 @@ namespace ts {
13112
13116
const flags = getCombinedModifierFlags(s.valueDeclaration);
13113
13117
return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier;
13114
13118
}
13115
- if (getCheckFlags(s) & CheckFlags.SyntheticProperty ) {
13119
+ if (getCheckFlags(s) & CheckFlags.Synthetic ) {
13116
13120
const checkFlags = (<TransientSymbol>s).checkFlags;
13117
13121
const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private :
13118
13122
checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public :
@@ -13130,6 +13134,10 @@ namespace ts {
13130
13134
return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0;
13131
13135
}
13132
13136
13137
+ function isMethodLike(symbol: Symbol) {
13138
+ return !!(symbol.flags & SymbolFlags.Method || getCheckFlags(symbol) & CheckFlags.SyntheticMethod);
13139
+ }
13140
+
13133
13141
/**
13134
13142
* Check whether the requested property access is valid.
13135
13143
* Returns true if node is a valid property access, and false otherwise.
@@ -13159,11 +13167,11 @@ namespace ts {
13159
13167
// where this references the constructor function object of a derived class,
13160
13168
// a super property access is permitted and must specify a public static member function of the base class.
13161
13169
if (languageVersion < ScriptTarget.ES2015) {
13162
- const propKind = getDeclarationKindFromSymbol (prop);
13163
- if (propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature) {
13164
- // `prop` refers to a *property* declared in the super class
13165
- // rather than a *method*, so it does not satisfy the above criteria.
13166
-
13170
+ const hasNonMethodDeclaration = forEachProperty (prop, p => {
13171
+ const propKind = getDeclarationKindFromSymbol(p);
13172
+ return propKind !== SyntaxKind.MethodDeclaration && propKind !== SyntaxKind.MethodSignature;
13173
+ });
13174
+ if (hasNonMethodDeclaration) {
13167
13175
error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
13168
13176
return false;
13169
13177
}
@@ -19697,7 +19705,7 @@ namespace ts {
19697
19705
else {
19698
19706
// derived overrides base.
19699
19707
const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived);
19700
- if (( baseDeclarationFlags & ModifierFlags.Private) || ( derivedDeclarationFlags & ModifierFlags.Private) ) {
19708
+ if (baseDeclarationFlags & ModifierFlags.Private || derivedDeclarationFlags & ModifierFlags.Private) {
19701
19709
// either base or derived property is private - not override, skip it
19702
19710
continue;
19703
19711
}
@@ -19707,28 +19715,24 @@ namespace ts {
19707
19715
continue;
19708
19716
}
19709
19717
19710
- if ((base.flags & derived.flags & SymbolFlags.Method ) || (( base.flags & SymbolFlags.PropertyOrAccessor) && ( derived.flags & SymbolFlags.PropertyOrAccessor)) ) {
19718
+ if (isMethodLike (base) && isMethodLike(derived ) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) {
19711
19719
// method is overridden with method or property/accessor is overridden with property/accessor - correct case
19712
19720
continue;
19713
19721
}
19714
19722
19715
19723
let errorMessage: DiagnosticMessage;
19716
- if (base.flags & SymbolFlags.Method ) {
19724
+ if (isMethodLike( base) ) {
19717
19725
if (derived.flags & SymbolFlags.Accessor) {
19718
19726
errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
19719
19727
}
19720
19728
else {
19721
- Debug.assert((derived.flags & SymbolFlags.Property) !== 0);
19722
19729
errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property;
19723
19730
}
19724
19731
}
19725
19732
else if (base.flags & SymbolFlags.Property) {
19726
- Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
19727
19733
errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
19728
19734
}
19729
19735
else {
19730
- Debug.assert((base.flags & SymbolFlags.Accessor) !== 0);
19731
- Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
19732
19736
errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
19733
19737
}
19734
19738
@@ -21387,7 +21391,7 @@ namespace ts {
21387
21391
}
21388
21392
21389
21393
function getRootSymbols(symbol: Symbol): Symbol[] {
21390
- if (getCheckFlags(symbol) & CheckFlags.SyntheticProperty ) {
21394
+ if (getCheckFlags(symbol) & CheckFlags.Synthetic ) {
21391
21395
const symbols: Symbol[] = [];
21392
21396
const name = symbol.name;
21393
21397
forEach(getSymbolLinks(symbol).containingType.types, t => {
0 commit comments