model: move guards `lookup_first_definition` after cache miss
authorJean Privat <jean@pryen.org>
Tue, 3 Feb 2015 13:54:44 +0000 (20:54 +0700)
committerJean Privat <jean@pryen.org>
Tue, 3 Feb 2015 13:54:44 +0000 (20:54 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index ff12710..677ac69 100644 (file)
@@ -1905,7 +1905,6 @@ abstract class MProperty
        # REQUIRE: `mtype.has_mproperty(mmodule, self)`
        fun lookup_first_definition(mmodule: MModule, mtype: MType): MPROPDEF
        do
-               assert mtype.has_mproperty(mmodule, self)
                return lookup_all_definitions(mmodule, mtype).first
        end
 
@@ -1913,12 +1912,14 @@ abstract class MProperty
        # Most specific first, most general last
        fun lookup_all_definitions(mmodule: MModule, mtype: MType): Array[MPROPDEF]
        do
-               assert not mtype.need_anchor
                mtype = mtype.as_notnullable
 
                var cache = self.lookup_all_definitions_cache[mmodule, mtype]
                if cache != null then return cache
 
+               assert not mtype.need_anchor
+               assert mtype.has_mproperty(mmodule, self)
+
                #print "select prop {mproperty} for {mtype} in {self}"
                # First, select all candidates
                var candidates = new Array[MPROPDEF]