autosuper: remove heuristic where a homonymous named constructor is implicitly called
authorJean Privat <jean@pryen.org>
Wed, 25 Nov 2015 14:30:41 +0000 (09:30 -0500)
committerJean Privat <jean@pryen.org>
Tue, 8 Dec 2015 19:33:43 +0000 (14:33 -0500)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/auto_super_init.nit

index 30b1f27..defe5a2 100644 (file)
@@ -101,43 +101,9 @@ redef class AMethPropdef
                # Still here? So it means that we must determine what super inits need to be automatically invoked
                # The code that follow is required to deal with complex cases with old-style and new-style inits
 
-               # Look for old-style super constructors
                var auto_super_inits = new Array[CallSite]
-               for msupertype in mclassdef.supertypes do
-                       # FIXME: the order is quite arbitrary
-                       if not msupertype.mclass.kind.need_init then continue
-                       msupertype = msupertype.anchor_to(mmodule, mclassdef.bound_mtype)
-                       var candidate = modelbuilder.try_get_mproperty_by_name2(self, mmodule, msupertype, mpropdef.mproperty.name)
-                       if candidate == null then
-                               candidate = modelbuilder.try_get_mproperty_by_name2(self, mmodule, msupertype, "init")
-                       end
-                       if candidate == null then
-                               modelbuilder.error(self, "Error: cannot do an implicit constructor call in `{mpropdef}`; there is no constructor named `{mpropdef.mproperty.name}` in `{msupertype}`.")
-                               return
-                       end
-                       assert candidate isa MMethod
-
-                       # Skip new-style init
-                       if candidate.is_root_init then continue
-
-                       var candidatedefs = candidate.lookup_definitions(mmodule, anchor)
-                       if candidatedefs.is_empty then
-                               # skip broken
-                               is_broken = true
-                               return
-                       end
-                       var candidatedef = candidatedefs.first
-                       # TODO, we drop the others propdefs in the callsite, that is not great :(
-
-                       var msignature = candidatedef.new_msignature or else candidatedef.msignature
-                       msignature = msignature.resolve_for(recvtype, anchor, mmodule, true)
-
-                       var callsite = new CallSite(hot_location, recvtype, mmodule, anchor, true, candidate, candidatedef, msignature, false)
-                       auto_super_inits.add(callsite)
-                       modelbuilder.toolcontext.info("Old-style auto-super init for {mpropdef} to {candidate.full_name}", 4)
-               end
 
-               # No old style? The look for new-style super constructors (called from a old style constructor)
+               # The look for new-style super constructors (called from a old style constructor)
                var the_root_init_mmethod = modelbuilder.the_root_init_mmethod
                if the_root_init_mmethod != null and auto_super_inits.is_empty then
                        var candidatedefs = the_root_init_mmethod.lookup_definitions(mmodule, anchor)