diff options
author | Martin Odersky <odersky@gmail.com> | 2004-04-08 13:25:45 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2004-04-08 13:25:45 +0000 |
commit | 98a03600e089ca46db9fe74cd3a0295a44148fff (patch) | |
tree | c09ab0d0833c0f0c76617045b01ebdf5abbfdac8 /sources/scalac | |
parent | 645f87a5a839685fde5ee9fbeb55d242a32445d4 (diff) | |
download | scala-98a03600e089ca46db9fe74cd3a0295a44148fff.tar.gz scala-98a03600e089ca46db9fe74cd3a0295a44148fff.tar.bz2 scala-98a03600e089ca46db9fe74cd3a0295a44148fff.zip |
*** empty log message ***
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/symtab/Modifiers.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 3 | ||||
-rw-r--r-- | sources/scalac/typechecker/RefCheck.java | 61 |
3 files changed, 38 insertions, 28 deletions
diff --git a/sources/scalac/symtab/Modifiers.java b/sources/scalac/symtab/Modifiers.java index afe215ea3d..dd6a6167ed 100644 --- a/sources/scalac/symtab/Modifiers.java +++ b/sources/scalac/symtab/Modifiers.java @@ -31,7 +31,7 @@ public interface Modifiers { int JAVA = 0x00001000; // symbol was defined by a Java class int MODUL = 0x00002000; // symbol is module or class implementing a module int MUTABLE = 0x00004000; // symbol is a mutable variable. - int VIEWBOUND = 0x00004000; // type symbol has a <+ bound. + int VIEWBOUND = 0x00004000; // type symbol has a <% bound. int PARAM = 0x00008000; // symbol is a (type) parameter to a method int INITIALIZED = 0x00010000; // symbol's definition is complete diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index ccd9f2632a..bbfd7c0301 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -1791,7 +1791,8 @@ final class AbsTypeSymbol extends TypeSymbol { public Type vuBound() { initialize(); - return vubound == null ? Global.instance.definitions.ANY_TYPE() : vubound; + return !isViewBounded() || vubound == null + ? Global.instance.definitions.ANY_TYPE() : vubound; } public Symbol setLoBound(Type lobound) { diff --git a/sources/scalac/typechecker/RefCheck.java b/sources/scalac/typechecker/RefCheck.java index 2bb96cbe69..f7649a9792 100644 --- a/sources/scalac/typechecker/RefCheck.java +++ b/sources/scalac/typechecker/RefCheck.java @@ -820,45 +820,54 @@ public class RefCheck extends Transformer implements Modifiers, Kinds { * the case classe's primary constructor `constr'. */ private Tree toConstructor(Tree tree, Symbol constr) { - switch (tree) { - case Apply(Tree fn, Tree[] args): - return copy.Apply(tree, toConstructor1(fn, constr), args); - default: - return gen.Apply( - tree.pos, toConstructor1(tree, constr), Tree.EMPTY_ARRAY); - } + int missing = constr.getType().paramSectionCount() - applyNesting(tree); + assert missing >= 0 && missing <= 1; + Tree tree1 = toConstructor1(tree, constr, missing > 0); + if (missing > 0) return gen.Apply(tree1, Tree.EMPTY_ARRAY); + else return tree1; } //where - private Tree toConstructor1(Tree tree, Symbol constr) { + private int applyNesting(Tree tree) { + switch (tree) { + case Apply(Tree fn, Tree[] args): + return applyNesting(fn) + 1; + default: + return 0; + } + } + + private Tree toConstructor1(Tree tree, Symbol constr, boolean addEmpty) { + Tree tree1 = toConstructor2(tree, constr, addEmpty); + if (addEmpty) + return tree1.duplicate() + .setType(addEmptyParams(tree1.getType())); + else + return tree1; + } + + private Tree toConstructor2(Tree tree, Symbol constr, boolean addEmpty) { switch (tree) { + case Apply(Tree fn, Tree[] args): + return copy.Apply( + tree, toConstructor1(fn, constr, addEmpty), args); case TypeApply(Tree fn, Tree[] args): - return toMethodType( - copy.TypeApply(tree, toConstructor1(fn, constr), args)); + return copy.TypeApply( + tree, toConstructor1(fn, constr, addEmpty), args); case Ident(_): - return toMethodType( - copy.Ident(tree, constr)); + return copy.Ident(tree, constr); case Select(Tree qual, _): - return toMethodType( - copy.Select(tree, constr, qual)); + return copy.Select(tree, constr, qual); default: throw new ApplicationError(); } } - private Tree toMethodType(Tree tree) { - Type tp = toMethodType(tree.type); - if (tp == tree.type) return tree; - else return tree.duplicate().setType(tp); - } - - private Type toMethodType(Type tp) { + private Type addEmptyParams(Type tp) { switch (tp) { - case MethodType(_, _): - return tp; + case MethodType(Symbol[] vparams, Type restp): + return Type.MethodType(vparams, addEmptyParams(restp)); case PolyType(Symbol[] tparams, Type restp): - Type restp1 = toMethodType(restp); - if (restp == restp) return tp; - else return Type.PolyType(tparams, restp1); + return Type.PolyType(tparams, addEmptyParams(restp)); default: return Type.MethodType(Symbol.EMPTY_ARRAY, tp); } |