Fix #313
All checks were successful
Build and Test with Maven / Build-and-test-with-Maven (push) Successful in 2m43s

This commit is contained in:
Daniel Holle 2024-04-08 14:25:41 +02:00
parent 6b0816c1c4
commit 0b7f07108f
3 changed files with 14 additions and 1 deletions

View File

@ -0,0 +1,3 @@
package pkg.sub;
public interface Interface {}

View File

@ -333,7 +333,7 @@ public class SyntaxTreeGenerator {
private ClassOrInterface convertInterface(Java17Parser.InterfaceDeclarationContext ctx, int modifiers) {
this.superClass = new RefType(new JavaClassName("java.lang.Object"), new NullToken());
String className = this.pkgName.length() > 0 ? this.pkgName + "." : "" + ctx.identifier().getText();
String className = (this.pkgName.length() > 0 ? this.pkgName + "." : "") + ctx.identifier().getText();
JavaClassName name = reg.getName(className); // Holt den Package Namen mit dazu
if (!name.toString().equals(className)) { // Kommt die Klasse schon in einem anderen Package vor?
throw new TypeinferenceException("Name " + className + " bereits vorhanden in " + reg.getName(className).toString(), ctx.getStart());

View File

@ -34,4 +34,14 @@ public class TestPackages {
cmp.generateBytecode(bytecodeDirectory);
}
@Test
public void testPackageInterface() throws Exception {
var cmp = new JavaTXCompiler(
List.of(new File("resources/packageTest/pkg/sub/Interface.jav")),
List.of(new File("resources/packageTest"))
);
cmp.generateBytecode(bytecodeDirectory);
}
}