Skip to content

Commit

Permalink
*** empty log message ***
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Nov 21, 2005
1 parent 5993450 commit b83bbad
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 54 deletions.
2 changes: 2 additions & 0 deletions doc/reference/ReferencePart.tex
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ \section{Literals}
floating point numbers (of types \code{Float} and \code{Double}), characters, and
strings. The syntax of these literals is in each case as in Java.

\todo{say that we take values from Java, give examples of some lits in particular float and double.}

\syntax\begin{lstlisting}
intLit ::= $\mbox{\rm\em ``as in Java''}$
floatLit ::= $\mbox{\rm\em ``as in Java''}$
Expand Down
4 changes: 4 additions & 0 deletions sources/scala/CaseClass.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ trait CaseClass extends AnyRef {
*/
def caseElement(n: Int): Any ;

/** need also, for reflection
def setCaseElement(n: Int, v: Any): unit
*/

/** for a case class A(x_0,...,x_(k-1)), returns k
*/
def caseArity: Int ;
Expand Down
10 changes: 10 additions & 0 deletions sources/scala/Predef.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ object Predef {
throw new Error("assertion failed: " + message);
}

def assume(assumption: Boolean): Unit = {
if (!assumption)
throw new Error("assumption failed");
}

def assume(assumption: Boolean, message: Any): Unit = {
if (!assumption)
throw new Error("assumption failed: " + message);
}

// views -------------------------------------------------------------

implicit def identity[a](x: a): a = x;
Expand Down
15 changes: 14 additions & 1 deletion sources/scala/concurrent/Actor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@

package scala.concurrent;

abstract class Actor extends Thread {
private val in = new MailBox;

def send(msg: in.Message) =
in.send(msg);

def receive[a](f: PartialFunction[in.Message, a]): a =
if (Thread.currentThread() == this) in.receive(f);
else error("receive called not on own process");

def receiveWithin[a](msec: long)(f: PartialFunction[in.Message, a]): a =
if (Thread.currentThread() == this) in.receiveWithin(msec)(f);
else error("receiveWithin called not on own process");
}

abstract class Actor extends Thread with MailBox;


2 changes: 1 addition & 1 deletion sources/scala/concurrent/MailBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ package scala.concurrent;


//class MailBox with Monitor with LinkedListQueueCreator {
[_trait_] abstract class MailBox extends AnyRef with ListQueueCreator {
class MailBox extends AnyRef with ListQueueCreator {

type Message = AnyRef;

Expand Down
2 changes: 1 addition & 1 deletion sources/scala/concurrent/NameServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object NameServer {
def whereis(name: Symbol): Option[Process] =
names.get(name);

def send(name: Symbol, msg: Actor#Message) =
def send(name: Symbol, msg: MailBox#Message) =
names(name).send(msg);

}
10 changes: 5 additions & 5 deletions sources/scala/concurrent/Process.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ object Process {
self.spawn_link(body);
}

def send(p: Process,msg: Actor#Message) =
def send(p: Process,msg: MailBox#Message) =
p.send(msg);
def receive[a](f: PartialFunction[Actor#Message, a]): a =
def receive[a](f: PartialFunction[MailBox#Message, a]): a =
self.receive(f);

def receiveWithin[a](msec: long)(f: PartialFunction[Actor#Message, a]): a =
def receiveWithin[a](msec: long)(f: PartialFunction[MailBox#Message, a]): a =
self.receiveWithin(msec)(f);

def self: Process = {
Expand All @@ -51,11 +51,11 @@ class Process(body: => Unit) extends Actor() {
}
}

private def signal(s: Actor#Message) = {
private def signal(s: MailBox#Message) = {
links.foreach((p:Process) => p.send(Tuple3('EXIT,this,s)));
}

def !(msg: Actor#Message) =
def !(msg: MailBox#Message) =
send(msg);

def link(p: Process) = {
Expand Down
2 changes: 1 addition & 1 deletion sources/scala/runtime/ScalaRunTime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ package scala.runtime;

object ScalaRunTime {

/** Names for primitive typesm, used by array unboxing */
/** Names for primitive types, used by array unboxing */
val ByteTag = ".Byte";
val ShortTag = ".Short";
val CharTag = ".Char";
Expand Down
29 changes: 15 additions & 14 deletions sources/scala/tools/nsc/symtab/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,25 +52,26 @@ object Flags {
// for parameters: is a val parameter

final val LABEL = 0x40000000; // symbol is a label. Set by TailCall
final val CAPTURED = 0x80000000l; // variable is accessed from nested function. Set by LambdaLift
final val CAPTURED = 0x80000000L; // variable is accessed from nested function. Set by LambdaLift

final val IS_ERROR = 0x100000000l; // symbol is an error symbol
final val OVERLOADED = 0x200000000l; // symbol is overloaded
final val LIFTED = 0x400000000l; // class has been lifted out to package level
final val IS_ERROR = 0x100000000L; // symbol is an error symbol
final val OVERLOADED = 0x200000000L; // symbol is overloaded
final val LIFTED = 0x400000000L; // class has been lifted out to package level
// local value has been lifted out to class level
final val MIXEDIN = 0x800000000l; // member has been mixed in
final val MIXEDIN = 0x800000000L; // member has been mixed in

final val EXPANDEDNAME = 0x1000000000l; // name has been expanded with class suffix
final val TRANS_FLAG = 0x2000000000l; // transient flag guaranteed to be reset after each phase.
final val INCONSTRUCTOR = TRANS_FLAG; // transient flag for analyzer
final val EXPANDEDNAME = 0x1000000000L; // name has been expanded with class suffix
final val IMPLCLASS = 0x2000000000L; // symbol is an implementation class
final val TRANS_FLAG = 0x4000000000L; // transient flag guaranteed to be reset after each phase.
final val INCONSTRUCTOR = TRANS_FLAG; // transient flag for analyzer

final val LOCKED = 0x8000000000l; // temporary flag to catch cyclic dependencies
final val LOCKED = 0x8000000000L; // temporary flag to catch cyclic dependencies

final val InitialFlags = 0x000000FFFFFFFFFFl; // flags that are enabled from phase 1.
final val LateFlags = 0x000FFF0000000000l; // flags that override flags in 0xFFF.
final val AntiFlags = 0x7FF0000000000000l; // flags that cancel flags in 0x7FF
final val LateShift = 40l;
final val AntiShift = 52l;
final val InitialFlags = 0x000000FFFFFFFFFFL; // flags that are enabled from phase 1.
final val LateFlags = 0x000FFF0000000000L; // flags that override flags in 0xFFF.
final val AntiFlags = 0x7FF0000000000000L; // flags that cancel flags in 0x7FF
final val LateShift = 40L;
final val AntiShift = 52L;

// late flags (set by a transformer phase)
final val lateDEFERRED = (DEFERRED: long) << LateShift;
Expand Down
8 changes: 3 additions & 5 deletions sources/scala/tools/nsc/symtab/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ import Flags._;
isConstructor && owner.primaryConstructor == this;

/** Is this symbol an implementation class for a trait ? */
final def isImplClass: boolean = isClass && nme.isImplClassName(name);
final def isImplClass: boolean = isClass && hasFlag(IMPLCLASS);

final def needsImplClass: boolean =
isTrait && (!hasFlag(INTERFACE) || hasFlag(lateINTERFACE)) && !isImplClass;
Expand Down Expand Up @@ -542,9 +542,7 @@ import Flags._;
final def toInterface: Symbol =
if (isImplClass) {
assert(!tpe.parents.isEmpty, this);
val iface = tpe.parents.last.symbol;
assert(nme.implClassName(iface.name) == name, this);
iface
tpe.parents.last.symbol
} else this;

/** The module corresponding to this module class (note that this
Expand Down Expand Up @@ -745,7 +743,7 @@ import Flags._;

/** String representation of symbol's definition */
final def defString: String =
compose(List(flagsToString(flags & ExplicitFlags),
compose(List(flagsToString(if (settings.debug.value) flags else flags & ExplicitFlags),
keyString,
varianceString + nameString + infoString(rawInfo)));

Expand Down
2 changes: 1 addition & 1 deletion sources/scala/tools/nsc/transform/AddInterfaces.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ abstract class AddInterfaces extends InfoTransform {
if (iface.owner.isClass) iface.owner.info.decls enter impl
}
impl setPos iface.pos;
impl.flags = iface.flags & ~(INTERFACE | lateINTERFACE);
impl.flags = iface.flags & ~(INTERFACE | lateINTERFACE) | IMPLCLASS;
impl setInfo new LazyImplClassType(iface);
implClassMap(iface) = impl;
if (settings.debug.value) log("generating impl class " + impl + " in " + iface.owner);//debug
Expand Down
20 changes: 2 additions & 18 deletions sources/scala/tools/nsc/transform/Mixin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ abstract class Mixin extends InfoTransform {
case Apply(Select(qual, _), args) =>
def staticCall(target: Symbol) = {
if (target == NoSymbol)
assert(false, "" + sym + " " + sym.owner + " " + sym.owner.implClass + " " + sym.owner.owner + atPhase(phase.prev)(sym.owner.owner.info.decls.toList));//debug
assert(false, "" + sym + " " + sym.owner + " " + implClass(sym.owner) + " " + sym.owner.owner + atPhase(phase.prev)(sym.owner.owner.info.decls.toList));//debug
localTyper.typed {
atPos(tree.pos) {
val qual1 =
Expand All @@ -341,20 +341,12 @@ abstract class Mixin extends InfoTransform {
assert(false, "illegal super in mixin class: " + currentOwner.enclClass + " " + tree);
}
if (sym.owner hasFlag lateINTERFACE)
staticCall(atPhase(phase.prev)(sym.overridingSymbol(sym.owner.implClass)))
staticCall(atPhase(phase.prev)(sym.overridingSymbol(implClass(sym.owner))))
else {
assert(!(sym.owner hasFlag INTERFACE));
assert(!currentOwner.enclClass.isImplClass);
tree
}
/*
} else {
var sym1 = sym;
if (sym.owner hasFlag lateINTERFACE)
sym1 = atPhase(phase.prev)(sym.overridingSymbol(sym.owner.implClass));
staticCall(sym1)
}
*/
case _ =>
tree
}
Expand All @@ -380,14 +372,6 @@ abstract class Mixin extends InfoTransform {
}
}
}
/*
case Ident(_) =>
if (sym.owner.isClass) {
assert(sym.isModuleVar, sym);
assert(!sym.owner.isImplClass, sym);
atPos(tree.pos) {
gen.SelectThis(
*/
case Assign(Apply(lhs @ Select(qual, _), List()), rhs) =>
localTyper.typed {
atPos(tree.pos) {
Expand Down
10 changes: 8 additions & 2 deletions sources/scala/tools/nsc/typechecker/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ abstract class RefChecks extends InfoTransform {
mvarRef))
}

// def m: T;
def newModuleAccessDcl(accessor: Symbol) =
DefDef(accessor setFlag lateDEFERRED, vparamss => EmptyTree);

class RefCheckTransformer(unit: CompilationUnit) extends Transformer {

var localTyper: analyzer.Typer = typer;
Expand Down Expand Up @@ -450,10 +454,12 @@ abstract class RefChecks extends InfoTransform {
val ddef =
atPhase(phase.next) {
localTyper.typed {
newModuleAccessDef(sym, vdef.symbol)
if (sym.owner.isTrait) newModuleAccessDcl(sym)
else newModuleAccessDef(sym, vdef.symbol)
}
}
if (sym.owner.isTrait) List(transform(cdef))

if (sym.owner.isTrait) transformTrees(List(cdef, ddef))
else transformTrees(List(cdef, vdef, ddef))
}

Expand Down
32 changes: 30 additions & 2 deletions sources/scala/tools/nsc/typechecker/SuperAccessors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,19 @@ abstract class SuperAccessors extends transform.Transform {
protected def newTransformer(unit: CompilationUnit): Transformer = new SuperAccTransformer;

class SuperAccTransformer extends Transformer {
var accDefs: List[Pair[Symbol, ListBuffer[Tree]]] = List();
private var validCurrentOwner = true;
private var accDefs: List[Pair[Symbol, ListBuffer[Tree]]] = List();

private def accDefBuf(clazz: Symbol) = accDefs.dropWhile(._1.!=(clazz)).head._2;

private def transformArgs(args: List[Tree], formals: List[Type]) = {
if (!formals.isEmpty && formals.last.symbol == definitions.ByNameParamClass)
(args take (formals.length - 1) map transform) :::
withInvalidOwner { args drop (formals.length - 1) map transform }
else
args map transform
}

override def transform(tree: Tree): Tree = tree match {
case Template(parents, body) =>
val ownAccDefs = new ListBuffer[Tree];
Expand All @@ -37,7 +46,7 @@ abstract class SuperAccessors extends transform.Transform {
case Select(sup @ Super(_, mix), name) =>
val clazz = sup.symbol;
if (tree.isTerm && mix == nme.EMPTY.toTypeName &&
(clazz.isTrait || clazz != currentOwner.enclClass)) {
(clazz.isTrait || clazz != currentOwner.enclClass || !validCurrentOwner)) {
val supername = nme.superName(tree.symbol.name);
var superAcc = clazz.info.decl(supername).suchThat(.alias.==(tree.symbol));
if (superAcc == NoSymbol) {
Expand All @@ -54,8 +63,27 @@ abstract class SuperAccessors extends transform.Transform {
Select(gen.This(clazz), superAcc) setType tree.tpe;
}
} else tree
case Apply(fn, args) =>
copy.Apply(tree, transform(fn), transformArgs(args, fn.tpe.paramTypes))
case Function(vparams, body) =>
withInvalidOwner {
copy.Function(tree, vparams, transform(body))
}
case _ =>
super.transform(tree)
}

override def atOwner[A](owner: Symbol)(trans: => A): A = {
if (owner.isClass) validCurrentOwner = true;
super.atOwner(owner)(trans)
}

private def withInvalidOwner[A](trans: => A): A = {
val prevValidCurrentOwner = validCurrentOwner;
validCurrentOwner = false;
val result = trans;
validCurrentOwner = prevValidCurrentOwner;
result
}
}
}
2 changes: 1 addition & 1 deletion support/latex/verbfilterScala.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class verbfilterScala {
"do", "else", "extends", "false", "final",
"finally", "for", "if", "import", "new",
"null", "object", "override", "package", "private",
"protected", "return", "sealed", "super", "this",
"protected", "requires", "return", "sealed", "super", "this", "throw",
"trait", "true", "try", "type", "val",
"var", "while", "with", "yield"};

Expand Down
4 changes: 2 additions & 2 deletions test-nsc/files/pos/refine.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object test {

val x: Object { def toString(): String } = new Object {
override def toString(): String = "1";
val x: Object { def t(): String } = new Object {
def t(): String = "1";
}
}

0 comments on commit b83bbad

Please sign in to comment.