diff options
Diffstat (limited to 'sources/scalac/transformer')
-rw-r--r-- | sources/scalac/transformer/AddAccessors.java | 2 | ||||
-rw-r--r-- | sources/scalac/transformer/AddInterfaces.java | 2 | ||||
-rw-r--r-- | sources/scalac/transformer/AddInterfacesPhase.java | 2 | ||||
-rw-r--r-- | sources/scalac/transformer/Erasure.java | 14 | ||||
-rw-r--r-- | sources/scalac/transformer/LambdaLift.java | 34 | ||||
-rw-r--r-- | sources/scalac/transformer/OwnerTransformer.java | 27 | ||||
-rw-r--r-- | sources/scalac/transformer/UnCurry.java | 4 |
7 files changed, 56 insertions, 29 deletions
diff --git a/sources/scalac/transformer/AddAccessors.java b/sources/scalac/transformer/AddAccessors.java index 3d3c5a9ba8..aaed700b89 100644 --- a/sources/scalac/transformer/AddAccessors.java +++ b/sources/scalac/transformer/AddAccessors.java @@ -57,7 +57,7 @@ public class AddAccessors extends Transformer { switch (tree) { case ClassDef(_, // : _, - Tree.TypeDef[] tparams, + Tree.AbsTypeDef[] tparams, Tree.ValDef[][] vparams, Tree tpe, Tree.Template impl): { diff --git a/sources/scalac/transformer/AddInterfaces.java b/sources/scalac/transformer/AddInterfaces.java index 69c9bf0a58..18d7f296e3 100644 --- a/sources/scalac/transformer/AddInterfaces.java +++ b/sources/scalac/transformer/AddInterfaces.java @@ -114,7 +114,7 @@ class AddInterfaces extends Transformer { case DefDef(int mods, Name name, - TypeDef[] tparams, + AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): { diff --git a/sources/scalac/transformer/AddInterfacesPhase.java b/sources/scalac/transformer/AddInterfacesPhase.java index 77b9fdb5b2..fbbed6a98d 100644 --- a/sources/scalac/transformer/AddInterfacesPhase.java +++ b/sources/scalac/transformer/AddInterfacesPhase.java @@ -42,7 +42,7 @@ public class AddInterfacesPhase extends PhaseDescriptor { public Type transformInfo(Symbol sym, Type tp) { if (sym.isPrimaryConstructor()) { Symbol clazz = sym.primaryConstructorClass(); - if (clazz.isPackage() || !needInterface(clazz)) return tp; + if (!(clazz.isClass() && needInterface(clazz))) return tp; // The symbol is a constructor of a class which needs // an interface. All its value arguments have to be // removed. diff --git a/sources/scalac/transformer/Erasure.java b/sources/scalac/transformer/Erasure.java index 5e855c2cd3..aceb0b03f1 100644 --- a/sources/scalac/transformer/Erasure.java +++ b/sources/scalac/transformer/Erasure.java @@ -15,7 +15,8 @@ import scalac.Global; import scalac.Unit; import scalac.ast.Tree; import scalac.ast.Tree.Template; -import scalac.ast.Tree.TypeDef; +import scalac.ast.Tree.AbsTypeDef; +import scalac.ast.Tree.AliasTypeDef; import scalac.ast.Tree.ValDef; import scalac.ast.TreeList; import scalac.ast.Transformer; @@ -329,22 +330,22 @@ public class Erasure extends Transformer implements Modifiers { assert tree.type != null : tree; Type owntype = eraseFully ? tree.type.fullErasure() : tree.type.erasure(); switch (tree) { - case ClassDef(_, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): + case ClassDef(_, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): Symbol oldCurrentClass = currentClass; currentClass = tree.symbol(); Tree newTree = - copy.ClassDef(tree, new TypeDef[0], + copy.ClassDef(tree, new AbsTypeDef[0], transform(vparams), tpe, transform(impl, tree.symbol())) .setType(owntype); currentClass = oldCurrentClass; return newTree; - case DefDef(_, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): + case DefDef(_, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): addBridges(tree.symbol()); Tree tpe1 = gen.mkType(tpe.pos, tpe.type.fullErasure()); Tree rhs1 = (rhs == Tree.Empty) ? rhs : transform(rhs, tpe1.type); return copy.DefDef( - tree, new TypeDef[0], transform(vparams), tpe1, rhs1) + tree, new AbsTypeDef[0], transform(vparams), tpe1, rhs1) .setType(owntype); case ValDef(_, _, Tree tpe, Tree rhs): @@ -352,7 +353,8 @@ public class Erasure extends Transformer implements Modifiers { Tree rhs1 = (rhs == Tree.Empty) ? rhs : transform(rhs, tpe1.type); return copy.ValDef(tree, tpe1, rhs1).setType(owntype); - case TypeDef(_, _, _, _): + case AbsTypeDef(_, _, _, _): + case AliasTypeDef(_, _, _, _): // eliminate return Tree.Empty; diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java index 6193af3fa3..8651abb0c7 100644 --- a/sources/scalac/transformer/LambdaLift.java +++ b/sources/scalac/transformer/LambdaLift.java @@ -209,15 +209,24 @@ public class LambdaLift extends OwnerTransformer } return super.transform(tree); - case TypeDef(int mods, Name name, Tree rhs, Tree lobound): + case AbsTypeDef(int mods, Name name, Tree rhs, Tree lobound): // ignore type definition as owner. // reason: it might be in a refinement // todo: handle type parameters? - return copy.TypeDef( + return copy.AbsTypeDef( tree, sym, transform(rhs, currentOwner), transform(lobound, currentOwner)); + case AliasTypeDef(int mods, Name name, AbsTypeDef[] tparams, Tree rhs): + // ignore type definition as owner. + // reason: it might be in a refinement + // todo: handle type parameters? + return copy.AliasTypeDef( + tree, sym, + transform(tparams, currentOwner), + transform(rhs, currentOwner)); + case Ident(_): if (sym.isLocal()) { if (sym.isMethod()) { @@ -321,7 +330,7 @@ public class LambdaLift extends OwnerTransformer liftSymbol(stats[i]); return copy.Block(tree, transform(stats)); - case ClassDef(int mods, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): + case ClassDef(int mods, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): Symbol sym = tree.symbol(); if ((mods & LIFTED) != 0) { ((ClassDef) tree).mods &= ~LIFTED; @@ -344,7 +353,7 @@ public class LambdaLift extends OwnerTransformer transform(impl, sym)); } - case DefDef(int mods, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): + case DefDef(int mods, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): Symbol sym = tree.symbol(); if ((mods & LIFTED) != 0) { ((DefDef) tree).mods &= ~LIFTED; @@ -365,15 +374,24 @@ public class LambdaLift extends OwnerTransformer transform(rhs, sym)); } - case TypeDef(int mods, Name name, Tree rhs, Tree lobound): + case AbsTypeDef(int mods, Name name, Tree rhs, Tree lobound): // ignore type definition as owner. // reason: it might be in a refinement // todo: handle type parameters? - return copy.TypeDef( + return copy.AbsTypeDef( tree, tree.symbol(), transform(rhs, currentOwner), transform(lobound, currentOwner)); + case AliasTypeDef(int mods, Name name, AbsTypeDef[] tparams, Tree rhs): + // ignore type definition as owner. + // reason: it might be in a refinement + // todo: handle type parameters? + return copy.AliasTypeDef( + tree, tree.symbol(), + transform(tparams, currentOwner), + transform(rhs, currentOwner)); + case ValDef(_, _, Tree tpe, Tree rhs): Symbol sym = tree.symbol(); Tree tpe1 = transform(tpe); @@ -587,9 +605,9 @@ public class LambdaLift extends OwnerTransformer } } - TypeDef[] addTypeParams(TypeDef[] tparams, Symbol[] newtparams) { + AbsTypeDef[] addTypeParams(AbsTypeDef[] tparams, Symbol[] newtparams) { if (newtparams.length == 0) return tparams; - TypeDef[] tparams1 = new TypeDef[tparams.length + newtparams.length]; + AbsTypeDef[] tparams1 = new AbsTypeDef[tparams.length + newtparams.length]; System.arraycopy(tparams, 0, tparams1, 0, tparams.length); for (int i = 0; i < newtparams.length; i++) { tparams1[tparams.length + i] = gen.mkTypeParam(newtparams[i]); diff --git a/sources/scalac/transformer/OwnerTransformer.java b/sources/scalac/transformer/OwnerTransformer.java index 587362e345..bb7ab098c7 100644 --- a/sources/scalac/transformer/OwnerTransformer.java +++ b/sources/scalac/transformer/OwnerTransformer.java @@ -43,10 +43,10 @@ public class OwnerTransformer extends Transformer { return tree1; } - public TypeDef[] transform(TypeDef[] params, Symbol owner) { + public AbsTypeDef[] transform(AbsTypeDef[] params, Symbol owner) { Symbol prevOwner = currentOwner; currentOwner = owner; - TypeDef[] res = transform(params); + AbsTypeDef[] res = transform(params); currentOwner = prevOwner; return res; } @@ -95,7 +95,7 @@ public class OwnerTransformer extends Transformer { transform(packaged), transform(impl, packaged.symbol())); - case ClassDef(_, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): + case ClassDef(_, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): Symbol symbol = tree.symbol(); return copy.ClassDef( tree, symbol, @@ -111,7 +111,7 @@ public class OwnerTransformer extends Transformer { transform(tpe), transform(impl, symbol.moduleClass())); - case DefDef(_, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): + case DefDef(_, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): Symbol symbol = tree.symbol(); return copy.DefDef( tree, symbol, @@ -127,12 +127,19 @@ public class OwnerTransformer extends Transformer { transform(tpe), transform(rhs, symbol)); - case TypeDef(int mods, Name name, Tree rhs, Tree lobound): - Symbol sym = tree.symbol(); - return copy.TypeDef( - tree, sym, - transform(rhs, sym), - transform(lobound, sym)); + case AbsTypeDef(int mods, Name name, Tree rhs, Tree lobound): + Symbol symbol = tree.symbol(); + return copy.AbsTypeDef( + tree, symbol, + transform(rhs, symbol), + transform(lobound, symbol)); + + case AliasTypeDef(int mods, Name name, AbsTypeDef[] tparams, Tree rhs): + Symbol symbol = tree.symbol(); + return copy.AliasTypeDef( + tree, symbol, + transform(tparams, symbol), + transform(rhs, symbol)); default: return super.transform(tree); diff --git a/sources/scalac/transformer/UnCurry.java b/sources/scalac/transformer/UnCurry.java index ff81672940..3d9d46c9cf 100644 --- a/sources/scalac/transformer/UnCurry.java +++ b/sources/scalac/transformer/UnCurry.java @@ -72,14 +72,14 @@ public class UnCurry extends OwnerTransformer //uncurry type and symbol if (tree.type != null) tree.type = descr.uncurry(tree.type); switch (tree) { - case ClassDef(_, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): + case ClassDef(_, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Template impl): return copy.ClassDef( tree, tree.symbol(), tparams, uncurry(transform(vparams, tree.symbol())), tpe, transform(impl, tree.symbol())); - case DefDef(_, _, TypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): + case DefDef(_, _, AbsTypeDef[] tparams, ValDef[][] vparams, Tree tpe, Tree rhs): Tree rhs1 = transform(rhs, tree.symbol()); return copy.DefDef( tree, tree.symbol(), tparams, |