Skip to content

Commit f2fd7da

Browse files
authored
fix(semantic): don't report abstract method with implementation twice (#14193)
The match above the deleted line already reports depending on the kind of method.
1 parent 5dcc64c commit f2fd7da

File tree

3 files changed

+0
-73
lines changed

3 files changed

+0
-73
lines changed

crates/oxc_semantic/src/checker/typescript.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,6 @@ pub fn check_method_definition<'a>(method: &MethodDefinition<'a>, ctx: &Semantic
389389
// have abstract modifiers, but this gets checked during parsing
390390
MethodDefinitionKind::Constructor => {}
391391
}
392-
ctx.error(abstract_method_cannot_have_implementation(method_name, span));
393392
}
394393
}
395394

tasks/coverage/snapshots/parser_babel.snap

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12388,22 +12388,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
1238812388
3 │ }
1238912389
╰────
1239012390

12391-
× TS(1245): Method 'method' cannot have an implementation because it is marked abstract.
12392-
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/abstract-method-with-body/input.ts:2:12]
12393-
1 │ abstract class Foo {
12394-
2 │ abstract method() {}
12395-
· ──────
12396-
3 │ }
12397-
╰────
12398-
12399-
× TS(1245): Method 'foo()' cannot have an implementation because it is marked abstract.
12400-
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/abstract-method-with-body-computed/input.ts:2:13]
12401-
1 │ abstract class Foo {
12402-
2 │ abstract [foo()]() {}
12403-
· ─────
12404-
3 │ }
12405-
╰────
12406-
1240712391
× TS(1245): Method 'foo()' cannot have an implementation because it is marked abstract.
1240812392
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/abstract-method-with-body-computed/input.ts:2:13]
1240912393
1 │ abstract class Foo {
@@ -12665,14 +12649,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
1266512649
× TS(1245): Method 'd' cannot have an implementation because it is marked abstract.
1266612650
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/generator-method-with-modifiers/input.ts:5:13]
1266712651
4 │ static *c() {}
12668-
5 │ abstract *d() {}
12669-
· ─
12670-
6 │ readonly *e() {}
12671-
╰────
12672-
12673-
× TS(1245): Method 'd' cannot have an implementation because it is marked abstract.
12674-
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/generator-method-with-modifiers/input.ts:5:13]
12675-
4 │ static *c() {}
1267612652
5 │ abstract *d() {}
1267712653
· ─
1267812654
6 │ readonly *e() {}
@@ -12825,14 +12801,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
1282512801
× TS(1245): Method 'd' cannot have an implementation because it is marked abstract.
1282612802
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/optional-generator-method-with-invalid-modifiers/input.ts:2:13]
1282712803
1 │ class C {
12828-
2 │ abstract *d?() { }
12829-
· ─
12830-
3 │ readonly *e?() { }
12831-
╰────
12832-
12833-
× TS(1245): Method 'd' cannot have an implementation because it is marked abstract.
12834-
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/optional-generator-method-with-invalid-modifiers/input.ts:2:13]
12835-
1 │ class C {
1283612804
2 │ abstract *d?() { }
1283712805
· ─
1283812806
3 │ readonly *e?() { }
@@ -12849,14 +12817,6 @@ Expect to Parse: tasks/coverage/babel/packages/babel-parser/test/fixtures/typesc
1284912817
× TS(1245): Method 'd?.d' cannot have an implementation because it is marked abstract.
1285012818
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/optional-generator-method-with-invalid-modifiers/input.ts:8:14]
1285112819
7 │ class A {
12852-
8 │ abstract *[d?.d]?() { }
12853-
· ────
12854-
9 │ readonly *[e?.e]?() { }
12855-
╰────
12856-
12857-
× TS(1245): Method 'd?.d' cannot have an implementation because it is marked abstract.
12858-
╭─[babel/packages/babel-parser/test/fixtures/typescript/class/optional-generator-method-with-invalid-modifiers/input.ts:8:14]
12859-
7 │ class A {
1286012820
8 │ abstract *[d?.d]?() { }
1286112821
· ────
1286212822
9 │ readonly *[e?.e]?() { }

tasks/coverage/snapshots/parser_typescript.snap

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14528,14 +14528,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
1452814528
× TS(1318): Accessor 'aa' cannot have an implementation because it is marked abstract.
1452914529
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts:3:17]
1453014530
2 │ abstract get a();
14531-
3 │ abstract get aa() { return 1; } // error
14532-
· ──
14533-
4 │ abstract set b(x: string);
14534-
╰────
14535-
14536-
× TS(1245): Method 'aa' cannot have an implementation because it is marked abstract.
14537-
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts:3:17]
14538-
2 │ abstract get a();
1453914531
3 │ abstract get aa() { return 1; } // error
1454014532
· ──
1454114533
4 │ abstract set b(x: string);
@@ -14544,14 +14536,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
1454414536
× TS(1318): Accessor 'bb' cannot have an implementation because it is marked abstract.
1454514537
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts:5:17]
1454614538
4 │ abstract set b(x: string);
14547-
5 │ abstract set bb(x: string) {} // error
14548-
· ──
14549-
6 │ }
14550-
╰────
14551-
14552-
× TS(1245): Method 'bb' cannot have an implementation because it is marked abstract.
14553-
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractAccessor.ts:5:17]
14554-
4 │ abstract set b(x: string);
1455514539
5 │ abstract set bb(x: string) {} // error
1455614540
· ──
1455714541
6 │ }
@@ -14664,14 +14648,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
1466414648
× TS(1245): Method 'foo' cannot have an implementation because it is marked abstract.
1466514649
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts:6:14]
1466614650
5 │ class B {
14667-
6 │ abstract foo() {}
14668-
· ───
14669-
7 │ }
14670-
╰────
14671-
14672-
× TS(1245): Method 'foo' cannot have an implementation because it is marked abstract.
14673-
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodInNonAbstractClass.ts:6:14]
14674-
5 │ class B {
1467514651
6 │ abstract foo() {}
1467614652
· ───
1467714653
7 │ }
@@ -14688,14 +14664,6 @@ Expect to Parse: tasks/coverage/typescript/tests/cases/conformance/parser/ecmasc
1468814664
× TS(1245): Method 'foo' cannot have an implementation because it is marked abstract.
1468914665
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts:2:14]
1469014666
1 │ abstract class A {
14691-
2 │ abstract foo() {}
14692-
· ───
14693-
3 │ }
14694-
╰────
14695-
14696-
× TS(1245): Method 'foo' cannot have an implementation because it is marked abstract.
14697-
╭─[typescript/tests/cases/conformance/classes/classDeclarations/classAbstractKeyword/classAbstractMethodWithImplementation.ts:2:14]
14698-
1 │ abstract class A {
1469914667
2 │ abstract foo() {}
1470014668
· ───
1470114669
3 │ }

0 commit comments

Comments
 (0)