@@ -8,6 +8,7 @@ use super::node::macro_nodes::MacroNode;
88use super :: node:: node_result:: NodeResult ;
99use super :: node:: NodeEnum ;
1010use super :: node:: TypeNode ;
11+ use super :: node:: TypeNodeEnum ;
1112use super :: plmod:: CompletionItemWrapper ;
1213use super :: plmod:: GlobType ;
1314use super :: plmod:: GlobalVar ;
@@ -482,6 +483,25 @@ impl<'a, 'ctx> Ctx<'a> {
482483 }
483484 }
484485 let ( st_pltype, st_value) = self . auto_deref ( ori_pltype, ori_value, builder) ;
486+ if let PLType :: Trait ( t) = & * target_pltype. borrow ( ) {
487+ for f in t. list_trait_fields ( ) . iter ( ) {
488+ if let TypeNodeEnum :: Func ( fu) = & * f. typenode {
489+ if fu. generics . is_some ( ) {
490+ return Err ( target_range. new_err ( ErrorCode :: THE_TARGET_TRAIT_CANNOT_BE_INSTANTIATED )
491+ . add_label (
492+ target_range,
493+ self . get_file ( ) ,
494+ format_label ! ( "trait type `{}`" , t. get_name( ) ) ,
495+ )
496+ . add_label (
497+ f. range ,
498+ t. get_path ( ) ,
499+ format_label ! ( "the method `{}` of trait `{}` has generic params, which makes it uninstantiatable" , & f. name, t. get_name( ) ) ,
500+ ) . add_to_ctx ( self ) ) ;
501+ }
502+ }
503+ }
504+ }
485505 match ( & * target_pltype. borrow ( ) , & * st_pltype. clone ( ) . borrow ( ) ) {
486506 ( PLType :: Trait ( t) , PLType :: Struct ( st) ) => {
487507 return self . cast_implable (
0 commit comments