# See the License for the specific language governing permissions and
# limitations under the License.
-# Computing of super-constructors that must be implicitely called at the begin of constructors.
+# Computing of super-constructors that must be implicitly called at the begin of constructors.
# The current rules are a bit crazy but whatever.
module auto_super_init
private import annotation
redef class ToolContext
+ # Phase that inject `super` in constructors that need it.
var auto_super_init_phase: Phase = new AutoSuperInitPhase(self, [typing_phase])
end
end
var has_explicit_super_init: nullable ANode = null
+
+ # The method is broken, so avoid to display additional errors
+ var is_broken = false
end
var nosuper = get_single_annotation("nosuper", modelbuilder)
# Collect only for constructors
- if not mpropdef.mproperty.is_init then
+ if not mpropdef.mproperty.is_init or mpropdef.mproperty.is_new then
if nosuper != null then modelbuilder.error(nosuper, "Error: nosuper only in `init`")
return
end
if nosuper != null then modelbuilder.error(anode, "Error: method is annotated nosuper but a constructor call is present")
return
end
+ if v.is_broken then return # skip
end
if nosuper != null then return
redef class ASendExpr
redef fun accept_auto_super_init(v)
do
- var mproperty = self.callsite.mproperty
- if mproperty == null then return
- if mproperty.is_init then
+ var callsite = self.callsite
+ if callsite == null then
+ v.is_broken = true
+ return
+ end
+ if callsite.mproperty.is_init then
v.has_explicit_super_init = self
end
end