@@ -7,9 +7,9 @@ use emmylua_parser::{
77use rowan:: { NodeOrToken , TextRange } ;
88
99use crate :: {
10- DiagnosticCode , LuaBuiltinAttributeKind , LuaDeclExtra , LuaDeclId , LuaMemberKey ,
11- LuaSemanticDeclId , LuaType , SemanticDeclLevel , SemanticModel , TypeCheckFailReason ,
12- TypeCheckResult , VariadicType , infer_index_expr ,
10+ DiagnosticCode , LuaBuiltinAttributeKind , LuaDeclId , LuaMemberKey , LuaType , SemanticDeclLevel ,
11+ SemanticModel , TypeCheckFailReason , TypeCheckResult , VariadicType ,
12+ semantic :: infer_expr_without_condition_flow ,
1313} ;
1414
1515use super :: { Checker , DiagnosticContext , humanize_lint_type} ;
@@ -74,36 +74,13 @@ fn check_name_expr(
7474 expr : Option < LuaExpr > ,
7575 value_type : LuaType ,
7676) -> Option < ( ) > {
77- let semantic_decl = semantic_model. find_decl (
78- NodeOrToken :: Node ( name_expr. syntax ( ) . clone ( ) ) ,
79- SemanticDeclLevel :: default ( ) ,
80- ) ?;
81- let source_type = match semantic_decl. clone ( ) {
82- LuaSemanticDeclId :: LuaDecl ( decl_id) => {
83- let decl = semantic_model
84- . get_db ( )
85- . get_decl_index ( )
86- . get_decl ( & decl_id) ?;
87- match decl. extra {
88- LuaDeclExtra :: Param {
89- idx, signature_id, ..
90- } => {
91- let signature = semantic_model
92- . get_db ( )
93- . get_signature_index ( )
94- . get ( & signature_id) ?;
95- let param_type = signature. get_param_info_by_id ( idx) ?;
96- Some ( param_type. type_ref . clone ( ) )
97- }
98- _ => semantic_model
99- . get_db ( )
100- . get_type_index ( )
101- . get_type_cache ( & decl_id. into ( ) )
102- . map ( |cache| cache. as_type ( ) . clone ( ) ) ,
103- }
104- }
105- _ => None ,
106- } ;
77+ let source_type = infer_expr_without_condition_flow (
78+ semantic_model. get_db ( ) ,
79+ & mut semantic_model. get_cache ( ) . borrow_mut ( ) ,
80+ LuaExpr :: NameExpr ( name_expr. clone ( ) ) ,
81+ )
82+ . ok ( ) ;
83+
10784 check_assign_type_mismatch (
10885 context,
10986 semantic_model,
@@ -132,11 +109,10 @@ fn check_index_expr(
132109 expr : Option < LuaExpr > ,
133110 value_type : LuaType ,
134111) -> Option < ( ) > {
135- let source_type = infer_index_expr (
112+ let source_type = infer_expr_without_condition_flow (
136113 semantic_model. get_db ( ) ,
137114 & mut semantic_model. get_cache ( ) . borrow_mut ( ) ,
138- index_expr. clone ( ) ,
139- false ,
115+ LuaExpr :: IndexExpr ( index_expr. clone ( ) ) ,
140116 )
141117 . ok ( ) ;
142118
0 commit comments