@@ -5129,7 +5129,8 @@ namespace ts {
51295129 const excludeModifiers = isUnion ? ModifierFlags.NonPublicAccessibilityModifier : 0;
51305130 // Flags we want to propagate to the result if they exist in all source symbols
51315131 let commonFlags = isUnion ? SymbolFlags.None : SymbolFlags.Optional;
5132- let checkFlags = CheckFlags.SyntheticProperty;
5132+ let syntheticFlag = CheckFlags.SyntheticMethod;
5133+ let checkFlags = 0;
51335134 for (const current of types) {
51345135 const type = getApparentType(current);
51355136 if (type !== unknownType) {
@@ -5148,6 +5149,9 @@ namespace ts {
51485149 (modifiers & ModifierFlags.Protected ? CheckFlags.ContainsProtected : 0) |
51495150 (modifiers & ModifierFlags.Private ? CheckFlags.ContainsPrivate : 0) |
51505151 (modifiers & ModifierFlags.Static ? CheckFlags.ContainsStatic : 0);
5152+ if (!isMethodLike(prop)) {
5153+ syntheticFlag = CheckFlags.SyntheticProperty;
5154+ }
51515155 }
51525156 else if (isUnion) {
51535157 checkFlags |= CheckFlags.Partial;
@@ -5177,7 +5181,7 @@ namespace ts {
51775181 propTypes.push(type);
51785182 }
51795183 const result = createSymbol(SymbolFlags.Property | commonFlags, name);
5180- result.checkFlags = checkFlags;
5184+ result.checkFlags = syntheticFlag | checkFlags;
51815185 result.containingType = containingType;
51825186 result.declarations = declarations;
51835187 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
@@ -8630,7 +8634,7 @@ namespace ts {
86308634 // Invoke the callback for each underlying property symbol of the given symbol and return the first
86318635 // value that isn't undefined.
86328636 function forEachProperty<T>(prop: Symbol, callback: (p: Symbol) => T): T {
8633- if (getCheckFlags(prop) & CheckFlags.SyntheticProperty ) {
8637+ if (getCheckFlags(prop) & CheckFlags.Synthetic ) {
86348638 for (const t of (<TransientSymbol>prop).containingType.types) {
86358639 const p = getPropertyOfType(t, prop.name);
86368640 const result = p && forEachProperty(p, callback);
@@ -13112,7 +13116,7 @@ namespace ts {
1311213116 const flags = getCombinedModifierFlags(s.valueDeclaration);
1311313117 return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier;
1311413118 }
13115- if (getCheckFlags(s) & CheckFlags.SyntheticProperty ) {
13119+ if (getCheckFlags(s) & CheckFlags.Synthetic ) {
1311613120 const checkFlags = (<TransientSymbol>s).checkFlags;
1311713121 const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private :
1311813122 checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public :
@@ -13130,6 +13134,10 @@ namespace ts {
1313013134 return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0;
1313113135 }
1313213136
13137+ function isMethodLike(symbol: Symbol) {
13138+ return !!(symbol.flags & SymbolFlags.Method || getCheckFlags(symbol) & CheckFlags.SyntheticMethod);
13139+ }
13140+
1313313141 /**
1313413142 * Check whether the requested property access is valid.
1313513143 * Returns true if node is a valid property access, and false otherwise.
@@ -13159,11 +13167,11 @@ namespace ts {
1315913167 // where this references the constructor function object of a derived class,
1316013168 // a super property access is permitted and must specify a public static member function of the base class.
1316113169 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) {
1316713175 error(errorNode, Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
1316813176 return false;
1316913177 }
@@ -19697,7 +19705,7 @@ namespace ts {
1969719705 else {
1969819706 // derived overrides base.
1969919707 const derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived);
19700- if (( baseDeclarationFlags & ModifierFlags.Private) || ( derivedDeclarationFlags & ModifierFlags.Private) ) {
19708+ if (baseDeclarationFlags & ModifierFlags.Private || derivedDeclarationFlags & ModifierFlags.Private) {
1970119709 // either base or derived property is private - not override, skip it
1970219710 continue;
1970319711 }
@@ -19707,28 +19715,24 @@ namespace ts {
1970719715 continue;
1970819716 }
1970919717
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) {
1971119719 // method is overridden with method or property/accessor is overridden with property/accessor - correct case
1971219720 continue;
1971319721 }
1971419722
1971519723 let errorMessage: DiagnosticMessage;
19716- if (base.flags & SymbolFlags.Method ) {
19724+ if (isMethodLike( base) ) {
1971719725 if (derived.flags & SymbolFlags.Accessor) {
1971819726 errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
1971919727 }
1972019728 else {
19721- Debug.assert((derived.flags & SymbolFlags.Property) !== 0);
1972219729 errorMessage = Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property;
1972319730 }
1972419731 }
1972519732 else if (base.flags & SymbolFlags.Property) {
19726- Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
1972719733 errorMessage = Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
1972819734 }
1972919735 else {
19730- Debug.assert((base.flags & SymbolFlags.Accessor) !== 0);
19731- Debug.assert((derived.flags & SymbolFlags.Method) !== 0);
1973219736 errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
1973319737 }
1973419738
@@ -21387,7 +21391,7 @@ namespace ts {
2138721391 }
2138821392
2138921393 function getRootSymbols(symbol: Symbol): Symbol[] {
21390- if (getCheckFlags(symbol) & CheckFlags.SyntheticProperty ) {
21394+ if (getCheckFlags(symbol) & CheckFlags.Synthetic ) {
2139121395 const symbols: Symbol[] = [];
2139221396 const name = symbol.name;
2139321397 forEach(getSymbolLinks(symbol).containingType.types, t => {
0 commit comments