summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/diagnostics/undefined-field.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/script/core/diagnostics/undefined-field.lua b/script/core/diagnostics/undefined-field.lua
index d4a0fe78..307182b3 100644
--- a/script/core/diagnostics/undefined-field.lua
+++ b/script/core/diagnostics/undefined-field.lua
@@ -21,11 +21,28 @@ return function (uri, callback)
return src.type == 'getglobal' and src.special == '_G'
end
+ local function canInfer2Class(src)
+ local className = vm.getClass(src, 0)
+ if not className then
+ local inferType = vm.getInferType(src, 0)
+ if inferType ~= 'any' and inferType ~= 'table' then
+ className = inferType
+ end
+ end
+
+ return className and className ~= 'table'
+ end
+
local function checkUndefinedField(src)
local fieldName = guide.getKeyName(src)
if is_G(src)then
return
end
+
+ if not canInfer2Class(src.node) then
+ return
+ end
+
local refs = vm.getFields(src.node, 0)
local fields = {}