Skip to content

Commit aefb654

Browse files
committed
Fix #404: Crash when using abstract class extending abstract class via interface.
1 parent cc381b5 commit aefb654

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

jphp-core/tests/org/develnext/jphp/core/compiler/jvm/ClassesTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,18 @@ public void testBugs() {
146146
check("classes/bug123.php");
147147
check("classes/bug127.php");
148148
check("classes/bug130.php");
149+
}
150+
151+
@Test
152+
public void testBug391() {
149153
check("classes/bug391.phpt", true);
150154
}
151155

156+
@Test
157+
public void testBug404() {
158+
check("classes/bug404.phpt", true);
159+
}
160+
152161
@Test
153162
public void testBug264() {
154163
check("classes/bug264.php");
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
Crash when using abstract class extending abstract class via interface
3+
--FILE--
4+
<?php
5+
interface a
6+
{
7+
public function test();
8+
}
9+
10+
abstract class b implements a
11+
{
12+
}
13+
14+
abstract class c extends b
15+
{
16+
}
17+
18+
class d extends c
19+
{
20+
public function test() { var_dump("ok"); }
21+
}
22+
23+
(new d)->test();
24+
?>
25+
--EXPECT--
26+
string(2) "ok"

jphp-runtime/src/php/runtime/reflection/ClassEntity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public SignatureResult addMethod(MethodEntity method, String realName) {
318318
SignatureResult addResult = new SignatureResult();
319319
if (method.isAbstract && method.isFinal) {
320320
addResult.add(InvalidMethod.error(InvalidMethod.Kind.FINAL_ABSTRACT, method));
321-
} else if (method.isAbstractable() && !(method.isAbstract || type == Type.INTERFACE)) {
321+
} else if (method.isAbstractable() && !(method.isAbstract || type == Type.INTERFACE || isAbstract)) {
322322
addResult.add(InvalidMethod.error(InvalidMethod.Kind.NON_ABSTRACT, method));
323323
} else if (method.isAbstract && !method.isAbstractable()) {
324324
addResult.add(InvalidMethod.error(InvalidMethod.Kind.NON_ABSTRACTABLE, method));

0 commit comments

Comments
 (0)