@@ -189,6 +189,9 @@ impl<'local, 'context> Interpreter<'local, 'context> {
189
189
"typed_expr_as_function_definition" => {
190
190
typed_expr_as_function_definition ( interner, arguments, return_type, location)
191
191
}
192
+ "typed_expr_get_type" => {
193
+ typed_expr_get_type ( interner, arguments, return_type, location)
194
+ }
192
195
"unresolved_type_is_field" => unresolved_type_is_field ( interner, arguments, location) ,
193
196
"zeroed" => zeroed ( return_type) ,
194
197
_ => {
@@ -1070,6 +1073,7 @@ fn trait_impl_trait_generic_args(
1070
1073
Ok ( Value :: Slice ( trait_generics, slice_type) )
1071
1074
}
1072
1075
1076
+ // fn as_function_definition(self) -> Option<FunctionDefinition>
1073
1077
fn typed_expr_as_function_definition (
1074
1078
interner : & NodeInterner ,
1075
1079
arguments : Vec < ( Value , Location ) > ,
@@ -1087,6 +1091,28 @@ fn typed_expr_as_function_definition(
1087
1091
option ( return_type, option_value)
1088
1092
}
1089
1093
1094
+ // fn get_type(self) -> Option<Type>
1095
+ fn typed_expr_get_type (
1096
+ interner : & NodeInterner ,
1097
+ arguments : Vec < ( Value , Location ) > ,
1098
+ return_type : Type ,
1099
+ location : Location ,
1100
+ ) -> IResult < Value > {
1101
+ let self_argument = check_one_argument ( arguments, location) ?;
1102
+ let typed_expr = get_typed_expr ( self_argument) ?;
1103
+ let option_value = if let TypedExpr :: ExprId ( expr_id) = typed_expr {
1104
+ let typ = interner. id_type ( expr_id) ;
1105
+ if typ == Type :: Error {
1106
+ None
1107
+ } else {
1108
+ Some ( Value :: Type ( typ) )
1109
+ }
1110
+ } else {
1111
+ None
1112
+ } ;
1113
+ option ( return_type, option_value)
1114
+ }
1115
+
1090
1116
// fn is_field(self) -> bool
1091
1117
fn unresolved_type_is_field (
1092
1118
interner : & NodeInterner ,
0 commit comments