Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modelize: broken mproperties can have definitions #2602

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions src/modelize/modelize_property.nit
Original file line number Diff line number Diff line change
Expand Up @@ -819,43 +819,46 @@ redef class AMethPropdef
modelbuilder.advice(self, "useless-init", "Warning: useless empty init in {mclassdef}")
end
end
if mprop == null then
var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility)
mprop = new MMethod(mclassdef, name, self.location, mvisibility)
if look_like_a_root_init and modelbuilder.the_root_init_mmethod == null then
modelbuilder.the_root_init_mmethod = mprop
mprop.is_root_init = true
end
mprop.is_init = is_init
mprop.is_new = is_new
if is_new then mclassdef.mclass.has_new_factory = true
if name == "sys" then mprop.is_toplevel = true # special case for sys allowed in `new` factories
if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mprop) then
mprop.is_broken = true
return
end
else
if mprop.is_broken then return
if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, not self isa AMainMethPropdef, mprop) then return
check_redef_property_visibility(modelbuilder, self.n_visibility, mprop)
end

# Check name conflicts in the local class for constructors.
if is_init then
for p, n in mclassdef.mprop2npropdef do
if p != mprop and p isa MMethod and p.name == name then
if not check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, p) then
mprop.is_broken = true
return
do
if mprop == null then
var mvisibility = new_property_visibility(modelbuilder, mclassdef, self.n_visibility)
mprop = new MMethod(mclassdef, name, self.location, mvisibility)
if look_like_a_root_init and modelbuilder.the_root_init_mmethod == null then
modelbuilder.the_root_init_mmethod = mprop
mprop.is_root_init = true
end
mprop.is_init = is_init
mprop.is_new = is_new
if is_new then mclassdef.mclass.has_new_factory = true
if name == "sys" then mprop.is_toplevel = true # special case for sys allowed in `new` factories
if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, mprop) then
mprop.is_broken = true
break label
end
else
if mprop.is_broken then break label
if not self.check_redef_keyword(modelbuilder, mclassdef, n_kwredef, not self isa AMainMethPropdef, mprop) then break label
check_redef_property_visibility(modelbuilder, self.n_visibility, mprop)
end

# Check name conflicts in the local class for constructors.
if is_init then
for p, n in mclassdef.mprop2npropdef do
if p != mprop and p isa MMethod and p.name == name then
if not check_redef_keyword(modelbuilder, mclassdef, n_kwredef, false, p) then
mprop.is_broken = true
break label
end
break
end
break
end
end
end
end label

mclassdef.mprop2npropdef[mprop] = self

var mpropdef = new MMethodDef(mclassdef, mprop, self.location)
mpropdef.is_broken = mprop.is_broken

set_doc(mpropdef, modelbuilder)

Expand Down