From 766aece3147dcd211b5e46c92df2552ff5b87892 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 13 Mar 2003 11:00:02 +0000 Subject: *** empty log message *** --- sources/examples/auction.scala | 3 ++- sources/scala/List.scala | 2 ++ sources/scala/Seq.scala | 8 ++++++-- sources/scalac/typechecker/Analyzer.java | 11 +++++++++-- 4 files changed, 19 insertions(+), 5 deletions(-) (limited to 'sources') diff --git a/sources/examples/auction.scala b/sources/examples/auction.scala index 9f96dc2984..2d00fca880 100644 --- a/sources/examples/auction.scala +++ b/sources/examples/auction.scala @@ -21,7 +21,8 @@ class Auction(seller: Actor, minBid: Int, closing: Date) extends Actor() { val timeToShutdown = 36000000; // msec val bidIncrement = 10; - override def run() { + override def run() = execute; + def execute { var maxBid = minBid - bidIncrement; var maxBidder: Actor = _; var running = true; diff --git a/sources/scala/List.scala b/sources/scala/List.scala index af9305b7fc..66f6cea807 100644 --- a/sources/scala/List.scala +++ b/sources/scala/List.scala @@ -127,6 +127,8 @@ trait List[a] extends Seq[a] { * @return the element at position n in this list. * @throws java.lang.RuntimeException if the list is too short. */ + def apply(n: Int) = drop(n).head; + def at(n: Int) = drop(n).head; /** Returns the list resulting from applying the given function f to each diff --git a/sources/scala/Seq.scala b/sources/scala/Seq.scala index aa6b7e32e0..6eb95d3318 100644 --- a/sources/scala/Seq.scala +++ b/sources/scala/Seq.scala @@ -1,7 +1,11 @@ package scala; -trait Seq[a] { +trait Seq[a] extends Function1[Int, a] { def length: Int; def elements: Iterator[a]; - def at(index: Int): a + def apply(index: Int): a; + + /** @deprecated + */ + def at(index: Int): a; } diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java index 38e8eb2b16..5f90933576 100644 --- a/sources/scalac/typechecker/Analyzer.java +++ b/sources/scalac/typechecker/Analyzer.java @@ -1094,10 +1094,16 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { return error(tree.pos, "not found: " + decode(name)); } else { sym.flags |= ACCESSED; - if (sym.owner().kind == CLASS) + if (sym.owner().kind == CLASS) { pre = nextcontext.enclClass.owner.thisType(); - else + if (!sym.owner().isPackage()) { + tree = make.Select( + tree.pos, gen.mkStableId(tree.pos, pre), name); + //System.out.println(name + " :::> " + tree);//DEBUG + } + } else { pre = Type.localThisType; + } } } else if (sym.kind != NONE && !sym.isPreloaded()) { return error(tree.pos, @@ -1867,6 +1873,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { new ValDef[][]{Tree.ExtValDef.EMPTY_ARRAY}, Tree.Empty, templ); + //new TextTreePrinter().print(cd).println().end();//DEBUG enterSym(cd); cd = transform(cd); Symbol clazz = cd.symbol(); -- cgit v1.2.3