Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test with mutliple inheritance through interfaces.
This test ensures that RTA uses topological order to choose which type the method is inherited from when an interface extends two interfaces defining the same method. PiperOrigin-RevId: 212726860
- Loading branch information
Showing
7 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/BUILD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Apache2 | ||
licenses(["notice"]) | ||
|
||
load("//tools/javatests/com/google/j2cl/tools/rta:rta_test.bzl", "rta_test") | ||
|
||
rta_test( | ||
name = "multipleinheritance", | ||
targets = [":multipleinheritance_library"], | ||
unused_members_golden_file = "unused_members.txt", | ||
unused_types_golden_file = "unused_types.txt", | ||
) |
32 changes: 32 additions & 0 deletions
32
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/FooBarImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2018 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.j2cl.tools.rta.multipleinheritance; | ||
|
||
import jsinterop.annotations.JsMethod; | ||
|
||
class FooBarImpl implements IFooBar { | ||
public void fooBar() {} | ||
|
||
public void foo() {} | ||
|
||
public void bar() {} | ||
|
||
@JsMethod | ||
public static void main() { | ||
IBar iBar = new FooBarImpl(); | ||
iBar.fooBar(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/IBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2018 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.j2cl.tools.rta.multipleinheritance; | ||
|
||
/** Redefines its parent method */ | ||
interface IBar extends IFoo { | ||
void fooBar(); | ||
|
||
void bar(); | ||
} |
22 changes: 22 additions & 0 deletions
22
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/IFoo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright 2018 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.j2cl.tools.rta.multipleinheritance; | ||
|
||
interface IFoo { | ||
void fooBar(); | ||
|
||
void foo(); | ||
} |
25 changes: 25 additions & 0 deletions
25
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/IFooBar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2018 Google Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.google.j2cl.tools.rta.multipleinheritance; | ||
|
||
/** | ||
* This interface inherits 2 times the same method fooBar(). RTA uses the topological depth to | ||
* choose which method IFooBar inherits. In this case IBar:fooBar(). If it's not the case (RTA finds | ||
* that IFooBar inherits from IFoo:fooBar()), the algorithm will find that IFoo:fooBar() is | ||
* overridden in IBar and IBar:fooBar() is overridden in IFoo through IFooBar and that introduces a | ||
* circle. | ||
*/ | ||
interface IFooBar extends IFoo, IBar {} |
13 changes: 13 additions & 0 deletions
13
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/unused_members.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
com.google.j2cl.tools.rta.multipleinheritance.FooBarImpl:m_foo__ | ||
com.google.j2cl.tools.rta.multipleinheritance.FooBarImpl:m_bar__ | ||
|
||
com.google.j2cl.tools.rta.multipleinheritance.IBar:m_fooBar__ | ||
com.google.j2cl.tools.rta.multipleinheritance.IBar:m_bar__ | ||
com.google.j2cl.tools.rta.multipleinheritance.IBar:$clinit | ||
|
||
com.google.j2cl.tools.rta.multipleinheritance.IFoo:m_fooBar__ | ||
com.google.j2cl.tools.rta.multipleinheritance.IFoo:m_foo__ | ||
com.google.j2cl.tools.rta.multipleinheritance.IFoo:$clinit | ||
|
||
com.google.j2cl.tools.rta.multipleinheritance.IFooBar:$clinit | ||
|
1 change: 1 addition & 0 deletions
1
tools/javatests/com/google/j2cl/tools/rta/multipleinheritance/unused_types.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# deliberately empty |