Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6c59f07f6 |
No files matched your search
@@ -0,0 +1,2 @@
|
|||||||
|
public class Bug422 {}
|
||||||
|
public class Bug422 {}
|
||||||
@@ -598,10 +598,7 @@ expressionList
|
|||||||
;
|
;
|
||||||
|
|
||||||
methodCall
|
methodCall
|
||||||
// eager: m(...)
|
|
||||||
: identifier '(' expressionList? ')'
|
: identifier '(' expressionList? ')'
|
||||||
// lazy: m.(...)
|
|
||||||
| identifier '.' '(' expressionList? ')'
|
|
||||||
| THIS '(' expressionList? ')'
|
| THIS '(' expressionList? ')'
|
||||||
| SUPER '(' expressionList? ')'
|
| SUPER '(' expressionList? ')'
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import de.dhbwstuttgart.bytecode.Codegen;
|
|||||||
import de.dhbwstuttgart.bytecode.FunNGenerator;
|
import de.dhbwstuttgart.bytecode.FunNGenerator;
|
||||||
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
import de.dhbwstuttgart.environment.CompilationEnvironment;
|
||||||
import de.dhbwstuttgart.environment.DirectoryClassLoader;
|
import de.dhbwstuttgart.environment.DirectoryClassLoader;
|
||||||
|
import de.dhbwstuttgart.exceptions.CompilerException;
|
||||||
import de.dhbwstuttgart.exceptions.CompilerWarning;
|
import de.dhbwstuttgart.exceptions.CompilerWarning;
|
||||||
import de.dhbwstuttgart.exceptions.DebugException;
|
import de.dhbwstuttgart.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.exceptions.WarningsException;
|
import de.dhbwstuttgart.exceptions.WarningsException;
|
||||||
@@ -171,6 +172,8 @@ public class JavaTXCompiler {
|
|||||||
|
|
||||||
var numberOfGenerics = decl == null ? 0 : decl.genericTypeVar().size();
|
var numberOfGenerics = decl == null ? 0 : decl.genericTypeVar().size();
|
||||||
var className = pkgName + (!pkgName.isEmpty() ? "." : "") + name;
|
var className = pkgName + (!pkgName.isEmpty() ? "." : "") + name;
|
||||||
|
if (classRegistry.contains(className))
|
||||||
|
throw new CompilerException("Duplicate class definition: " + className);
|
||||||
classRegistry.addName(className, numberOfGenerics);
|
classRegistry.addName(className, numberOfGenerics);
|
||||||
input.add(classRegistry.getName(className));
|
input.add(classRegistry.getName(className));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package de.dhbwstuttgart.exceptions;
|
||||||
|
|
||||||
|
public class CompilerException extends RuntimeException {
|
||||||
|
public CompilerException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -734,9 +734,6 @@ public class StatementGenerator {
|
|||||||
ret = new SuperCall(argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
ret = new SuperCall(argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
||||||
} else if(expr.THIS() != null) {
|
} else if(expr.THIS() != null) {
|
||||||
ret = new ThisCall(argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
ret = new ThisCall(argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
||||||
} else if (expr.DOT() != null) {
|
|
||||||
// Lazy-Aufruf: m.(...)
|
|
||||||
ret = new LazyMethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
|
||||||
} else {
|
} else {
|
||||||
ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
||||||
}
|
}
|
||||||
@@ -756,13 +753,7 @@ public class StatementGenerator {
|
|||||||
ArgumentList argumentList = convertArguments(expr.expressionList());
|
ArgumentList argumentList = convertArguments(expr.expressionList());
|
||||||
ArrayList<TypePlaceholder> signature = argumentList.getArguments().stream().map(x -> TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
ArrayList<TypePlaceholder> signature = argumentList.getArguments().stream().map(x -> TypePlaceholder.fresh(offset)).collect(Collectors.toCollection(ArrayList::new));
|
||||||
signature.add(TypePlaceholder.fresh(offset)); // return type
|
signature.add(TypePlaceholder.fresh(offset)); // return type
|
||||||
MethodCall ret;
|
MethodCall ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
||||||
if (expr.DOT() != null) {
|
|
||||||
// Lazy-Aufruf: receiver.m.(...)
|
|
||||||
ret = new LazyMethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
|
||||||
} else {
|
|
||||||
ret = new MethodCall(TypePlaceholder.fresh(offset), getReceiver(receiver), name, argumentList, TypePlaceholder.fresh(offset), signature, offset);
|
|
||||||
}
|
|
||||||
ret.setStatement();
|
ret.setStatement();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package de.dhbwstuttgart.syntaxtree.statement;
|
|
||||||
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
|
||||||
import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder;
|
|
||||||
import org.antlr.v4.runtime.Token;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
// Lazy-Methodenaufruf: m.(...)
|
|
||||||
public class LazyMethodCall extends MethodCall {
|
|
||||||
|
|
||||||
public LazyMethodCall(RefTypeOrTPHOrWildcardOrGeneric retType, Receiver receiver, String methodName,
|
|
||||||
ArgumentList argumentList, RefTypeOrTPHOrWildcardOrGeneric receiverType,
|
|
||||||
ArrayList<TypePlaceholder> signature, Token offset) {
|
|
||||||
super(retType, receiver, methodName, argumentList, receiverType, signature, offset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
import de.dhbwstuttgart.bytecode.CodeGenException;
|
import de.dhbwstuttgart.bytecode.CodeGenException;
|
||||||
import de.dhbwstuttgart.core.ConsoleInterface;
|
import de.dhbwstuttgart.core.ConsoleInterface;
|
||||||
|
import de.dhbwstuttgart.exceptions.CompilerException;
|
||||||
|
import de.dhbwstuttgart.exceptions.DebugException;
|
||||||
import de.dhbwstuttgart.exceptions.WarningsException;
|
import de.dhbwstuttgart.exceptions.WarningsException;
|
||||||
import de.dhbwstuttgart.util.Logger;
|
import de.dhbwstuttgart.util.Logger;
|
||||||
import de.dhbwstuttgart.util.Logger.LogLevel;
|
import de.dhbwstuttgart.util.Logger.LogLevel;
|
||||||
@@ -1704,4 +1706,14 @@ public class TestComplete {
|
|||||||
var clazz = classFiles.get("Bug406");
|
var clazz = classFiles.get("Bug406");
|
||||||
clazz.getDeclaredMethod("main", List.class).invoke(null, List.of());
|
clazz.getDeclaredMethod("main", List.class).invoke(null, List.of());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testBug422() throws Exception {
|
||||||
|
try {
|
||||||
|
var classFiles = generateClassFiles(createClassLoader(), "Bug422.jav");
|
||||||
|
fail("Shouldn't compile!");
|
||||||
|
} catch (CompilerException e) {
|
||||||
|
assertEquals("Duplicate class definition: Bug422", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user