From: Jean Privat Date: Fri, 3 Apr 2015 02:34:01 +0000 (+0700) Subject: model: protect MClassDef.is_intro and provide MClass.try_intro X-Git-Tag: v0.7.4~40^2~11 X-Git-Url: http://nitlanguage.org model: protect MClassDef.is_intro and provide MClass.try_intro Signed-off-by: Jean Privat --- diff --git a/src/model/model.nit b/src/model/model.nit index 76a3839..754f57a 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -433,8 +433,17 @@ class MClass # # Warning: such a definition may not exist in the early life of the object. # In this case, the method will abort. + # + # Use `try_intro` instead var intro: MClassDef is noinit + # The definition that introduces the class or null if not yet known. + # + # See `intro` + fun try_intro: nullable MClassDef do + if isset _intro then return _intro else return null + end + # Return the class `self` in the class hierarchy of the module `mmodule`. # # SEE: `MModule::flatten_mclass_hierarchy` @@ -627,7 +636,7 @@ class MClassDef var in_hierarchy: nullable POSetElement[MClassDef] = null # Is the definition the one that introduced `mclass`? - fun is_intro: Bool do return mclass.intro == self + fun is_intro: Bool do return isset mclass._intro and mclass.intro == self # All properties introduced by the classdef var intro_mproperties = new Array[MProperty]