correctly generate Java superclass constructor calls; don't replace owner when Java method is called via a Jet class
This commit is contained in:
@@ -729,7 +729,12 @@ public class ExpressionCodegen extends JetVisitor {
|
||||
ensureReceiverOnStack(expression, null);
|
||||
if (expression.getParent() instanceof JetQualifiedExpression) {
|
||||
final JetExpression receiver = ((JetQualifiedExpression) expression.getParent()).getReceiverExpression();
|
||||
owner = expressionType(receiver).getInternalName();
|
||||
JetType expressionType = bindingContext.getExpressionType(receiver);
|
||||
DeclarationDescriptor declarationDescriptor = expressionType.getConstructor().getDeclarationDescriptor();
|
||||
PsiElement ownerDeclaration = bindingContext.getDeclarationPsiElement(declarationDescriptor);
|
||||
if (ownerDeclaration instanceof PsiClass) {
|
||||
owner = typeMapper.mapType(expressionType).getInternalName();
|
||||
}
|
||||
}
|
||||
}
|
||||
pushMethodArguments(expression, methodDescriptor);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
@@ -220,7 +222,16 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
ConstructorFrameMap frameMap) {
|
||||
ClassDescriptor classDecl = constructorDescriptor.getContainingDeclaration();
|
||||
boolean isDelegating = kind == OwnerKind.DELEGATING_IMPLEMENTATION;
|
||||
Type type = isDelegating ? JetTypeMapper.jetDelegatingImplementationType(classDecl) : JetTypeMapper.jetImplementationType(classDecl);
|
||||
PsiElement declaration = bindingContext.getDeclarationPsiElement(classDecl);
|
||||
Type type;
|
||||
if (declaration instanceof PsiClass) {
|
||||
type = JetTypeMapper.psiClassType((PsiClass) declaration);
|
||||
}
|
||||
else {
|
||||
type = isDelegating
|
||||
? JetTypeMapper.jetDelegatingImplementationType(classDecl)
|
||||
: JetTypeMapper.jetImplementationType(classDecl);
|
||||
}
|
||||
|
||||
if (!isJavaSuperclass) {
|
||||
if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class GameError(msg: String): Exception(msg) {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val e = GameError("foo")
|
||||
return if (e.getMessage() == "foo") "OK" else "fail"
|
||||
}
|
||||
@@ -99,4 +99,8 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
public void testSecondaryConstructors() throws Exception {
|
||||
blackBoxFile("classes/secondaryConstructors.jet");
|
||||
}
|
||||
|
||||
public void testExceptionConstructor() throws Exception {
|
||||
blackBoxFile("classes/exceptionConstructor.jet");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user