diff options
author | Martin Odersky <odersky@gmail.com> | 2003-11-11 14:06:09 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-11-11 14:06:09 +0000 |
commit | ab3ba403efdb2c4ab829e526c8fe21783c44ef27 (patch) | |
tree | 43b30f20b1a6a9cdbe0f58a8d876f89562da4b42 /sources/scalac | |
parent | 8f126982806efc1c68ac717c7fd9dba70d85e787 (diff) | |
download | scala-ab3ba403efdb2c4ab829e526c8fe21783c44ef27.tar.gz scala-ab3ba403efdb2c4ab829e526c8fe21783c44ef27.tar.bz2 scala-ab3ba403efdb2c4ab829e526c8fe21783c44ef27.zip |
*** empty log message ***
Diffstat (limited to 'sources/scalac')
-rw-r--r-- | sources/scalac/ast/TreeGen.java | 3 | ||||
-rw-r--r-- | sources/scalac/ast/parser/PatternNormalizer.java | 18 | ||||
-rw-r--r-- | sources/scalac/ast/parser/Scanner.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Type.java | 30 | ||||
-rw-r--r-- | sources/scalac/typechecker/Infer.java | 14 |
5 files changed, 35 insertions, 32 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 0dc210e2ae..987bf8b743 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -262,6 +262,7 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { /** Builds a reference corresponding to given symbol. */ public Tree mkRef(int pos, Symbol sym) { + //System.out.println("mkref " + sym.owner().thisType() + " . " + sym);//DEBUG return mkRef(pos, sym.owner().thisType(), sym); } @@ -405,7 +406,7 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { global.prevPhase(); return mkApplyTV(pos, mkRef(pos, constr), targs, vargs); } - public Tree mkPrimaryConstr(int pos, Symbol clazz,Type[]targs,Tree[]vargs){ + public Tree mkPrimaryConstr(int pos, Symbol clazz, Type[]targs, Tree[]vargs){ return mkPrimaryConstr(pos,clazz.owner().thisType(),clazz,targs,vargs); } diff --git a/sources/scalac/ast/parser/PatternNormalizer.java b/sources/scalac/ast/parser/PatternNormalizer.java index 8b69ef84ae..f2a35829df 100644 --- a/sources/scalac/ast/parser/PatternNormalizer.java +++ b/sources/scalac/ast/parser/PatternNormalizer.java @@ -200,7 +200,7 @@ public class PatternNormalizer { */ // apply `flattenAlternative' to each tree in ts - Tree[] flattenAlternatives( Tree[] ts ) { + public Tree[] flattenAlternatives( Tree[] ts ) { Tree[] res = new Tree[ ts.length ]; for( int i = 0; i < ts.length; i++ ) res[ i ] = flattenAlternative( ts[ i ] ); @@ -208,7 +208,7 @@ public class PatternNormalizer { } // main algo for (1) - Tree flattenAlternative( Tree tree ) { + public Tree flattenAlternative( Tree tree ) { switch( tree ) { case Alternative( Tree[] choices ): TreeList cs = new TreeList(); @@ -244,7 +244,7 @@ public class PatternNormalizer { } // main algo for (1), precondition: choices are children of an Alternative node - TreeList flattenAlternativeChildren( Tree[] choices ) { + public TreeList flattenAlternativeChildren( Tree[] choices ) { boolean allEmpty = true; TreeList cs = new TreeList(); for( int j = 0; j < choices.length; j++ ) { @@ -275,14 +275,14 @@ public class PatternNormalizer { */ // apply `flattenSequence' to each tree in trees - Tree[] flattenSequences( Tree[] trees ) { + public Tree[] flattenSequences( Tree[] trees ) { Tree[] res = new Tree[ trees.length ]; for( int i = 0; i < trees.length; i++ ) res[ i ] = flattenSequence( trees[ i ] ); return res; } // main algo for (2) - Tree flattenSequence( Tree tree ) { + public Tree flattenSequence( Tree tree ) { //System.out.println("flattenSequence of "+tree); switch( tree ) { /* @@ -347,14 +347,14 @@ public class PatternNormalizer { /** applies `elimSequence' to each tree is ts */ - Tree[] elimSequences( Tree[] ts ) { + public Tree[] elimSequences( Tree[] ts ) { Tree[] res = new Tree[ ts.length ]; for( int i = 0; i < ts.length; i++ ) res[ i ] = elimSequence( ts[ i ] ); return res; } - Tree elimSequence( Tree tree ) { + public Tree elimSequence( Tree tree ) { switch( tree ) { case Sequence( Tree[] trees ): // might be empty ... @@ -457,7 +457,7 @@ public class PatternNormalizer { /** applies `warpAlternative' to each tree is ts */ - Tree[] wrapAlternatives( Tree[] trees ) { + public Tree[] wrapAlternatives( Tree[] trees ) { Tree[] newts = new Tree[ trees.length ]; for( int i = 0; i < trees.length; i++ ) newts[ i ] = wrapAlternative( trees[ i ] ); @@ -466,7 +466,7 @@ public class PatternNormalizer { /** main algo for (4) */ - Tree wrapAlternative( Tree tree ) { + public Tree wrapAlternative( Tree tree ) { switch( tree ) { case Alternative( Tree[] choices ): return make.Alternative( tree.pos, wrapAlternativeChildren( choices )); diff --git a/sources/scalac/ast/parser/Scanner.java b/sources/scalac/ast/parser/Scanner.java index 7d5910588b..ae8a9ba187 100644 --- a/sources/scalac/ast/parser/Scanner.java +++ b/sources/scalac/ast/parser/Scanner.java @@ -24,7 +24,7 @@ public class Scanner extends TokenData { /** buffer for the documentation comment */ - protected StringBuffer docBuffer = null; + public StringBuffer docBuffer = null; /** add the given character to the documentation buffer */ diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java index b419a83e7c..632900eea4 100644 --- a/sources/scalac/symtab/Type.java +++ b/sources/scalac/symtab/Type.java @@ -152,21 +152,21 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags { } private static Type value2type(Object value) { - if (value instanceof Character) - return Global.instance.definitions.CHAR_TYPE(); - else if (value instanceof Integer) - return Global.instance.definitions.INT_TYPE(); - else if (value instanceof Long) - return Global.instance.definitions.LONG_TYPE(); - else if (value instanceof Float) - return Global.instance.definitions.FLOAT_TYPE(); - else if (value instanceof Double) - return Global.instance.definitions.DOUBLE_TYPE(); - else if (value instanceof String) - return Global.instance.definitions.JAVA_STRING_TYPE(); - else if (value instanceof Boolean) - return Global.instance.definitions.BOOLEAN_TYPE(); - else throw new ApplicationError(); + if (value instanceof Character) + return Global.instance.definitions.CHAR_CLASS.typeConstructor(); + else if (value instanceof Integer) + return Global.instance.definitions.INT_CLASS.typeConstructor(); + else if (value instanceof Long) + return Global.instance.definitions.LONG_CLASS.typeConstructor(); + else if (value instanceof Float) + return Global.instance.definitions.FLOAT_CLASS.typeConstructor(); + else if (value instanceof Double) + return Global.instance.definitions.DOUBLE_CLASS.typeConstructor(); + else if (value instanceof String) + return Global.instance.definitions.JAVA_STRING_CLASS.typeConstructor(); + else if (value instanceof Boolean) + return Global.instance.definitions.BOOLEAN_CLASS.typeConstructor(); + else throw new ApplicationError(); } public static Type singleTypeMethod(Type pre, Symbol sym) { diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java index 0ad12d6cd2..29acd44100 100644 --- a/sources/scalac/typechecker/Infer.java +++ b/sources/scalac/typechecker/Infer.java @@ -337,13 +337,15 @@ public class Infer implements Modifiers, Kinds { Type[] result; if (params.length == 1 && (params[0].flags & REPEATED) != 0) { Type[] formals = new Type[length]; - Type ft = params[0].type().typeArgs()[0]; - // params[0] has type Seq[T], we need T here - for (int i = 0; i < length; i++) formals[i] = ft; - return formals; - } else { - return Symbol.type(params); + Type[] args = params[0].type().typeArgs(); + if (args.length == 1) { + Type ft = args[0]; + // params[0] has type Seq[T], we need T here + for (int i = 0; i < length; i++) formals[i] = ft; + return formals; + } } + return Symbol.type(params); } /** Is type fully defined, i.e. no embedded anytypes or typevars in it? |