From 4409444f4994d1337f78484f0a0e5dc593f013fc Mon Sep 17 00:00:00 2001 From: schinz Date: Thu, 28 Aug 2003 09:07:57 +0000 Subject: - bug fix: correctly handle calls to the primar... - bug fix: correctly handle calls to the primary constructor from secondary constructors --- sources/scalac/backend/jvm/GenJVM.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'sources/scalac/backend') diff --git a/sources/scalac/backend/jvm/GenJVM.java b/sources/scalac/backend/jvm/GenJVM.java index b07e1f6d00..30f8ee3f9b 100644 --- a/sources/scalac/backend/jvm/GenJVM.java +++ b/sources/scalac/backend/jvm/GenJVM.java @@ -258,7 +258,7 @@ class GenJVM { } break; case Apply(TypeApply(Tree fun, Tree[] args), _): { - genLoadQualifier(ctx, fun); + genLoadQualifier(ctx, fun, true); JType type = typeStoJ(args[0].type); if (fun.symbol() == defs.IS) { @@ -378,15 +378,14 @@ class GenJVM { JType[] argTypes = funType.getArgumentTypes(); boolean isConstrCall = (funSym.name == CONSTRUCTOR_NAME); - boolean isSuperCall; + boolean isSuperCall = false; switch (fun) { - case Select(Super(_, _), _): isSuperCall = true; break; - default: isSuperCall = false; break; + case Select(Super(_, _), _): isSuperCall = true; } boolean isStatic = isStaticMember(funSym); - if (!(isStatic || (isConstrCall && !isSuperCall))) - genLoadQualifier(ctx, fun); + if (!isStatic) + genLoadQualifier(ctx, fun, !isConstrCall); for (int i = 0; i < args.length; ++i) genLoad(ctx, args[i], argTypes[i]); @@ -452,7 +451,7 @@ class GenJVM { if (isStaticMember(sym)) ctx.code.emitGETSTATIC(className, fieldName, fieldType); else { - genLoadQualifier(ctx, tree); + genLoadQualifier(ctx, tree, true); ctx.code.emitGETFIELD(className, fieldName, fieldType); } generatedType = fieldType; @@ -593,10 +592,11 @@ class GenJVM { * Generate code to load the qualifier of the given tree, which * can be implicitely "this". */ - protected void genLoadQualifier(Context ctx, Tree tree) { + protected void genLoadQualifier(Context ctx, Tree tree, boolean implicitThis) { switch (tree) { case Ident(_): - ctx.code.emitALOAD_0(); + if (implicitThis) + ctx.code.emitALOAD_0(); break; case Select(Tree qualifier, _): genLoad(ctx, qualifier, JAVA_LANG_OBJECT_T); @@ -630,7 +630,7 @@ class GenJVM { break; case Select(Tree qualifier, _): if (!isStaticMember(sym)) - genLoadQualifier(ctx, tree); + genLoadQualifier(ctx, tree, true); break; default: throw global.fail("unexpected left-hand side", tree); -- cgit v1.2.3