diff options
author | Matthias Zenger <mzenger@gmail.com> | 2003-08-28 12:39:14 +0000 |
---|---|---|
committer | Matthias Zenger <mzenger@gmail.com> | 2003-08-28 12:39:14 +0000 |
commit | 1f02ae13680bcf874db01096105c22b4d5d3f042 (patch) | |
tree | 56b6d42ad48f39e669b439373e7e10cc1fafab16 /sources/scalac/typechecker/RefCheck.java | |
parent | 7a9bbd21f018981ce132dd7d2d4ab1ca33bd4df2 (diff) | |
download | scala-1f02ae13680bcf874db01096105c22b4d5d3f042.tar.gz scala-1f02ae13680bcf874db01096105c22b4d5d3f042.tar.bz2 scala-1f02ae13680bcf874db01096105c22b4d5d3f042.zip |
Added support for case tags.
Diffstat (limited to 'sources/scalac/typechecker/RefCheck.java')
-rw-r--r-- | sources/scalac/typechecker/RefCheck.java | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java index 460e98abeb..d25c547e20 100644 --- a/sources/scalac/typechecker/RefCheck.java +++ b/sources/scalac/typechecker/RefCheck.java @@ -588,7 +588,6 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { testtp = testtp.subst(tparams, targs); } } - // if (that is C) {... Tree cond = gen.TypeApply( gen.Select( @@ -639,6 +638,15 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { return gen.Select(qual, clazz.caseFieldAccessor(i)); } + private Tree tagMethod(ClassSymbol clazz) { + Symbol tagSym = new TermSymbol( + clazz.pos, Names.tag, clazz, + clazz.isSubClass(defs.OBJECT_CLASS) ? OVERRIDE : 0) + .setInfo(Type.MethodType(Symbol.EMPTY_ARRAY, defs.INT_TYPE)); + clazz.info().members().enter(tagSym); + return gen.DefDef(clazz.pos, tagSym, gen.mkIntLit(clazz.pos, clazz.tag())); + } + private Tree hashCodeMethod(ClassSymbol clazz) { Symbol hashCodeSym = new TermSymbol( clazz.pos, Names.hashCode, clazz, OVERRIDE) @@ -693,6 +701,7 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { ts.append(equalsMethod(clazz)); if (!hasImplementation(clazz, Names.hashCode)) ts.append(hashCodeMethod(clazz)); + ts.append(tagMethod(clazz)); if (ts.length() > 0) { Tree[] stats1 = new Tree[stats.length + ts.length()]; System.arraycopy(stats, 0, stats1, 0, stats.length); |