summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2004-09-02 16:19:06 +0000
committerMartin Odersky <odersky@gmail.com>2004-09-02 16:19:06 +0000
commit7320ca34aad20a1c47715d265a85da7274b0eaf4 (patch)
treed463653247060d0d7d5b2139cbdada138215e554
parent5c259cbc76648b0e36e27b47e07a6066704c3f52 (diff)
downloadscala-7320ca34aad20a1c47715d265a85da7274b0eaf4.tar.gz
scala-7320ca34aad20a1c47715d265a85da7274b0eaf4.tar.bz2
scala-7320ca34aad20a1c47715d265a85da7274b0eaf4.zip
*** empty log message ***
-rw-r--r--config/list/scalac.lst1
-rw-r--r--config/list/util.lst1
-rw-r--r--doc/reference/ReferencePart.tex77
-rw-r--r--doc/reference/ReferencePartAppendix.tex8
-rw-r--r--sources/scala/Iterable.scala52
-rw-r--r--sources/scala/List.scala2
-rw-r--r--sources/scala/Stream.scala4
-rw-r--r--sources/scala/runtime/ScalaRunTime.scala10
-rw-r--r--sources/scala/tools/scala4ant/AntAdaptor.scala2
-rw-r--r--sources/scala/tools/scalac/Main.scala2
-rw-r--r--sources/scala/tools/scalac/ast/parser/Parser.scala43
-rw-r--r--sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala3
-rw-r--r--sources/scala/tools/scalac/typechecker/Analyzer.scala26
-rw-r--r--sources/scala/tools/scalac/typechecker/Context.scala9
-rw-r--r--sources/scala/tools/scalac/typechecker/DeSugarize.scala31
-rw-r--r--sources/scala/tools/scaladoc/HTMLGeneratorCommand.java2
-rw-r--r--sources/scala/tools/scaladoc/Main.scala2
-rw-r--r--sources/scala/tools/scalai/InterpreterCommand.java2
-rw-r--r--sources/scala/tools/scalai/Main.java2
-rw-r--r--sources/scala/tools/scalap/Flags.scala3
-rw-r--r--sources/scala/tools/scalap/ScalaWriter.scala4
-rw-r--r--sources/scala/tools/util/Reporter.java237
-rw-r--r--sources/scalac/CompilerCommand.java2
-rw-r--r--sources/scalac/Global.java1
-rw-r--r--sources/scalac/checkers/TreeChecker.java3
-rw-r--r--sources/scalac/symtab/Modifiers.java5
-rw-r--r--sources/scalac/symtab/Symbol.java2
-rw-r--r--sources/scalac/symtab/Type.java15
-rw-r--r--sources/scalac/transformer/ExplicitOuterClassesPhase.java1
-rw-r--r--sources/scalac/util/OptionParser.java1
-rw-r--r--test/files/pos/bug31.scala2
-rw-r--r--test/files/pos/bug76.scala2
-rw-r--r--test/files/pos/bug93.scala2
-rw-r--r--test/files/run/Course-2002-01.scala2
-rw-r--r--test/files/run/Course-2002-03.scala10
-rw-r--r--test/files/run/Course-2002-04.scala2
-rw-r--r--test/files/run/Course-2002-08.scala2
-rw-r--r--test/files/run/Course-2002-13.scala2
-rw-r--r--test/files/run/bridges.scala2
-rw-r--r--test/files/run/bugs.scala4
-rw-r--r--test/files/run/enums.scala2
-rw-r--r--test/files/run/literals.scala2
-rw-r--r--test/files/run/runtime.scala2
-rw-r--r--test/files/run/tailcalls.scala2
44 files changed, 457 insertions, 134 deletions
diff --git a/config/list/scalac.lst b/config/list/scalac.lst
index 714c792045..b0e4a44299 100644
--- a/config/list/scalac.lst
+++ b/config/list/scalac.lst
@@ -157,7 +157,6 @@
../../../scalac/util/Names.java
../../../scalac/util/OptionParser.java
../../../scalac/util/PrefixMatcher.java
-../../../scalac/util/Reporter.java
../../../scalac/util/SourceRepresentation.java
../../../scalac/util/Strings.java
../../../scalac/util/TermName.java
diff --git a/config/list/util.lst b/config/list/util.lst
index 7ee9025357..f2ed790993 100644
--- a/config/list/util.lst
+++ b/config/list/util.lst
@@ -17,6 +17,7 @@ StringBufferWriter.java
VirtualDirectory.java
VirtualFile.java
ZipArchive.java
+Reporter.java
debug/AbortError.java
debug/ArrayDebugger.java
diff --git a/doc/reference/ReferencePart.tex b/doc/reference/ReferencePart.tex
index e1728fa95a..bf038648b0 100644
--- a/doc/reference/ReferencePart.tex
+++ b/doc/reference/ReferencePart.tex
@@ -487,9 +487,8 @@ Method types associate to the right: $(\Ts_1)(\Ts_2)U$ is treated as
$(\Ts_1)((\Ts_2)U)$.
A special case are types of methods without any parameters. They are
-written here $[]T$, following the syntax for polymorphic method types
-(\sref{sec:poly-types}). Parameterless methods name expressions that
-are re-evaluated each time the parameterless method name is
+written here \lstinline@=> T@. Parameterless methods name expressions
+that are re-evaluated each time the parameterless method name is
referenced.
Method types do not exist as types of values. If a method name is used
@@ -504,7 +503,7 @@ def c (x: Int) (y: String, z: String): String
\end{lstlisting}
produce the typings
\begin{lstlisting}
-a: [] Int
+a: => Int
b: (Int) Boolean
c: (Int) (String, String) String
\end{lstlisting}
@@ -554,7 +553,7 @@ def println[a](x: a)(tostring: a => String): unit = $\ldots$
define a single function \code{println} which has an overloaded
type.
\begin{lstlisting}
-println: [] unit $\overload$
+println: => unit $\overload$
(String) unit $\overload$
(float) unit $\overload$
(float, int) unit $\overload$
@@ -850,7 +849,7 @@ method type that are used as values, rather than being applied to some
arguments.
\begin{itemize}
\item
-A parameterless method $m$ of type $[] T$
+A parameterless method $m$ of type \lstinline@=> $T$@
is converted to type $T$ by evaluating the expression to which $m$ is bound.
\item
An expression $e$ of polymorphic type
@@ -875,7 +874,7 @@ parameter section consisting of parameters with fresh names of types $\Ts_i$:
(val $x$ = $e$ ; $(ps_1) \ldots \Arrow \ldots \Arrow (ps_n) \Arrow x(ps_1)\ldots(ps_n)$)
\end{lstlisting}
This conversion is not applicable to functions with call-by-name
-parameters \lstinline@def $x$: $T$@ or repeated parameters
+parameters \lstinline@$x$: => $T$@ or repeated parameters
\lstinline@x: T*@, (\sref{sec:parameters}), because its result would
violate the well-formedness rules for anonymous functions
(\sref{sec:closures}). Hence, methods with such parameters
@@ -1384,7 +1383,7 @@ FunDef ::= FunSig {`,' FunSig} [`:' Type] `=' Expr
FunSig ::= id [FunTypeParamClause] {ParamClause}
FunTypeParamClause ::= `[' TypeParam {`,' TypeParam} `]'
ParamClause ::= `(' [Param {`,' Param}] `)'
-Param ::= [def] id `:' Type [`*']
+Param ::= id `:' [`=>'] Type [`*']
\end{lstlisting}
A function declaration has the form ~\lstinline@def $f \psig$: $T$@, where
@@ -1411,22 +1410,18 @@ value parameter name $x$ is the function body, if one is
given. Both type parameter names and value parameter names must be
pairwise distinct.
-Value parameters may be prefixed by \code{def}, e.g.\
-~\lstinline@def $x$:$T$@. The type of such a parameter is then the
-parameterless method type ~\lstinline@[]$T$@. This indicates that the
+The type of a value parameter may be prefixed by \code{=>}, e.g.\
+~\lstinline@$x$: => $T$@. The type of such a parameter is then the
+parameterless method type ~\lstinline@=> $T$@. This indicates that the
corresponding argument is not evaluated at the point of function
application, but instead is evaluated at each use within the
function. That is, the argument is evaluated using {\em call-by-name}.
\example The declaration
\begin{lstlisting}
-def whileLoop (def cond: Boolean) (def stat: Unit): Unit
+def whileLoop (cond: => Boolean) (stat: => Unit): Unit
\end{lstlisting}
-produces the typing
-\begin{lstlisting}
-whileLoop: (cond: [] Boolean) (stat: [] Unit) Unit
-\end{lstlisting}
-which indicates that both parameters of \code{while} are evaluated using
+indicates that both parameters of \code{while} are evaluated using
call-by-name.
The last value parameter of a parameter section may be suffixed by
@@ -2068,10 +2063,13 @@ definition in Java:
\section{Class Definitions}
\label{sec:classes}
-\syntax\begin{lstlisting} TmplDef ::= class ClassDef ClassDef ::=
- ClassSig {`,' ClassSig} [`:' SimpleType] ClassTemplate ClassSig ::=
- id [TypeParamClause] [ParamClause] ClassTemplate ::= extends
- Template | TemplateBody |
+\syntax\begin{lstlisting}
+ TmplDef ::= class ClassDef
+ ClassDef ::= ClassSig {`,' ClassSig} [`:' SimpleType] ClassTemplate
+ ClassSig ::= id [TypeParamClause] [ClassParamClause]
+ ClassTemplate ::= extends Template | TemplateBody |
+ ClassParamClause ::= `(' [ClassParam {`,' ClassParam}] `)'
+ ClassParam ::= [{Modifier} `val'] Param
\end{lstlisting}
The most general form of class definition is
@@ -2095,6 +2093,12 @@ part of the types of any of the parent classes or members of $t$.
It is illegal to define two formal value parameters with the same name.
The formal parameter section \lstinline@($ps\,$)@ may be omitted, in which case
an empty parameter section \lstinline@()@ is assumed.
+
+If a formal parameter declaration $x: T$ is preceded by a \code{val}
+keyword, an accessor definition for this parameter is implicitly added
+to the class. The accessor introduces a value member $x$ of $c$ that is
+defined as alias of the parameter. The formal paremter declaration may
+contain modifiers, which then carry over to the accessor definition.
\item[]
$s$ is the {\em self type} of the class. Inside the
class, the type of \code{this} is assumed to be $s$. The self
@@ -2225,6 +2229,10 @@ If a type parameter section
is missing in the class, it is also missing in the factory
definition).
+All formal value parameters of a case class are implicitly prefixed
+with a \code{val} keyword. Therefore, accessor definitions
+(\sref{sec:classes}) for such parameters are generated.
+
Also implicitly defined are accessor member definitions
in the class that return its value parameters. Every binding
$x: T$ in the parameter section leads to a value definition of
@@ -2479,6 +2487,7 @@ module FileSystem {
| [SimpleExpr `.'] id `=' Expr
| SimpleExpr ArgumentExprs `=' Expr
| PostfixExpr [`:' Type1]
+ | MethodClosure
PostfixExpr ::= InfixExpr [id]
InfixExpr ::= PrefixExpr
| InfixExpr id PrefixExpr
@@ -2494,6 +2503,7 @@ module FileSystem {
| XmlExpr
ArgumentExprs ::= `(' [Exprs] ')'
| BlockExpr
+ MethodClosure ::= `.' Id {`.' Id | TypeArgs | ArgumentExprs}
BlockExpr ::= `{' CaseClause {CaseClause} `}'
| `{' Block `}'
Block ::= {BlockStat `;'} [ResultExpr]
@@ -2718,8 +2728,8 @@ with actual arguments substituted for formal parameters. The result
of evaluating the rewritten right-hand side is finally converted to
the function's declared result type, if one is given.
-The case of a formal \code{def}-parameter with a parameterless
-method type \lstinline@[]$T$@ is treated specially. In this case, the
+The case of a formal parameter with a parameterless
+method type \lstinline@=> $T$@ is treated specially. In this case, the
corresponding actual argument expression is not evaluated before the
application. Instead, every use of the formal parameter on the
right-hand side of the rewrite rule entails a re-evaluation of the
@@ -3031,6 +3041,27 @@ the expression is the value of $e$ converted to type $T$.
// 1: string // illegal
\end{lstlisting}
+\section{Method closures}
+\syntax\begin{lstlisting}
+ MethodClosure ::= `.' Id {`.' Id | TypeArgs | ArgumentExprs}
+\end{lstlisting}
+
+A method closure $.id$ starts with a period and an identifier, which
+may be followed by selections and type- and value-arguments. This
+expression is equivalenet to an anonymous function
+\lstinline@$x$ => $x.id$@ where $x$ is a fresh parameter name. No type
+for $x$ is given; hence this type needs to be inferrable from the
+context of the expression.
+
+\example The following method returns the $n$'th column of a given
+list of row-lists $xss$, using methods \lstlistinline@map@,
+\lstlistinline@drop@ and \lstlistinline@head@ defined in class
+\lstlinline@scala.List@.
+\begin{lstlisting}
+def column[T](xss: List[List[T]], n: int): List[T] =
+ xss.map(.drop(i)).map(.head)
+\end{lstlisting}
+
\section{Assignments}
\syntax\begin{lstlisting}
diff --git a/doc/reference/ReferencePartAppendix.tex b/doc/reference/ReferencePartAppendix.tex
index a7a100699d..f5f6a74c78 100644
--- a/doc/reference/ReferencePartAppendix.tex
+++ b/doc/reference/ReferencePartAppendix.tex
@@ -76,6 +76,7 @@ grammar.
| [SimpleExpr `.'] id `=' Expr
| SimpleExpr ArgumentExprs `=' Expr
| PostfixExpr [`:' Type1]
+ | MethodClosure
PostfixExpr ::= InfixExpr [id]
InfixExpr ::= PrefixExpr
| InfixExpr id PrefixExpr
@@ -89,8 +90,9 @@ grammar.
| SimpleExpr TypeArgs
| SimpleExpr ArgumentExprs
| XmlExpr
- ArgumentExprs ::= `(' [Exprs] ')'
+ ArgumentExprs ::= `(' [Exprs] ')'
| BlockExpr
+ MethodClosure ::= `.' Id {`.' Id | TypeArgs | ArgumentExprs}
BlockExpr ::= `{' CaseClause {CaseClause} `}'
| `{' Block `}'
Block ::= {BlockStat `;'} [ResultExpr]
@@ -132,7 +134,9 @@ grammar.
VarTypeParam ::= [`+' | `-'] TypeParam
TypeParam ::= id [>: Type] [<: Type | <% Type]
ParamClause ::= `(' [Param {`,' Param}] `)'
- Param ::= [def] id `:' Type [`*']
+ ClassParamClause::= `(' [ClassParam {`,' ClassParam}] `)'
+ Param ::= id `:' [`=>' Type [`*']
+ ClassParam ::= [{Modifier} `val'] Param
Bindings ::= id [`:' Type1]
| `(' Binding {`,' Binding `)'
Binding ::= id [`:' Type]
diff --git a/sources/scala/Iterable.scala b/sources/scala/Iterable.scala
index 84e7a9daa8..0be6cfa000 100644
--- a/sources/scala/Iterable.scala
+++ b/sources/scala/Iterable.scala
@@ -11,22 +11,46 @@ package scala;
object Iterable {
- def view[A <% Ordered[A]](x: Iterable[A]): Ordered[Iterable[A]] = new Ordered[Iterable[A]] {
- def compareTo[B >: Iterable[A] <% Ordered[B]](that: B): Int = that match {
- case y: Iterable[A] =>
- val xs = x.elements;
- val ys = y.elements;
- var res = 0;
- while (xs.hasNext && ys.hasNext && (res == 0)) {
- res = xs.next compareTo ys.next;
- }
- if (xs.hasNext) 1
- else if (ys.hasNext) -1
- else res;
- case _ =>
- -(that compareTo x)
+ def view[A <% Ordered[A]](x: Iterable[A]): Ordered[Iterable[A]] = new Ordered[Iterable[A]] {
+ def compareTo[B >: Iterable[A] <% Ordered[B]](that: B): Int = that match {
+ case y: Iterable[A] =>
+ val xs = x.elements;
+ val ys = y.elements;
+ var res = 0;
+ while (xs.hasNext && ys.hasNext && (res == 0)) {
+ res = xs.next compareTo ys.next;
}
+ if (xs.hasNext) 1
+ else if (ys.hasNext) -1
+ else res;
+ case _ =>
+ -(that compareTo x)
}
+ }
+
+ /** The minimum element of a non-empty sequence of ordered elements */
+ def min[A <% Ordered[A]](seq: Iterable[A]): A = {
+ val xs = seq.elements;
+ if (!xs.hasNext) throw new Error("min(<empty>)");
+ var min = xs.next;
+ while (xs.hasNext) {
+ val x = xs.next;
+ if (x < min) min = x;
+ }
+ min
+ }
+
+ /** The maximum element of a non-empty sequence of ordered elements */
+ def max[A <% Ordered[A]](seq: Iterable[A]): A = {
+ val xs = seq.elements;
+ if (!xs.hasNext) throw new Error("max(<empty>)");
+ var max = xs.next;
+ while (xs.hasNext) {
+ val x = xs.next;
+ if (max < x) max = x;
+ }
+ max
+ }
}
/** Collection classes supporting this trait provide a method
diff --git a/sources/scala/List.scala b/sources/scala/List.scala
index d66728f97e..57752bcafd 100644
--- a/sources/scala/List.scala
+++ b/sources/scala/List.scala
@@ -137,8 +137,6 @@ object List {
res
}
-
-
/** Parses a string which contains substrings separated by a
*
* separator character and returns a list of all substrings.
diff --git a/sources/scala/Stream.scala b/sources/scala/Stream.scala
index b6eea6c64b..444b4aae3a 100644
--- a/sources/scala/Stream.scala
+++ b/sources/scala/Stream.scala
@@ -25,7 +25,7 @@ object Stream {
def printElems(buf: StringBuffer, prefix: String): StringBuffer = buf;
}
- def cons[a](hd: a, def tl: Stream[a]) = new Stream[a] {
+ def cons[a](hd: a, def/*!!!*/ tl: Stream[a]) = new Stream[a] {
def isEmpty = false;
def head = hd;
private var tlVal: Stream[a] = _;
@@ -126,7 +126,7 @@ trait Stream[+a] extends Seq[a] {
def length: int = if (isEmpty) 0 else tail.length + 1;
- def append[b >: a](def rest: Stream[b]): Stream[b] =
+ def append[b >: a](def/*!!!*/ rest: Stream[b]): Stream[b] =
if (isEmpty) rest
else Stream.cons(head, tail.append(rest));
diff --git a/sources/scala/runtime/ScalaRunTime.scala b/sources/scala/runtime/ScalaRunTime.scala
index 8dd8a2ca1e..adb14a1fee 100644
--- a/sources/scala/runtime/ScalaRunTime.scala
+++ b/sources/scala/runtime/ScalaRunTime.scala
@@ -15,19 +15,19 @@ object ScalaRunTime {
if (r.exc == null) r.result.asInstanceOf[a] else throw r.exc;
}
- def Try[a](def block: a): Try[a] =
+ def Try[a](def/*!!!*/ block: a): Try[a] =
new Try(ResultOrException.tryBlock(block));
- def While(def cond: Boolean)(def body: Unit): Unit =
+ def While(def/*!!!*/ cond: Boolean)(def/*!!!*/ body: Unit): Unit =
NativeLoop.loopWhile(cond, body);
trait DoWhile {
- def While(def condition: Boolean): Unit;
+ def While(def/*!!!*/ condition: Boolean): Unit;
}
- def Do(def command: Unit): DoWhile =
+ def Do(def/*!!!*/ command: Unit): DoWhile =
new DoWhile {
- def While(def condition: Boolean): Unit = {
+ def While(def/*!!!*/ condition: Boolean): Unit = {
command;
NativeLoop.loopWhile(condition, command);
}
diff --git a/sources/scala/tools/scala4ant/AntAdaptor.scala b/sources/scala/tools/scala4ant/AntAdaptor.scala
index 19fab5d32d..b61816da0a 100644
--- a/sources/scala/tools/scala4ant/AntAdaptor.scala
+++ b/sources/scala/tools/scala4ant/AntAdaptor.scala
@@ -1,6 +1,6 @@
import scalac._;
-import scalac.util.Reporter;
+import scala.tools.util.Reporter;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
diff --git a/sources/scala/tools/scalac/Main.scala b/sources/scala/tools/scalac/Main.scala
index 8b637c408e..3b1821fbcb 100644
--- a/sources/scala/tools/scalac/Main.scala
+++ b/sources/scala/tools/scalac/Main.scala
@@ -6,7 +6,7 @@
** $Id$
\* */
-import scalac.util.Reporter;
+import scala.tools.util.Reporter;
import scalac.{CompilerCommand, Global => scalac_Global};
import scalac.symtab.classfile.CLRPackageParser;
diff --git a/sources/scala/tools/scalac/ast/parser/Parser.scala b/sources/scala/tools/scalac/ast/parser/Parser.scala
index b5edbcef5b..d606e7d527 100644
--- a/sources/scala/tools/scalac/ast/parser/Parser.scala
+++ b/sources/scala/tools/scalac/ast/parser/Parser.scala
@@ -1462,27 +1462,28 @@ class Parser(unit: CompilationUnit) {
def paramClauses(): Array[Array[Tree$ValDef]] = {
val ts = new ArrayList();
while (s.token == LPAREN)
- ts.add(paramClause());
+ ts.add(paramClause(false));
ts.toArray(new Array[Array[Tree$ValDef]](ts.size()).asInstanceOf[Array[java.lang.Object]])
.asInstanceOf[Array[Array[Tree$ValDef]]]
}
/** ParamClauseOpt ::= [ParamClause]
*/
- def paramClauseOpt(): Array[Array[Tree$ValDef]] =
- if (s.token == LPAREN) NewArray.ValDefArray(paramClause())
+ def paramClauseOpt(ofPrimaryConstructor: boolean): Array[Array[Tree$ValDef]] =
+ if (s.token == LPAREN) NewArray.ValDefArray(paramClause(ofPrimaryConstructor))
else Tree.ValDef_EMPTY_ARRAY_ARRAY;
/** ParamClause ::= `(' [Param {`,' Param}] `)'
- */
- def paramClause(): Array[Tree$ValDef] = {
+ * ClassParamClause ::= `(' [ClassParam {`,' ClassParam}] `)'
+ */
+ def paramClause(ofPrimaryConstructor: boolean): Array[Tree$ValDef] = {
val pos = accept(LPAREN);
val params = new myTreeList();
if (s.token != RPAREN) {
- params.append(param());
+ params.append(param(ofPrimaryConstructor));
while (s.token == COMMA) {
s.nextToken();
- params.append(param());
+ params.append(param(ofPrimaryConstructor));
}
}
accept(RPAREN);
@@ -1490,17 +1491,31 @@ class Parser(unit: CompilationUnit) {
.asInstanceOf[Array[Tree$ValDef]]
}
- /** Param ::= [def] Id `:' Type [`*']
- */
- def param(): Tree$ValDef = {
+ /** Param ::= Id `:' [`=>'] Type [`*']
+ * ClassParam ::= [[modifiers] val] Param
+ */
+ def param(ofPrimaryConstructor: boolean): Tree$ValDef = {
val pos = s.pos;
- var mods = Modifiers.PARAM;
+ var mods = if (ofPrimaryConstructor) modifiers() | Modifiers.PARAM else Modifiers.PARAM;
+ if (s.token == VAL) {
+ s.nextToken(); mods = mods | Modifiers.PARAMACCESSOR;
+ } else if (mods != Modifiers.PARAM) {
+ accept(VAL);
+ }
if (s.token == DEF) {
mods = mods | Modifiers.DEF;
+ /* notyet
+ s.unit.warning(s.pos, "def-parameter syntax `def x: T' is deprecated \n" +
+ "use `x: => T' instead");
+ */
s.nextToken();
}
val name = ident();
accept(COLON);
+ if (s.token == ARROW) {
+ mods = mods | Modifiers.DEF;
+ s.nextToken();
+ }
var tp = typ();
if (s.token == IDENTIFIER && s.name == STAR) {
s.nextToken();
@@ -1793,7 +1808,7 @@ class Parser(unit: CompilationUnit) {
if (s.token == THIS) {
val pos = s.pos;
s.nextToken();
- val vparams = NewArray.ValDefArray(paramClause());
+ val vparams = NewArray.ValDefArray(paramClause(false));
accept(EQUALS);
ts.append(
make.DefDef(
@@ -1878,7 +1893,7 @@ class Parser(unit: CompilationUnit) {
}
}
- /** ClassDef ::= Id [TypeParamClause] [ParamClause] [`:' SimpleType] ClassTemplate
+ /** ClassDef ::= Id [TypeParamClause] [ClassParamClause] [`:' SimpleType] ClassTemplate
*/
def classDef(mods: int): Array[Tree] = {
val lhs = new ListBuffer[Tuple4[Int, Name, Array[Tree$AbsTypeDef], Array[Array[Tree$ValDef]]]];
@@ -1887,7 +1902,7 @@ class Parser(unit: CompilationUnit) {
lhs.append(Tuple4(s.pos,
ident().toTypeName(),
typeParamClauseOpt(true),
- paramClauseOpt()));
+ paramClauseOpt(true)));
} while (s.token == COMMA);
val thistpe = simpleTypedOpt();
val template = classTemplate( (mods & Modifiers.CASE)!= 0 );
diff --git a/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala b/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala
index 0c93b00f4e..09acf7870b 100644
--- a/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala
+++ b/sources/scala/tools/scalac/ast/printer/TextTreePrinter.scala
@@ -710,6 +710,9 @@ class TextTreePrinter(writer: PrintWriter) with TreePrinter {
case Tree$ValDef(mods, name, tpe, Tree.Empty) =>
printModifiers(mods);
+ if ((mods & Modifiers.PARAMACCESSOR) != 0) {
+ print(KW_VAL); print(Space);
+ }
printSymbolDefinition(tree.symbol(), name);
printOpt(TXT_COLON, tpe, false);
diff --git a/sources/scala/tools/scalac/typechecker/Analyzer.scala b/sources/scala/tools/scalac/typechecker/Analyzer.scala
index 9a2b60055b..203e7aa7f0 100644
--- a/sources/scala/tools/scalac/typechecker/Analyzer.scala
+++ b/sources/scala/tools/scalac/typechecker/Analyzer.scala
@@ -1110,8 +1110,8 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
vparamSyms1(1) = Symbol.EMPTY_ARRAY;
vparamSyms = vparamSyms1
}
- if ((mods & CASE) != 0 && vparams.length > 0)
- templ.body = desugarize.addCaseElements(
+ if (vparams.length > 0)
+ templ.body = desugarize.addParamAccessors(
templ.body, vparams(vparams.length - 1));
val constrtype: Type = makeMethodType(
@@ -1162,8 +1162,12 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
restype = context.enclClass.owner.getType();/*.subst(
context.enclClass.owner.typeParams(), tparamSyms)*/;
} else {
- rhs = transform(rhs, EXPRmode);
- (tree.asInstanceOf[Tree$DefDef]).rhs = rhs;
+ if ((sym.flags & PARAMACCESSOR) != 0) {
+ rhs.setType(rhs.symbol().getType());
+ } else {
+ rhs = transform(rhs, EXPRmode);
+ (tree.asInstanceOf[Tree$DefDef]).rhs = rhs;
+ }
restype = rhs.getType();
if (!sym.isFinal()) restype = restype.deconst();
}
@@ -1198,12 +1202,8 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
owntype = Type.ErrorType;
}
} else {
- if ((sym.flags & CASEACCESSOR) != 0) {
- rhs.setType(rhs.symbol().getType());
- } else {
- rhs = transform(rhs, EXPRmode);
- (tree.asInstanceOf[Tree$ValDef]).rhs = rhs;
- }
+ rhs = transform(rhs, EXPRmode);
+ (tree.asInstanceOf[Tree$ValDef]).rhs = rhs;
owntype = rhs.getType();
if (sym.isVariable() || !sym.isFinal())
owntype = owntype.deconst();
@@ -1651,7 +1651,7 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
} else {
nextcontext = nextcontext.enclClass;
if (nextcontext != Context.NONE) {
- sym = nextcontext.owner.thisSym().info().lookup(name);
+ sym = nextcontext.owner.typeOfThis().lookup(name);
if (sym.kind != NONE) {
stopPos = nextcontext.owner.pos;
} else {
@@ -2239,8 +2239,8 @@ class Analyzer(global: scalac_Global, descr: AnalyzerPhase) extends Transformer(
val vparams1 = transform(vparams);
checkNoEscapeParams(vparams1);
val tpe1: Tree = transform(tpe, TYPEmode);
- if ((sym.flags & CASE) != 0 && vparams.length > 0 && templ.getType() == null)
- templ.body = desugarize.addCaseElements(
+ if (vparams.length > 0 && templ.getType() == null)
+ templ.body = desugarize.addParamAccessors(
templ.body, vparams(vparams.length - 1));
val templ1: Tree$Template = transformTemplate(templ, sym);
diff --git a/sources/scala/tools/scalac/typechecker/Context.scala b/sources/scala/tools/scalac/typechecker/Context.scala
index 81cf9a28c9..ceedc3c2e0 100644
--- a/sources/scala/tools/scalac/typechecker/Context.scala
+++ b/sources/scala/tools/scalac/typechecker/Context.scala
@@ -9,6 +9,7 @@ import scalac.symtab._;
import scalac.ast._;
import scalac.util.Names;
import scalac.util.Name;
+import scalac.{Global => scalac_Global}
package scala.tools.scalac.typechecker {
@@ -122,7 +123,13 @@ class Context {
if (viewCache == null) {
viewCache = outer.viewMeths;
- if (scope != outer.scope) {
+ if (enclClass == this) {
+ val sym = owner.typeOfThis().lookup(Names.view);
+ if (sym.kind == VAL) {
+ addView(sym, owner.thisType().memberType(sym),
+ scalac_Global.instance.treeGen.This(owner.pos, owner));
+ }
+ } else if (scope != outer.scope) {
val e = scope.lookupEntry(Names.view);
if (e.owner == scope && e.sym.kind == VAL)
addView(e.sym, e.sym.getType(), Tree.Empty);
diff --git a/sources/scala/tools/scalac/typechecker/DeSugarize.scala b/sources/scala/tools/scalac/typechecker/DeSugarize.scala
index 99ec52fb2b..41db26e4b1 100644
--- a/sources/scala/tools/scalac/typechecker/DeSugarize.scala
+++ b/sources/scala/tools/scalac/typechecker/DeSugarize.scala
@@ -422,7 +422,7 @@ class DeSugarize(make: TreeFactory, copy: TreeCopier, gen: TreeGen, infer: scala
case Tree$ValDef(mods, name, tpe, rhs) =>
val valname: Name = Name.fromString("" + name + "$");
val valdef1: Tree = copy.ValDef(
- tree, (mods & (DEFERRED | MUTABLE | CASEACCESSOR | MODUL)) | PRIVATE,
+ tree, (mods & (DEFERRED | MUTABLE | PARAMACCESSOR | MODUL)) | PRIVATE,
valname, tpe, rhs).setType(null);
var mods1: int = mods | ACCESSOR;
if ((mods1 & MUTABLE) == 0) mods1 = mods1 | STABLE;
@@ -600,24 +600,31 @@ class DeSugarize(make: TreeFactory, copy: TreeCopier, gen: TreeGen, infer: scala
/** Build value element definition name for case parameter.
*/
- def addCaseElement(ts: TreeList, vparam: Tree$ValDef): unit = {
- //vparam.symbol().initialize();
- ts.append(
- make.ValDef(
- vparam.pos, CASEACCESSOR, vparam.name, Tree.Empty,
- make.Ident(vparam.pos, vparam.name)
- .setSymbol(vparam.symbol())));
+ def addParamAccessor(ts: TreeList, vparam: Tree$ValDef): unit = {
+ if ((vparam.symbol().owner().constructorClass().flags & CASE) != 0)
+ vparam.mods = vparam.mods | PARAMACCESSOR;
+ if ((vparam.mods & PARAMACCESSOR) != 0)
+ ts.append(
+ make.DefDef(
+ vparam.pos, (vparam.mods & ~PARAM) | STABLE, vparam.name,
+ Tree.AbsTypeDef_EMPTY_ARRAY, Tree.ValDef_EMPTY_ARRAY_ARRAY,
+ Tree.Empty,
+ make.Ident(vparam.pos, vparam.name)
+ .setSymbol(vparam.symbol())))
}
/** add case constructor, definitions value and access functions.
*/
- def addCaseElements(body: Array[Tree], vparams: Array[Tree$ValDef]): Array[Tree] = {
+ def addParamAccessors(body: Array[Tree], vparams: Array[Tree$ValDef]): Array[Tree] = {
val stats: TreeList = new TreeList();
for (val i <- Iterator.range(0, vparams.length)) {
- addCaseElement(stats, vparams(i));
+ addParamAccessor(stats, vparams(i));
+ }
+ if (stats.length() == 0) body
+ else {
+ stats.append(body);
+ stats.toArray()
}
- stats.append(body);
- stats.toArray();
}
//debug
diff --git a/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java b/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java
index dfdc81d18c..bdf6b672da 100644
--- a/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java
+++ b/sources/scala/tools/scaladoc/HTMLGeneratorCommand.java
@@ -15,11 +15,11 @@ import ch.epfl.lamp.util.HTMLPrinter;
import ch.epfl.lamp.util.HTMLRepresentation;
import scala.tools.util.ClassPath;
+import scala.tools.util.Reporter;
import scalac.CompilerCommand;
import scalac.util.BooleanOptionParser;
import scalac.util.OptionParser;
-import scalac.util.Reporter;
import scalac.util.StringOptionParser;
import scalac.util.ScalaProgramArgumentParser;
import scalac.util.Strings;
diff --git a/sources/scala/tools/scaladoc/Main.scala b/sources/scala/tools/scaladoc/Main.scala
index 2b9a0f3d47..763fa8002c 100644
--- a/sources/scala/tools/scaladoc/Main.scala
+++ b/sources/scala/tools/scaladoc/Main.scala
@@ -7,7 +7,7 @@
// $Id$
import scala.tools.scalac.Global;
-import scalac.util.Reporter;
+import scala.tools.util.Reporter;
package scala.tools.scaladoc {
diff --git a/sources/scala/tools/scalai/InterpreterCommand.java b/sources/scala/tools/scalai/InterpreterCommand.java
index d89378da82..9e8907a499 100644
--- a/sources/scala/tools/scalai/InterpreterCommand.java
+++ b/sources/scala/tools/scalai/InterpreterCommand.java
@@ -11,7 +11,7 @@ package scala.tools.scalai;
import scalac.CompilerPhases;
import scalac.CompilerCommand;
-import scalac.util.Reporter;
+import scala.tools.util.Reporter;
import scalac.util.StringOptionParser;
import scalac.util.BooleanOptionParser;
import scalac.util.ScalaProgramArgumentParser;
diff --git a/sources/scala/tools/scalai/Main.java b/sources/scala/tools/scalai/Main.java
index be19e26be6..b2dc69827c 100644
--- a/sources/scala/tools/scalai/Main.java
+++ b/sources/scala/tools/scalai/Main.java
@@ -10,7 +10,7 @@
package scala.tools.scalai;
import scala.tools.scalac.CompilerPhases$class;
-import scalac.util.Reporter;
+import scala.tools.util.Reporter;
public class Main {
diff --git a/sources/scala/tools/scalap/Flags.scala b/sources/scala/tools/scalap/Flags.scala
index 6956bb3667..7d5a2fd48f 100644
--- a/sources/scala/tools/scalap/Flags.scala
+++ b/sources/scala/tools/scalap/Flags.scala
@@ -38,7 +38,8 @@ object Flags {
final val PARAM = 0x00008000; // a (type) parameter of a method
final val PACKAGE = 0x00100000; // a java package
- final val CASEACCESSOR = 0x02000000; // a case constructor
+ final val PARAMACCESSOR= 0x02000000; // for methods: is an access method for a val parameter
+ // for parameters: is a val parameter
final val ACCESSOR = 0x04000000; // an access function for a value/variable
final val BRIDGE = 0x08000000; // a bridge method.
diff --git a/sources/scala/tools/scalap/ScalaWriter.scala b/sources/scala/tools/scalap/ScalaWriter.scala
index 014a6e2d87..5ff8ea6277 100644
--- a/sources/scala/tools/scalap/ScalaWriter.scala
+++ b/sources/scala/tools/scalap/ScalaWriter.scala
@@ -89,7 +89,7 @@ class ScalaWriter(args: Arguments, writer: Writer) extends CodeWriter(writer) {
sym => { sym match {
case s: ValSymbol if
(s.tpe.isInstanceOf[OverloadedType] ||
- (Flags.is(Flags.CASEACCESSOR, s.flags) &&
+ (Flags.is(Flags.PARAMACCESSOR, s.flags) &&
!s.tpe.isInstanceOf[PolyType])) =>
case _ =>
if (!ignoreDef(sym)) {
@@ -292,7 +292,7 @@ class ScalaWriter(args: Arguments, writer: Writer) extends CodeWriter(writer) {
(Flags.is(Flags.PRIVATE, s.flags) &&
!((args != null) && (args contains "-private"))) ||
(s.name == "<init>") ||
- Flags.is(Flags.CASEACCESSOR, s.flags) ||
+ Flags.is(Flags.PARAMACCESSOR, s.flags) ||
(Flags.is(Flags.CASE, s.flags) &&
(s match {
case sym: ValSymbol => true
diff --git a/sources/scala/tools/util/Reporter.java b/sources/scala/tools/util/Reporter.java
new file mode 100644
index 0000000000..4fef766fe9
--- /dev/null
+++ b/sources/scala/tools/util/Reporter.java
@@ -0,0 +1,237 @@
+/* ____ ____ ____ ____ ______ *\
+** / __// __ \/ __// __ \/ ____/ SOcos COmpiles Scala **
+** __\_ \/ /_/ / /__/ /_/ /\_ \ (c) 2002, LAMP/EPFL **
+** /_____/\____/\___/\____/____/ **
+\* */
+
+// $Id$
+
+package scala.tools.util;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.HashSet;
+
+import scala.tools.util.Position;
+
+public class Reporter {
+
+ //########################################################################
+ // Private Fields
+
+ /** The reader to ask for failures on demand */
+ private final BufferedReader reader;
+ /** The writer to print messages */
+ private final PrintWriter writer;
+
+ /** Log of error positions (used to avoid printing errors twice) */
+ private final HashSet positions;
+
+ /** Number of errors issued totally */
+ private int errors;
+ /** Number of warning issued totally */
+ private int warnings;
+
+ //########################################################################
+ // Public Fields
+
+ /** Whether warnings should be issued */
+ public boolean nowarn;
+ /** Whether information messages should be issued */
+ public boolean verbose;
+ /** Whether a prompt should be displayed after errors and warnings */
+ public boolean prompt;
+ /** Whether a short file name should be displayed before errors */
+ public boolean shortname;
+
+ //########################################################################
+ // Public Constructors
+
+ /** Initializes a new instance. */
+ public Reporter() {
+ this(
+ new BufferedReader(new InputStreamReader(System.in)),
+ new PrintWriter(System.err, true));
+ }
+
+ /** Initializes a new instance. */
+ public Reporter(BufferedReader reader, PrintWriter writer) {
+ this.reader = reader;
+ this.writer = writer;
+ this.positions = new HashSet();
+ this.prompt = false;
+ this.nowarn = false;
+ this.verbose = false;
+ this.errors = 0;
+ }
+
+ //########################################################################
+ // Public Methods - Count
+
+ /** Returns the number of errors issued totally */
+ public int errors() {
+ return errors;
+ }
+
+ /** Returns the number of warnings issued totally */
+ public int warnings() {
+ return warnings;
+ }
+
+ /** Returns the number of errors issued totally as a string */
+ public String getErrorCountString() {
+ return getCountString(errors, "error");
+ }
+
+ /** Returns the number of warnings issued totally as a string */
+ public String getWarningCountString() {
+ return getCountString(warnings, "warning");
+ }
+
+ /** Returns a string meaning "n elements". */
+ public String getCountString(int n, String elements) {
+ switch (n) {
+ case 0: return "no " + elements + "s";
+ case 1: return "one " + elements;
+ case 2: return "two " + elements + "s";
+ case 3: return "three " + elements + "s";
+ case 4: return "four " + elements + "s";
+ default: return n + " " + elements + "s";
+ }
+ }
+
+ /** Resets all counters */
+ public void resetCounters() {
+ errors = 0;
+ warnings = 0;
+ }
+
+ //########################################################################
+ // Public Methods - Report
+
+ /** Issues a message */
+ public void report(String message) {
+ printMessage(message);
+ }
+
+ /** Issues a message */
+ public void inform(String message) {
+ if (verbose) printMessage(message);
+ }
+
+ /** Issues an error */
+ public void error(Position position, String message) {
+ boolean hidden = testAndLog(position);
+ if (!hidden || prompt) printError(position, message);
+ if (!hidden) errors++;
+ if (prompt) failOnDemand();
+ }
+
+ /** Issues a warning */
+ public void warning(Position position, String message) {
+ boolean hidden = testAndLog(position);
+ if (nowarn) return;
+ if (!hidden || prompt) printWarning(position, message);
+ if (!hidden) warnings++;
+ if (prompt) failOnDemand();
+ }
+
+ //########################################################################
+ // Public Methods - Print
+
+ /** Prints the message. */
+ public void printMessage(String message) {
+ writer.println(message);
+ }
+
+ /** Prints the message with the given position indication. */
+ public void printMessage(Position position, String message) {
+ if (position != null) {
+ message = " " + message;
+ if (position.getLineNumber() != 0)
+ message = position.getLineNumber() + ":" + message;
+ if (shortname)
+ message = position.getName() + ":" + message;
+ else
+ message = position.getPath() + ":" + message;
+ }
+ printMessage(message);
+ printSourceLine(position);
+ }
+
+ /** Prints the error message. */
+ public void printError(Position position, String message) {
+ if (position == null) message = "error: " + message;
+ printMessage(position, message);
+ }
+
+ /** Prints the warning message. */
+ public void printWarning(Position position, String message) {
+ message = "warning: " + message;
+ printMessage(position, message);
+ }
+
+ /** Prints the number of errors and warnings if their are non-zero. */
+ public void printSummary() {
+ if (errors() > 0) report(getErrorCountString() + " found");
+ if (warnings() > 0) report(getWarningCountString() + " found");
+ }
+
+ /** Prints the source line of the given position. */
+ public void printSourceLine(Position position) {
+ String line = position == null ? null : position.getLineContent();
+ if (line == null) return;
+ printMessage(line);
+ printColumnMarker(position);
+ }
+
+ /** Prints the column marker of the given position. */
+ public void printColumnMarker(Position position) {
+ int column = position == null ? 0 : position.getColumnNumber();
+ StringBuffer buffer = new StringBuffer(column);
+ for (int i = 1; i < column; i++) buffer.append(' ');
+ if (column > 0) buffer.append('^');
+ printMessage(buffer.toString());
+ }
+
+ //########################################################################
+ // Public Methods - Fail on demand
+
+ /** Fails only if requested. */
+ public void failOnDemand() {
+ failOnDemand("user abort");
+ }
+
+ /** Fails only if requested. */
+ public void failOnDemand(String message) {
+ try {
+ while (true) {
+ writer.print("r)esume, a)bort: ");
+ writer.flush();
+ String line = reader.readLine();
+ if (line == null) continue; else line = line.toLowerCase();
+ if ("abort".startsWith(line))
+ throw new Error(message);
+ if ("resume".startsWith(line)) return;
+ }
+ } catch (IOException e) {
+ throw new Error("input read error");
+ }
+ }
+
+ //########################################################################
+ // Private Methods
+
+ /** Logs a position and returns true if it was already logged. */
+ private boolean testAndLog(Position position) {
+ if (position == null) return false;
+ if (position.getColumnNumber() == 0) return false;
+ if (positions.contains(position)) return true;
+ positions.add(position);
+ return false;
+ }
+
+ //########################################################################
+}
diff --git a/sources/scalac/CompilerCommand.java b/sources/scalac/CompilerCommand.java
index dd3505b6be..a5178ee50d 100644
--- a/sources/scalac/CompilerCommand.java
+++ b/sources/scalac/CompilerCommand.java
@@ -13,8 +13,8 @@ import java.util.ArrayList;
import java.util.List;
import scala.tools.util.ClassPath;
+import scala.tools.util.Reporter;
-import scalac.util.Reporter;
import scalac.util.CommandParser;
import scalac.util.ArgumentParser;
import scalac.util.OptionParser;
diff --git a/sources/scalac/Global.java b/sources/scalac/Global.java
index 66d8d76506..fe4f528015 100644
--- a/sources/scalac/Global.java
+++ b/sources/scalac/Global.java
@@ -27,6 +27,7 @@ import scala.tools.util.ClassPath;
import scala.tools.util.Position;
import scala.tools.util.SourceFile;
import scala.tools.util.SourceReader;
+import scala.tools.util.Reporter;
import scalac.ast.*;
import scalac.ast.parser.*;
diff --git a/sources/scalac/checkers/TreeChecker.java b/sources/scalac/checkers/TreeChecker.java
index bc38e3eafb..b52d6c657c 100644
--- a/sources/scalac/checkers/TreeChecker.java
+++ b/sources/scalac/checkers/TreeChecker.java
@@ -393,7 +393,8 @@ public class TreeChecker {
assert symbol != null && symbol.isTerm(): show(tree);
Symbol owner = symbol.owner();
assert owner.isClass() && !owner.isStaticOwner(): show(tree);
- assert qualifier.type().baseType(owner) != Type.NoType: show(tree);
+ assert qualifier.type().baseType(owner) != Type.NoType:
+ show(tree) + "#" + qualifier.type() + "/" + owner;
return expression(qualifier, qualifier.type());
default:
diff --git a/sources/scalac/symtab/Modifiers.java b/sources/scalac/symtab/Modifiers.java
index 7a79680bd6..952736083f 100644
--- a/sources/scalac/symtab/Modifiers.java
+++ b/sources/scalac/symtab/Modifiers.java
@@ -46,7 +46,8 @@ public interface Modifiers {
int CAPTURED = 0x01000000; // variables is accessed from
// nested function. Set by LambdaLift
int INCONSTRUCTOR = 0x01000000; // transient flag for Analyzer
- int CASEACCESSOR = 0x02000000; // function is a case constructor
+ int PARAMACCESSOR = 0x02000000; // for methods: is an access method for a val parameter
+ // for parameters: is a val parameter
int ACCESSOR = 0x04000000; // function is an access function for a
// value or variable
@@ -102,7 +103,7 @@ public interface Modifiers {
}
public static boolean isCaseAccessor(int flags) {
- return (flags & CASEACCESSOR) != 0;
+ return (flags & PARAMACCESSOR) != 0;
}
public static boolean isInterface(int flags) {
diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java
index 5325107000..63206f4044 100644
--- a/sources/scalac/symtab/Symbol.java
+++ b/sources/scalac/symtab/Symbol.java
@@ -2124,7 +2124,7 @@ public class ClassSymbol extends TypeSymbol {
for (int i = 0; i <= index; i++) {
do {
sym = it.next();
- } while (sym != NONE && sym.kind != VAL || (sym.flags & CASEACCESSOR) == 0 || !sym.isMethod());
+ } while (sym != NONE && sym.kind != VAL || (sym.flags & PARAMACCESSOR) == 0 || !sym.isMethod());
}
//System.out.println(this + ", case field[" + index + "] = " + sym);//DEBUG
} else {
diff --git a/sources/scalac/symtab/Type.java b/sources/scalac/symtab/Type.java
index 5901fc75fa..ff3e25e84f 100644
--- a/sources/scalac/symtab/Type.java
+++ b/sources/scalac/symtab/Type.java
@@ -2171,10 +2171,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
this.singleDeref().isSameAs(that)
||
that.singleDeref().isSingletonType() &&
- this.isSameAs(that.singleDeref())
- ||
- deAlias(that) != that &&
- this.isSameAs(deAlias(that));
+ this.isSameAs(that.singleDeref());
default:
if (deAlias(this) != this)
return deAlias(this).isSameAs(that);
@@ -2190,10 +2187,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
this.singleDeref().isSameAs(that)
||
that.singleDeref().isSingletonType() &&
- this.isSameAs(that.singleDeref())
- ||
- (deAlias(this) != this || deAlias(that) != that) &&
- deAlias(this).isSameAs(deAlias(that));
+ this.isSameAs(that.singleDeref());
case ThisType(Symbol sym1):
return sym.isModule()
&& sym.moduleClass() == sym1
@@ -2203,10 +2197,7 @@ public class Type implements Modifiers, Kinds, TypeTags, EntryTags {
this.singleDeref().isSameAs(that)
||
that.singleDeref().isSingletonType() &&
- this.isSameAs(that.singleDeref())
- ||
- deAlias(this) != this &&
- deAlias(this).isSameAs(that);
+ this.isSameAs(that.singleDeref());
default:
if (deAlias(this) != this)
return deAlias(this).isSameAs(that);
diff --git a/sources/scalac/transformer/ExplicitOuterClassesPhase.java b/sources/scalac/transformer/ExplicitOuterClassesPhase.java
index e7e4fe33d8..b0cd2918d8 100644
--- a/sources/scalac/transformer/ExplicitOuterClassesPhase.java
+++ b/sources/scalac/transformer/ExplicitOuterClassesPhase.java
@@ -309,6 +309,7 @@ public class ExplicitOuterClassesPhase extends Phase {
/** Transforms the given tree. */
public Tree transform(Tree tree) {
+ if (global.debug) global.log("transforming " + tree);//debug
switch (tree) {
case ClassDef(_, _, _, _, _, Template impl):
diff --git a/sources/scalac/util/OptionParser.java b/sources/scalac/util/OptionParser.java
index 6294db9a20..9521ca388e 100644
--- a/sources/scalac/util/OptionParser.java
+++ b/sources/scalac/util/OptionParser.java
@@ -9,6 +9,7 @@
package scalac.util;
import scala.tools.util.Position;
+import scala.tools.util.Reporter;
import java.text.Format;
import java.text.MessageFormat;
diff --git a/test/files/pos/bug31.scala b/test/files/pos/bug31.scala
index 607dd4ce4f..92f33bfd02 100644
--- a/test/files/pos/bug31.scala
+++ b/test/files/pos/bug31.scala
@@ -4,7 +4,7 @@ object Main {
def ensure(postcondition: a => Boolean): a
}
- def require[a](def precondition: Boolean)(def command: a): Ensure[a] =
+ def require[a](precondition: => Boolean)(command: => a): Ensure[a] =
if (precondition)
new Ensure[a] {
def ensure(postcondition: a => Boolean): a = {
diff --git a/test/files/pos/bug76.scala b/test/files/pos/bug76.scala
index 07cddd714f..5419cf5154 100644
--- a/test/files/pos/bug76.scala
+++ b/test/files/pos/bug76.scala
@@ -1,6 +1,6 @@
// This is extracted from a test file => don't add a new test file.
object bug {
- def foo(def i: Int): Int = 0;
+ def foo(i: => Int): Int = 0;
def bar: Int = {
var i: Int = 0;
diff --git a/test/files/pos/bug93.scala b/test/files/pos/bug93.scala
index f3441fe9c3..d648d773b0 100644
--- a/test/files/pos/bug93.scala
+++ b/test/files/pos/bug93.scala
@@ -1,4 +1,4 @@
object Bug {
- def f(def cond: Boolean) = while (cond == false) {};
+ def f(cond: => Boolean) = while (cond == false) {};
// no bug with "false == cond"
}
diff --git a/test/files/run/Course-2002-01.scala b/test/files/run/Course-2002-01.scala
index 11d29540af..1e97cf0886 100644
--- a/test/files/run/Course-2002-01.scala
+++ b/test/files/run/Course-2002-01.scala
@@ -41,7 +41,7 @@ object M0 {
def loop: Int = loop;
def first(x: Int, y: Int) = x;
- def constOne(x: Int, def y: Int) = 1;
+ def constOne(x: Int, y: => Int) = 1;
java.lang.System.out.println(constOne(1, loop));
diff --git a/test/files/run/Course-2002-03.scala b/test/files/run/Course-2002-03.scala
index f84625f2b3..c0e3cecfc6 100644
--- a/test/files/run/Course-2002-03.scala
+++ b/test/files/run/Course-2002-03.scala
@@ -181,12 +181,12 @@ object M5 {
object M6 {
trait Boolean {
- def ifThenElse[a](def t: a)(def e: a): a;
+ def ifThenElse[a](t: => a)(e: => a): a;
def ! : Boolean = ifThenElse[Boolean](new False())(new True());
- def && (def x: Boolean): Boolean = ifThenElse[Boolean](x)(new False());
- def || (def x: Boolean): Boolean = ifThenElse[Boolean](new True())(x);
+ def && (x: => Boolean): Boolean = ifThenElse[Boolean](x)(new False());
+ def || (x: => Boolean): Boolean = ifThenElse[Boolean](new True())(x);
// !!! def == (x: Boolean): Boolean = ifThenElse[Boolean](x)(x.!);
// !!! def != (x: Boolean): Boolean = ifThenElse[Boolean](x.!)(x);
@@ -196,9 +196,9 @@ object M6 {
def >= (x: Boolean): Boolean = ifThenElse[Boolean](new True())(x.!);
}
class True() extends Boolean { // !!! class -> object
- def ifThenElse[a](def t: a)(def e: a): a = t }
+ def ifThenElse[a](t: => a)(e: => a): a = t }
class False() extends Boolean { // !!! class -> object
- def ifThenElse[a](def t: a)(def e: a): a = e }
+ def ifThenElse[a](t: => a)(e: => a): a = e }
}
//############################################################################
diff --git a/test/files/run/Course-2002-04.scala b/test/files/run/Course-2002-04.scala
index e74711d454..d14af43a96 100644
--- a/test/files/run/Course-2002-04.scala
+++ b/test/files/run/Course-2002-04.scala
@@ -47,7 +47,7 @@ object M1 {
def mergesort[a] (less : (a,a) => Boolean) (xs: Array[a]): Unit = {
- def While(def c: Boolean)(def b: Unit): Unit =
+ def While(c: => Boolean)(b: => Unit): Unit =
if (c) { b ; While(c)(b) } else ();
def swap(i: Int, j: Int): Unit = {
diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala
index de6b497fde..0c0926fa09 100644
--- a/test/files/run/Course-2002-08.scala
+++ b/test/files/run/Course-2002-08.scala
@@ -91,7 +91,7 @@ object M1 {
object M2 {
- def While(def condition: Boolean)(def command: Unit): Unit =
+ def While(condition: => Boolean)(command: => Unit): Unit =
if (condition) {
command; While(condition)(command)
} else {
diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala
index 022bb77ac5..cd9360fb97 100644
--- a/test/files/run/Course-2002-13.scala
+++ b/test/files/run/Course-2002-13.scala
@@ -223,7 +223,7 @@ class Parser(s: String) {
def syntaxError(msg: String): Unit = error(msg + ", but " + token + " found");
- def rep[a](def p: a): List[a] = {
+ def rep[a](p: => a): List[a] = {
val t = p;
if (token == ",") { token = it.next; t :: rep(p) } else List(t)
}
diff --git a/test/files/run/bridges.scala b/test/files/run/bridges.scala
index 8c6c013ae1..91fd277f57 100644
--- a/test/files/run/bridges.scala
+++ b/test/files/run/bridges.scala
@@ -3580,7 +3580,7 @@ abstract class BarYIf[Y] { class I ; def f: I = {bar; null}; f; }
object Test {
var errors: Int = 0;
- def test(name: String, def test: Any, count: Int, value: String) = {
+ def test(name: String, test: => Any, count: Int, value: String) = {
try {
Help.init;
test;
diff --git a/test/files/run/bugs.scala b/test/files/run/bugs.scala
index 31c82eb490..b0a26d92e3 100644
--- a/test/files/run/bugs.scala
+++ b/test/files/run/bugs.scala
@@ -300,7 +300,7 @@ object Bug257Test {
def f1(x: Unit): Unit = ();
def f2(x: Unit)(y: Unit): Unit = ();
- def f(def x: Unit) = {
+ def f(x: => Unit) = {
f1(x);
f2(x);
}
@@ -404,7 +404,7 @@ object Bug328Test {
object Test {
var errors: Int = 0;
- def test(bug: Int, def test: Unit): Unit = {
+ def test(bug: Int, test: => Unit): Unit = {
System.out.println("<<< bug " + bug);
try {
test;
diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala
index 91fea177ad..5af6577ba3 100644
--- a/test/files/run/enums.scala
+++ b/test/files/run/enums.scala
@@ -53,7 +53,7 @@ object Test3 {
object Test {
import java.lang.System;
- def check_success(name: String, def closure: Int, expected: Int): Unit = {
+ def check_success(name: String, closure: => Int, expected: Int): Unit = {
System.out.print("test " + name);
try {
val actual: Int = closure;
diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala
index 6d7647009d..5a0c2e5c53 100644
--- a/test/files/run/literals.scala
+++ b/test/files/run/literals.scala
@@ -15,7 +15,7 @@ object Test {
case class GGG(i:int) {
def \u21a1\u21a1( that:GGG ) = that;
}
- def check_success[a](name: String, def closure: a, expected: a): Unit = {
+ def check_success[a](name: String, closure: => a, expected: a): Unit = {
out.print("test " + name);
try {
val actual: a = closure;
diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala
index 55b2d9d862..1a7141befa 100644
--- a/test/files/run/runtime.scala
+++ b/test/files/run/runtime.scala
@@ -92,7 +92,7 @@ object Test1Test {
object Test {
var errors: Int = 0;
- def test(bug: String, def test: Unit): Unit = {
+ def test(bug: String, test: => Unit): Unit = {
System.out.println("<<< bug " + bug);
try {
test;
diff --git a/test/files/run/tailcalls.scala b/test/files/run/tailcalls.scala
index 1a296023aa..efec951d02 100644
--- a/test/files/run/tailcalls.scala
+++ b/test/files/run/tailcalls.scala
@@ -190,7 +190,7 @@ class TailCall[S](s: S) {
object Test {
import java.lang.System;
- def check_success(name: String, def closure: Int, expected: Int): Unit = {
+ def check_success(name: String, closure: => Int, expected: Int): Unit = {
System.out.print("test " + name);
try {
val actual: Int = closure;