(&mut self, _can_assign: bool)
| 2211 | } |
| 2212 | |
| 2213 | fn super_(&mut self, _can_assign: bool) -> Option<Expr<'gc>> { |
| 2214 | let is_in_static_method = if let Some(class_compiler) = self.class_compiler.as_ref() { |
| 2215 | if !class_compiler.is_enum && !class_compiler.has_superclass { |
| 2216 | self.error("Can't use 'super' in a class with no superclass."); |
| 2217 | return None; |
| 2218 | } else if class_compiler.is_enum { |
| 2219 | self.error("Can't use 'super' in an enum."); |
| 2220 | return None; |
| 2221 | } |
| 2222 | class_compiler.current_method_type.is_static_method() || self.fn_type.is_static_method() |
| 2223 | } else { |
| 2224 | self.error("Can't use 'super' outside of a class."); |
| 2225 | return None; |
| 2226 | }; |
| 2227 | |
| 2228 | if is_in_static_method { |
| 2229 | self.error("Can't use 'super' in static method."); |
| 2230 | return None; |
| 2231 | } |
| 2232 | |
| 2233 | let keyword = self.previous; |
| 2234 | self.consume(TokenType::Dot, "Expect '.' after 'super'."); |
| 2235 | self.consume(TokenType::Identifier, "Expect superclass method name."); |
| 2236 | let method = self.previous; |
| 2237 | |
| 2238 | if self.match_token(TokenType::OpenParen) { |
| 2239 | let (arguments, keyword_args) = self.argument_list()?; |
| 2240 | self.consume(TokenType::CloseParen, "Expect ')' after arguments."); |
| 2241 | |
| 2242 | Some(Expr::SuperInvoke { |
| 2243 | method, |
| 2244 | arguments, |
| 2245 | keyword_args, |
| 2246 | line: keyword.line, |
| 2247 | }) |
| 2248 | } else { |
| 2249 | Some(Expr::Super { |
| 2250 | method, |
| 2251 | line: keyword.line, |
| 2252 | }) |
| 2253 | } |
| 2254 | } |
| 2255 | |
| 2256 | fn self_(&mut self, _can_assign: bool) -> Option<Expr<'gc>> { |
| 2257 | let is_in_static_method = if let Some(class_compiler) = self.class_compiler.as_ref() { |
nothing calls this directly
no test coverage detected