Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

77 lines
1.6 KiB
Plaintext

== Why is this an issue?
There are situations where ``++super()++`` must be invoked and situations where ``++super()++`` cannot be invoked.
The basic rule is: a constructor in a non-derived class cannot invoke ``++super()++``; a constructor in a derived class must invoke ``++super()++``.
Furthermore:
* ``++super()++`` must be invoked before the ``++this++`` and ``++super++`` keywords can be used.
* ``++super()++`` must be invoked with the same number of arguments as the base class' constructor.
* ``++super()++`` can only be invoked in a constructor - not in any other method.
* ``++super()++`` cannot be invoked multiple times in the same constructor.
Some issues are not raised if the base class is not defined in the same file as the current class. This is a known limitation for this rule.
=== Noncompliant code example
[source,javascript]
----
class Dog extends Animal {
constructor(name) {
super();
this.name = name;
super(); // Noncompliant
super.doSomething();
}
}
----
=== Compliant solution
[source,javascript]
----
class Dog extends Animal {
constructor(name) {
super();
this.name = name;
super.doSomething();
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Lacked a call of 'super()' in some code paths.
Expected to call 'super()'.
Unexpected duplicate 'super()'.
Unexpected 'super()' because 'super' is not a constructor.
Unexpected 'super()'.
'super'|'this' is not allowed before 'super()'.
'''
== Comments And Links
(visible only on this page)
=== supercedes: S3833
endif::env-github,rspecator-view[]