Construction of a specific callsite according to the current context.

Three entry points exist to create a callsite based on knowledge. The build_callsite_by_name is a top entry point, the method find the mpropdefs to call by the name of this. see build_callsite_by_property and build_callsite_by_propdef for more detail. If you already know the mpropdef to call use directly the get_method_by_propdef method If you just know the mproperty use the build_callsite_by_property method to display error if no mpropdef is found in the context

Property definitions

nitc $ TypeVisitor :: build_callsite_by_name
	# Construction of a specific callsite according to the current context.
	# Three entry points exist to create a callsite based on knowledge.
	# The `build_callsite_by_name` is a top entry point, the method find the mpropdefs to call by the name of this.
	# see `build_callsite_by_property` and `build_callsite_by_propdef` for more detail.
	# If you already know the mpropdef to call use directly the `get_method_by_propdef` method
	# If you just know the mproperty use the `build_callsite_by_property` method to display error if no `mpropdef` is found in the context
	fun build_callsite_by_name(node: ANode, recvtype: MType, name: String, recv_is_self: Bool): nullable CallSite
	do
		var unsafe_type = self.anchor_to(recvtype)

		#debug("recv: {recvtype} (aka {unsafe_type})")
		if recvtype isa MNullType then
			var objclass = get_mclass(node, "Object")
			if objclass == null then return null # Forward error
			unsafe_type = objclass.mclass_type
		end

		var mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name)
		if name == "new" and mproperty == null then
			name = "defaultinit"
			mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name)
			if mproperty == null then
				name = "init"
				mproperty = self.try_get_mproperty_by_name2(node, unsafe_type, name)
			end
		end

		if mproperty == null then
			if recv_is_self then
				# FIXME This test was added to display a more explicit error when a potential duplication of root object class.
				if name == "init" then
					self.modelbuilder.error(node, "Possible duplication of the root class `Object`")
				else
					self.modelbuilder.error(node, "Error: method or variable `{name}` unknown in `{recvtype}`.")
				end
			else if recvtype.need_anchor then
				self.modelbuilder.error(node, "Error: method `{name}` does not exists in `{recvtype}: {unsafe_type}`.")
			else
				self.modelbuilder.error(node, "Error: method `{name}` does not exists in `{recvtype}`.")
			end
			return null
		end

		assert mproperty isa MMethod

		return build_callsite_by_property(node, recvtype, mproperty, recv_is_self)
	end
src/semantize/typing.nit:305,2--351,4