Skip to content

Commit e340a58

Browse files
committed
stash
1 parent f279da5 commit e340a58

5 files changed

Lines changed: 25 additions & 3 deletions

File tree

crates/emmylua_code_analysis/src/db_index/type/types.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ impl LuaType {
403403
LuaType::Variadic(inner) => inner.contain_tpl(),
404404
LuaType::TplRef(_) => true,
405405
LuaType::StrTplRef(_) => true,
406+
LuaType::ConstTplRef(_) => true,
406407
LuaType::SelfInfer => true,
407408
LuaType::MultiLineUnion(inner) => inner.contain_tpl(),
408409
LuaType::TypeGuard(inner) => inner.contain_tpl(),

crates/emmylua_code_analysis/src/semantic/generic/instantiate_func_generic.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use super::{
1313
TypeSubstitutor,
1414
};
1515

16-
// todo: need cache
1716
pub fn instantiate_func_generic(
1817
db: &DbIndex,
1918
cache: &mut LuaInferCache,

crates/emmylua_code_analysis/src/semantic/generic/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod instantiate_type_generic;
44
mod test;
55
mod tpl_pattern;
66
mod type_substitutor;
7+
mod tpl_context;
78

89
pub use instantiate_func_generic::instantiate_func_generic;
910
pub use instantiate_type_generic::instantiate_doc_function;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use emmylua_parser::LuaSyntaxNode;
2+
3+
use crate::{LuaType, TypeSubstitutor};
4+
5+
#[derive(Debug)]
6+
pub struct TplContext<'a> {
7+
pub tpl_param_types: &'a [LuaType],
8+
pub call_arg_types: &'a [LuaType],
9+
pub substitutor: &'a mut TypeSubstitutor,
10+
pub root: LuaSyntaxNode
11+
}
12+

crates/emmylua_code_analysis/src/semantic/generic/tpl_pattern.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use crate::{
88
check_type_compact,
99
db_index::{DbIndex, LuaGenericType, LuaType},
1010
semantic::{
11-
member::{find_index_operations, get_member_map},
12-
LuaInferCache,
11+
generic::tpl_context::TplContext, member::{find_index_operations, get_member_map}, LuaInferCache
1312
},
1413
InferFailReason, LuaFunctionType, LuaMemberKey, LuaMemberOwner, LuaObjectType,
1514
LuaSemanticDeclId, LuaTupleType, LuaUnionType, VariadicType,
@@ -27,6 +26,13 @@ pub fn tpl_pattern_match_args(
2726
root: &LuaSyntaxNode,
2827
substitutor: &mut TypeSubstitutor,
2928
) -> TplPatternMatchResult {
29+
let _ = TplContext {
30+
tpl_param_types: func_param_types,
31+
call_arg_types,
32+
substitutor,
33+
root: root.clone(),
34+
};
35+
3036
for (i, func_param_type) in func_param_types.iter().enumerate() {
3137
let call_arg_type = if i < call_arg_types.len() {
3238
&call_arg_types[i]
@@ -129,6 +135,9 @@ fn tpl_pattern_match(
129135
substitutor: &mut TypeSubstitutor,
130136
) -> TplPatternMatchResult {
131137
let target = escape_alias(db, target);
138+
if !pattern.contain_tpl() {
139+
return Ok(());
140+
}
132141

133142
match pattern {
134143
LuaType::TplRef(tpl) => {

0 commit comments

Comments
 (0)