diff --git a/src/julec/obj/cxx/object.jule b/src/julec/obj/cxx/object.jule index d32bf2a9e..ccca6db9d 100644 --- a/src/julec/obj/cxx/object.jule +++ b/src/julec/obj/cxx/object.jule @@ -747,7 +747,7 @@ impl ObjectCoder { fn structureInsDecl(mut &self, mut &s: &StructIns) { for (_, mut m) in s.Methods { // Operator methods are declared by [structureDecl]. - if isOpMethod(m) { + if isHeadDecl(m) { self.funcDecl(m, false) } } @@ -799,7 +799,7 @@ impl ObjectCoder { for (_, mut ins) in s.Instances { for (_, mut m) in ins.Methods { // Operator methods are declared by [structureDecl]. - if !isOpMethod(m) { + if !isHeadDecl(m) { self.pushResult(m) self.funcDecl(m, false) } @@ -1435,9 +1435,9 @@ fn pushMethodsFromInherits(mut &dest: &Trait, mut &src: &Trait) { } } -// Reports whtehr the m is operator overloading function. +// Reports whether the m is operator overloading method. fn isOpMethod(&m: &Fn): bool { - if m == nil || len(m.Generics) > 0 || len(m.Instances) == 0 { + if len(m.Generics) > 0 || len(m.Instances) == 0 { ret false } let mi = m.Instances[0] @@ -1449,4 +1449,17 @@ fn isOpMethod(&m: &Fn): bool { } } ret false +} + +// Reports whether the m is a method which is declarated top of the struct. +fn isHeadDecl(mut &m: &Fn): bool { + if len(m.Generics) > 0 || len(m.Instances) == 0 { + ret false + } + if isOpMethod(m) { + ret true + } + let mut mi = m.Instances[0] + const Static = false + ret FuncPattern.Dispose(mi.Owner.FindMethod("Dispose", Static)) } \ No newline at end of file