Skip to content

Commit

Permalink
test for override final method
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoBettini committed Feb 8, 2024
1 parent fb28bcf commit 0469977
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,20 @@ public void testWildcardSuperType() throws Exception {
+ " inherited from InterfaceWithAbstractMethod.");
}

@Test public void testOverrideFinalMethod() throws Exception {
var source = "class Foo extends test.ClassWithFinalMembers { def void foo() {} }";
var model = parse(source);
validationHelper.assertError(model, MY_METHOD, OVERRIDDEN_FINAL,
source.indexOf("foo"), "foo".length(),
"override", "final");
}

@Test public void testOverrideNonFinalMethod() throws Exception {
var source = "class Foo extends test.SuperTypeClass { def void foo() {} }";
var model = parse(source);
validationHelper.assertNoErrors(model);
}

@Test public void testDuplicateParameter() throws Exception {
var source = "class Foo { def void foo(int x, int x) {} }";
var model = parse(source);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package test;

/**
* @author Lorenzo Bettini - Initial contribution and API
*/
public class ClassWithFinalMembers {

public final void foo() {
}

}
19 changes: 19 additions & 0 deletions org.eclipse.xtext.xbase.tests/testdata/test/SuperTypeClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright (c) 2024 itemis AG (http://www.itemis.eu) and others.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package test;

/**
* @author Lorenzo Bettini - Initial contribution and API
*/
public abstract class SuperTypeClass {

public void foo() {
}

}

0 comments on commit 0469977

Please sign in to comment.