Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Jul 7, 2005
1 parent 1e33553 commit 5e728c6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
12 changes: 3 additions & 9 deletions newsources/scala/Array.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
package scala;

final class Array[T](val length: Int) extends Cloneable with java.io.Serializable with Seq[T] {

def apply(i: Int): T;
def update(i: Int, x: T): Unit;

def elements = new Iterator[T] {
var index = 0;
def hasNext: Boolean = index < length;
def next: T = { val i = index; index = i + 1; apply(i) }
}
def apply(i: Int): T = throw new Error();
def update(i: Int, x: T): Unit = throw new Error();
def elements: Iterator[T] = throw new Error();
}
7 changes: 2 additions & 5 deletions sources/scala/runtime/ScalaRunTime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

package scala.runtime;


object ScalaRunTime {

/** Names for primitive typesm, used by array unboxing */
Expand All @@ -23,8 +22,6 @@ object ScalaRunTime {
val DoubleTag = ".Double";
val BooleanTag = ".Boolean";

import compat.Platform.getClass;

trait Try[a] {
def Catch[b >: a](handler: PartialFunction[Throwable, b]): b;
def Finally(handler: Unit): a;
Expand Down Expand Up @@ -66,7 +63,7 @@ object ScalaRunTime {
}

def _hashCode(x: CaseClass): Int = {
var code = getClass(x).hashCode();
var code = x.getClass().hashCode();
val arity = x.caseArity;
var i = 0;
while (i < arity) {
Expand All @@ -78,7 +75,7 @@ object ScalaRunTime {

def _equals(x: CaseClass, y: Any): Boolean = y match {
case y1: CaseClass =>
(getClass(x) eq getClass(y1)) && {
(x.getClass() eq y1.getClass()) && {
val arity = x.caseArity;
var i = 0;
while (i < arity && x.caseElement(i) == y1.caseElement(i))
Expand Down
12 changes: 6 additions & 6 deletions sources/scala/tools/nsc/matching/DetWordAutoms.scala
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class DetWordAutom {

// TEMPORARY VAR used only during determinization and debug printing
// Q -> (Label -> Q )
var deltaMap: HashMap = _;
var delta/*Map*/: HashMap = _;
// Q -> Integer;
var indexMap: HashMap = _;

Expand Down Expand Up @@ -183,7 +183,7 @@ class DetWordAutom {

this._labels = nfa.labels;
////System.out.println("Labels: "+labels);
this.deltaMap = new HashMap();
this.delta/*Map*/ = new HashMap();
//this.dead = -1;

states = new TreeSet( new StateSetComparator() );
Expand Down Expand Up @@ -222,7 +222,7 @@ class DetWordAutom {
invIndexMap.put( new Integer( ix ), P1 );
indexMap.put( P1, new Integer( ix ));
ix = ix + 1;
deltaMap.put( P1, {trans = new HashMap(); trans});
delta/*Map*/.put( P1, {trans = new HashMap(); trans});

//Console.println("...beginning 4" );
// labelled transitions
Expand Down Expand Up @@ -310,7 +310,7 @@ class DetWordAutom {
////System.out.print(state.toString() + " --> " + state_x);
//System.out.println(" deftarget " + defTarget + " --> "+defTarget_x);

trans = deltaMap.get( state ).asInstanceOf[HashMap];
trans = delta/*Map*/.get( state ).asInstanceOf[HashMap];
val newTrans = new HashMap();
val labs = _labels.iterator();
while(labs.hasNext()) {
Expand All @@ -333,7 +333,7 @@ class DetWordAutom {
_deltaq( state_x.intValue() ) = newTrans;
_defaultq( state_x.intValue() ) = defTarget_x;

deltaMap.remove( state );
delta/*Map*/.remove( state );
deftrans.remove( state );

}
Expand Down Expand Up @@ -866,7 +866,7 @@ class DetWordAutom {
while (it.hasNext()) {
val state = it.next().asInstanceOf[TreeSet];
Console.print("state:" + state.toString() + " transitions ");
trans = deltaMap.get( state ).asInstanceOf[HashMap];
trans = delta/*Map*/.get( state ).asInstanceOf[HashMap];
val labs = _labels.iterator();
while(labs.hasNext()) {
val label = labs.next();
Expand Down
2 changes: 1 addition & 1 deletion sources/scala/tools/nsc/matching/MatcherLabels.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.tools.nsc.matching ;

class MatcherLabels: TransMatcher {
abstract class MatcherLabels: TransMatcher {

import global._ ;

Expand Down
10 changes: 9 additions & 1 deletion sources/scala/tools/nsc/symtab/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ abstract class Types: SymbolTable {
/** For a typeref, its arguments. The empty list for all other types */
def typeArgs: List[Type] = List();

/** For a method or poly type, its result type,
/** For a method or poly type, its direct result type,
* the type itself for all other types */
def resultType: Type = this;

/** For a curried method or poly type its non-method result type,
* the type itself for all other types */
def finalResultType: Type = this;

/** For a method or poly type, the number of its value parameter sections,
* 0 for all other types */
def paramSectionCount: int = 0;
Expand Down Expand Up @@ -688,6 +692,8 @@ abstract class Types: SymbolTable {

override def paramSectionCount: int = resultType.paramSectionCount + 1;

override def finalResultType: Type = resultType.finalResultType;

override def erasure = {
val pts = List.mapConserve(paramTypes)(.erasure);
val res = resultType.erasure;
Expand All @@ -711,6 +717,8 @@ abstract class Types: SymbolTable {
override def paramSectionCount: int = resultType.paramSectionCount;
override def paramTypes: List[Type] = resultType.paramTypes;

override def finalResultType: Type = resultType.finalResultType;

override def parents: List[Type] = resultType.parents;
override def decls: Scope = resultType.decls;
override def symbol: Symbol = resultType.symbol;
Expand Down
11 changes: 7 additions & 4 deletions sources/scala/tools/nsc/typechecker/Typers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ abstract class Typers: Analyzer {
* If all this fails, error
*/
// def adapt(tree: Tree, mode: int, pt: Type): Tree = {
private def adapt(tree: Tree, mode: int, pt: Type): Tree = tree.tpe match {
protected def adapt(tree: Tree, mode: int, pt: Type): Tree = tree.tpe match {
case ct @ ConstantType(value) if ((mode & TYPEmode) == 0 && (ct <:< pt)) => // (0)
copy.Literal(tree, value)
case OverloadedType(pre, alts) if ((mode & FUNmode) == 0) => // (1)
Expand Down Expand Up @@ -458,8 +458,11 @@ abstract class Typers: Analyzer {
val vdef = copy.ValDef(stat, mods | PRIVATE | LOCAL, nme.LOCAL_NAME(name), tpe, rhs);
val getter: DefDef = {
val sym = vdef.symbol;
val getter = sym.owner.info.decls.lookup(name).suchThat(.hasFlag(ACCESSOR));
assert(getter != NoSymbol, vdef);
val decls = sym.owner.info.decls;
var getterEntry = decls.lookupEntry(name);
while (!(getterEntry.sym hasFlag ACCESSOR))
getterEntry = decls.lookupNextEntry(getterEntry);
val getter = getterEntry.sym;
val result = atPos(vdef.pos)(
DefDef(getter, vparamss =>
if ((mods & DEFERRED) != 0) EmptyTree else typed(gen.mkRef(sym), EXPRmode, sym.tpe)));
Expand Down Expand Up @@ -1065,7 +1068,7 @@ abstract class Typers: Analyzer {
else if (!context.owner.hasFlag(INITIALIZED))
errorTree(tree, "method " + context.owner + " has return statement; needs result type")
else {
val expr1: Tree = typed(expr, enclFun.tpe.resultType);
val expr1: Tree = typed(expr, enclFun.tpe.finalResultType);
copy.Return(tree, expr1) setSymbol enclFun setType AllClass.tpe;
}

Expand Down

0 comments on commit 5e728c6

Please sign in to comment.