From aa24a7a10821b32cd390c34ed05d9bbbd08e27f3 Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 16 Jan 2024 15:58:55 +0100 Subject: [PATCH] also verify error position for INCOMPATIBLE_THROWS_CLAUSE (2) --- .../tests/validation/OverrideValidationTest.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/OverrideValidationTest.java b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/OverrideValidationTest.java index 123e5bdffe1..091dee92461 100644 --- a/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/OverrideValidationTest.java +++ b/org.eclipse.xtend.core.tests/src/org/eclipse/xtend/core/tests/validation/OverrideValidationTest.java @@ -480,7 +480,7 @@ public void testClassMustBeAbstract_06() throws Exception { XtendClass xtendClass = clazz(source); helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, INCOMPATIBLE_THROWS_CLAUSE, source.lastIndexOf("Exception"), "Exception".length(), - "Exception", "not", "compatible", "throws", "clause"); + "Exception", "is not", "compatible", "throws", "clause"); } @Test public void testIncompatibleThrowsClause_01() throws Exception { @@ -512,7 +512,19 @@ public void testClassMustBeAbstract_06() throws Exception { helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, INCOMPATIBLE_THROWS_CLAUSE, "Exception", "FileNotFoundException", "not", "compatible", "throws", "clause"); } - + + /** + * Two incompatible exceptions; the marker is on the first one + */ + @Test public void testIncompatibleThrowsClause_06() throws Exception { + var source = "class Foo extends test.ExceptionThrowing { override nullPointerException() throws java.io.IOException, java.io.FileNotFoundException {} }"; + XtendClass xtendClass = clazz(source); + helper.assertError(xtendClass.getMembers().get(0), XTEND_FUNCTION, INCOMPATIBLE_THROWS_CLAUSE, + source.indexOf("java.io.IOException"), "java.io.IOException".length(), + "declared exceptions", "IOException", "FileNotFoundException", + "are not", "compatible", "throws", "clause"); + } + @Test public void testCompatibleThrowsClause() throws Exception { XtendClass xtendClass = clazz("class Foo extends test.ExceptionThrowing { override ioException() throws java.io.FileNotFoundException {} }"); helper.assertNoError(xtendClass.getMembers().get(0), INCOMPATIBLE_THROWS_CLAUSE);