@@ -5,7 +5,7 @@ use rustc_hash::FxHashMap;
55
66use oxc_ast:: { AstKind , ast:: * } ;
77use oxc_diagnostics:: OxcDiagnostic ;
8- use oxc_ecmascript:: { BoundNames , PropName } ;
8+ use oxc_ecmascript:: BoundNames ;
99use oxc_span:: { Atom , GetSpan , Span } ;
1010
1111use crate :: { builder:: SemanticBuilder , diagnostics:: redeclaration} ;
@@ -289,48 +289,6 @@ fn reserved_type_name(span: Span, reserved_name: &str, syntax_name: &str) -> Oxc
289289 ts_error ( "2414" , format ! ( "{syntax_name} name cannot be '{reserved_name}'" ) ) . with_label ( span)
290290}
291291
292- fn abstract_element_cannot_have_initializer (
293- code : & ' static str ,
294- elem_name : & str ,
295- prop_name : & str ,
296- span : Span ,
297- init_or_impl : & str ,
298- ) -> OxcDiagnostic {
299- ts_error (
300- code,
301- format ! (
302- "{elem_name} '{prop_name}' cannot have an {init_or_impl} because it is marked abstract."
303- ) ,
304- )
305- . with_label ( span)
306- }
307-
308- /// TS(1245): Method 'foo' cannot have an implementation because it is marked abstract.
309- fn abstract_method_cannot_have_implementation ( method_name : & str , span : Span ) -> OxcDiagnostic {
310- abstract_element_cannot_have_initializer ( "1245" , "Method" , method_name, span, "implementation" )
311- }
312-
313- /// TS(1267): Property 'foo' cannot have an initializer because it is marked abstract.
314- fn abstract_property_cannot_have_initializer ( prop_name : & str , span : Span ) -> OxcDiagnostic {
315- abstract_element_cannot_have_initializer ( "1267" , "Property" , prop_name, span, "initializer" )
316- }
317-
318- /// TS(1318): Accessor 'foo' cannot have an implementation because it is marked abstract.
319- ///
320- /// Applies to getters/setters
321- ///
322- /// > TS's original message, `An abstract accessor cannot have an
323- /// > implementation.`, is less helpful than the one provided here.
324- fn abstract_accessor_cannot_have_implementation ( accessor_name : & str , span : Span ) -> OxcDiagnostic {
325- abstract_element_cannot_have_initializer (
326- "1318" ,
327- "Accessor" ,
328- accessor_name,
329- span,
330- "implementation" ,
331- )
332- }
333-
334292/// 'abstract' modifier can only appear on a class, method, or property declaration. (1242)
335293fn illegal_abstract_modifier ( span : Span ) -> OxcDiagnostic {
336294 ts_error (
@@ -372,23 +330,6 @@ pub fn check_method_definition<'a>(method: &MethodDefinition<'a>, ctx: &Semantic
372330 // constructors cannot be abstract, no matter what
373331 if method. kind . is_constructor ( ) {
374332 ctx. error ( illegal_abstract_modifier ( method. key . span ( ) ) ) ;
375- } else if method. value . body . is_some ( ) {
376- // abstract class elements cannot have bodies or initializers
377- let ( method_name, span) = method. key . prop_name ( ) . unwrap_or_else ( || {
378- let key_span = method. key . span ( ) ;
379- ( & ctx. source_text [ key_span] , key_span)
380- } ) ;
381- match method. kind {
382- MethodDefinitionKind :: Method => {
383- ctx. error ( abstract_method_cannot_have_implementation ( method_name, span) ) ;
384- }
385- MethodDefinitionKind :: Get | MethodDefinitionKind :: Set => {
386- ctx. error ( abstract_accessor_cannot_have_implementation ( method_name, span) ) ;
387- }
388- // abstract classes can have concrete methods. Constructors cannot
389- // have abstract modifiers, but this gets checked during parsing
390- MethodDefinitionKind :: Constructor => { }
391- }
392333 }
393334 }
394335
@@ -408,16 +349,6 @@ pub fn check_method_definition<'a>(method: &MethodDefinition<'a>, ctx: &Semantic
408349 }
409350}
410351
411- pub fn check_property_definition < ' a > ( prop : & PropertyDefinition < ' a > , ctx : & SemanticBuilder < ' a > ) {
412- if prop. r#type . is_abstract ( ) && prop. value . is_some ( ) {
413- let ( prop_name, span) = prop. key . prop_name ( ) . unwrap_or_else ( || {
414- let key_span = prop. key . span ( ) ;
415- ( & ctx. source_text [ key_span] , key_span)
416- } ) ;
417- ctx. error ( abstract_property_cannot_have_initializer ( prop_name, span) ) ;
418- }
419- }
420-
421352pub fn check_object_property ( prop : & ObjectProperty , ctx : & SemanticBuilder < ' _ > ) {
422353 if let Expression :: FunctionExpression ( func) = & prop. value
423354 && prop. kind . is_accessor ( )
0 commit comments