Bug 533151: Add support of self typing for function expr:f() end
diff --git a/libraries/modelsbuilder/models/internalmodelbuilder.mlua b/libraries/modelsbuilder/models/internalmodelbuilder.mlua
index 20f7fef..18a13eb 100644
--- a/libraries/modelsbuilder/models/internalmodelbuilder.mlua
+++ b/libraries/modelsbuilder/models/internalmodelbuilder.mlua
@@ -549,6 +549,22 @@
                 end
               end
             end
+          else
+            -- this is the case where we have
+            -- function expr.f(self) or  function expr:f()
+            -- we suppose the type of self is the type of "expr" 
+            if itemname == "self" and i==1 and binder.parent.tag == "Set" then
+              match binder.parent with
+              |`Set   { {`Index { right , string}}, {...}} ->
+                  -- if node is an expression supported
+                  local supportedexpr = expreto_expression[right]
+                  if supportedexpr then
+                    -- create expression type ref
+                    local selftype = apimodel._exprtyperef(supportedexpr,1)
+                    return createitem(itemname,id,selftype)
+                  end
+              end
+            end
           end              
           return createitem(itemname,id)
         end