@@ -1012,7 +1012,11 @@ impl Evaluation {
1012
1012
if !attributes. is_empty ( ) {
1013
1013
let is_instance = ibase. as_weak ( ) . instance . unwrap_or ( false ) ;
1014
1014
attributes. iter ( ) . for_each ( |attribute|{
1015
- let mut eval = Evaluation :: eval_from_symbol ( & Rc :: downgrade ( attribute) , None ) ;
1015
+ let instance = match attribute. borrow ( ) . typ ( ) {
1016
+ SymType :: CLASS => Some ( false ) ,
1017
+ _ => None
1018
+ } ;
1019
+ let mut eval = Evaluation :: eval_from_symbol ( & Rc :: downgrade ( attribute) , instance) ;
1016
1020
match eval. symbol . sym {
1017
1021
EvaluationSymbolPtr :: WEAK ( ref mut weak) => {
1018
1022
weak. context . insert ( S ! ( "base_attr" ) , ContextValue :: SYMBOL ( Rc :: downgrade ( & base_loc) ) ) ;
@@ -1066,13 +1070,17 @@ impl Evaluation {
1066
1070
return AnalyzeAstResult :: from_only_diagnostics ( diagnostics) ;
1067
1071
}
1068
1072
for inferred_sym in inferred_syms. symbols . iter ( ) {
1069
- evals. push ( Evaluation :: eval_from_symbol ( & Rc :: downgrade ( inferred_sym) , None ) ) ;
1073
+ let instance = match inferred_sym. borrow ( ) . typ ( ) {
1074
+ SymType :: CLASS => Some ( false ) ,
1075
+ _ => None
1076
+ } ;
1077
+ evals. push ( Evaluation :: eval_from_symbol ( & Rc :: downgrade ( inferred_sym) , instance) ) ;
1070
1078
}
1071
1079
if !inferred_syms. always_defined {
1072
1080
evals. push ( Evaluation :: new_unbound ( name) ) ;
1073
1081
}
1074
1082
} ,
1075
- ExprOrIdent :: Expr ( Expr :: Subscript ( sub) ) => {
1083
+ ExprOrIdent :: Expr ( Expr :: Subscript ( sub) ) => ' subscript_block : {
1076
1084
let ( eval_left, diags) = Evaluation :: eval_from_ast ( session, & sub. value , parent. clone ( ) , max_infer, required_dependencies) ;
1077
1085
diagnostics. extend ( diags) ;
1078
1086
// TODO handle multiple eval_left
@@ -1087,20 +1095,38 @@ impl Evaluation {
1087
1095
if bases. len ( ) != 1 {
1088
1096
return AnalyzeAstResult :: from_only_diagnostics ( diagnostics) ;
1089
1097
}
1090
- let parent_file_or_func = parent. clone ( ) . borrow ( ) . parent_file_or_function ( ) . as_ref ( ) . unwrap ( ) . upgrade ( ) . unwrap ( ) ;
1091
- let is_in_validation = match parent_file_or_func. borrow ( ) . typ ( ) . clone ( ) {
1092
- SymType :: FILE | SymType :: PACKAGE ( _) | SymType :: FUNCTION => {
1093
- parent_file_or_func. borrow ( ) . build_status ( BuildSteps :: VALIDATION ) == BuildStatus :: IN_PROGRESS
1094
- } ,
1095
- _ => { false }
1096
- } ;
1098
+ let base = & bases[ 0 ] ;
1099
+ match base {
1100
+ EvaluationSymbolPtr :: WEAK ( base_sym_weak_eval) if base_sym_weak_eval. instance == Some ( false ) => {
1101
+ if let Some ( SymType :: CLASS ) = base. upgrade_weak ( ) . map ( |s| s. borrow ( ) . typ ( ) ) {
1102
+ // This is a Generic type (Field[int], or List[int]), for now we just return the main type/Class (Field/List)
1103
+ // TODO: handle generic types
1104
+ evals. push ( Evaluation {
1105
+ symbol : EvaluationSymbol {
1106
+ sym : base. clone ( ) ,
1107
+ get_symbol_hook : None ,
1108
+ } ,
1109
+ value : None ,
1110
+ range : Some ( sub. range ( ) )
1111
+ } ) ;
1112
+ break ' subscript_block;
1113
+ }
1114
+ }
1115
+ _ => { }
1116
+ }
1097
1117
let value = Evaluation :: expr_to_str ( session, & sub. slice , parent. clone ( ) , max_infer, & mut diagnostics) ;
1098
1118
diagnostics. extend ( value. 1 ) ;
1099
1119
if let Some ( value) = value. 0 {
1100
- let base = & bases[ 0 ] ;
1101
1120
if !base. is_weak ( ) {
1102
1121
return AnalyzeAstResult :: from_only_diagnostics ( diagnostics) ;
1103
1122
}
1123
+ let parent_file_or_func = parent. clone ( ) . borrow ( ) . parent_file_or_function ( ) . as_ref ( ) . unwrap ( ) . upgrade ( ) . unwrap ( ) ;
1124
+ let is_in_validation = match parent_file_or_func. borrow ( ) . typ ( ) . clone ( ) {
1125
+ SymType :: FILE | SymType :: PACKAGE ( _) | SymType :: FUNCTION => {
1126
+ parent_file_or_func. borrow ( ) . build_status ( BuildSteps :: VALIDATION ) == BuildStatus :: IN_PROGRESS
1127
+ } ,
1128
+ _ => { false }
1129
+ } ;
1104
1130
let base = base. upgrade_weak ( ) . unwrap ( ) ;
1105
1131
let get_item = base. borrow ( ) . get_content_symbol ( "__getitem__" , u32:: MAX ) . symbols ;
1106
1132
if get_item. len ( ) == 1 {
0 commit comments