summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2005-10-03 13:42:39 +0000
committerMartin Odersky <odersky@gmail.com>2005-10-03 13:42:39 +0000
commit2994973970bcba6ff90d7788e79f2042cc11deaf (patch)
treeb90fbfc9d5b12b01f2815edabb2f0eeb17655a94
parent159a3633b593bf2b0a10f4f4e218489b2bba03bc (diff)
downloadscala-2994973970bcba6ff90d7788e79f2042cc11deaf.tar.gz
scala-2994973970bcba6ff90d7788e79f2042cc11deaf.tar.bz2
scala-2994973970bcba6ff90d7788e79f2042cc11deaf.zip
*** empty log message ***
-rw-r--r--sources/scala/Predef.scala4
-rwxr-xr-xsources/scala/tools/nsc/Global.scala9
-rw-r--r--sources/scala/tools/nsc/ast/TreePrinters.scala2
-rw-r--r--sources/scala/tools/nsc/ast/Trees.scala7
-rwxr-xr-xsources/scala/tools/nsc/ast/parser/Parsers.scala1
-rw-r--r--sources/scala/tools/nsc/backend/icode/TypeStacks.scala3
-rwxr-xr-xsources/scala/tools/nsc/symtab/Types.scala58
-rwxr-xr-xsources/scala/tools/nsc/transform/AddInterfaces.scala12
-rwxr-xr-xsources/scala/tools/nsc/transform/Constructors.scala7
-rwxr-xr-xsources/scala/tools/nsc/transform/Flatten.scala2
-rwxr-xr-xsources/scala/tools/nsc/transform/Mixin.scala20
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Infer.scala19
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Namers.scala12
-rwxr-xr-xsources/scala/tools/nsc/typechecker/Typers.scala70
-rw-r--r--test/files/pos/MailBox.scala4
-rw-r--r--test/files/pos/S5.scala4
-rw-r--r--test/files/pos/bug115.scala2
-rw-r--r--test/files/pos/bug159.scala4
-rw-r--r--test/files/pos/bug211.scala2
-rw-r--r--test/files/pos/bug245.scala6
-rw-r--r--test/files/pos/bug267.scala6
-rw-r--r--test/files/pos/bug289.scala2
-rw-r--r--test/files/pos/bug342.scala2
-rwxr-xr-xtest/files/pos/bug348plus.scala23
-rw-r--r--test/files/pos/bug360.scala2
-rw-r--r--test/files/pos/bug361.scala2
-rw-r--r--test/files/pos/bug91.scala2
-rw-r--r--test/files/pos/compile.scala2
-rw-r--r--test/files/pos/constfold.scala2
-rwxr-xr-xtest/files/pos/failed.lst3
-rw-r--r--test/files/pos/gui.scala2
-rw-r--r--test/files/pos/matthias4.scala6
-rw-r--r--test/files/pos/michel1.scala2
-rw-r--r--test/files/pos/mixins.scala17
-rw-r--r--test/files/pos/nested.scala6
-rwxr-xr-xtest/files/pos/ok.lst138
-rwxr-xr-xtest/files/pos/orderedpoints.scala8
-rw-r--r--test/files/pos/rebind.scala2
-rw-r--r--test/files/pos/scoping1.scala2
-rw-r--r--test/files/pos/testcast.scala2
-rwxr-xr-xtest/files/pos/viewtest1.scala4
-rwxr-xr-xtest/files/pos/viewtest2.scala12
-rw-r--r--test/files/pos/viewtest3.scala2
43 files changed, 378 insertions, 119 deletions
diff --git a/sources/scala/Predef.scala b/sources/scala/Predef.scala
index d3214f9fd3..f8e62aa12b 100644
--- a/sources/scala/Predef.scala
+++ b/sources/scala/Predef.scala
@@ -141,6 +141,8 @@ object Predef {
// views -------------------------------------------------------------
+ implicit def identity[a](x: a): a = x;
+
implicit def int2ordered(x: int): Ordered[int] = new Ordered[int] with Proxy {
def self: Any = x;
def compareTo [b >: int <% Ordered[b]](y: b): int = y match {
@@ -295,8 +297,6 @@ object Predef {
}
def view(x: String): Ordered[String] = string2ordered(x);
- implicit def ordered2ordered[a <: Ordered[a]](x: a): Ordered[a] = x;
-
implicit def array2seq[A](xs: Array[A]): Seq[A] = new Seq[A] {
def length = xs.length;
def elements = Iterator.fromArray(xs);
diff --git a/sources/scala/tools/nsc/Global.scala b/sources/scala/tools/nsc/Global.scala
index 0648bd3c4e..e82af18eb9 100755
--- a/sources/scala/tools/nsc/Global.scala
+++ b/sources/scala/tools/nsc/Global.scala
@@ -360,6 +360,7 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
symData -= sym.linkedSym;
writeSymblFile(sym, pickled)
}
+ resetPackageClass(sym.owner);
}
} else {
for (val Pair(sym, file) <- symSource.elements) {
@@ -396,6 +397,14 @@ class Global(val settings: Settings, val reporter: Reporter) extends SymbolTable
} catch {
case ex: IOException => error(ex.getMessage());
}
+
+ private def resetPackageClass(pclazz: Symbol): unit = {
+ assert(pclazz.isPackageClass, pclazz);
+ atPhase(firstPhase) {
+ pclazz.setInfo(atPhase(typerPhase)(pclazz.info))
+ }
+ if (!pclazz.isRoot) resetPackageClass(pclazz.owner);
+ }
}
def showDef(name: Name, module: boolean): unit = {
diff --git a/sources/scala/tools/nsc/ast/TreePrinters.scala b/sources/scala/tools/nsc/ast/TreePrinters.scala
index 509ad67d62..f8891766ed 100644
--- a/sources/scala/tools/nsc/ast/TreePrinters.scala
+++ b/sources/scala/tools/nsc/ast/TreePrinters.scala
@@ -260,7 +260,7 @@ abstract class TreePrinters {
def print(tree: Tree): unit =
printRaw(
- if (tree.isDef && tree.symbol != NoSymbol && !tree.symbol.isInitialized) {
+ if (tree.isDef && tree.symbol != NoSymbol) {
tree match {
case ClassDef(_, _, _, _, impl) => ClassDef(tree.symbol, impl)
case ModuleDef(_, _, impl) => ModuleDef(tree.symbol, impl)
diff --git a/sources/scala/tools/nsc/ast/Trees.scala b/sources/scala/tools/nsc/ast/Trees.scala
index 357aeae666..84e297afbf 100644
--- a/sources/scala/tools/nsc/ast/Trees.scala
+++ b/sources/scala/tools/nsc/ast/Trees.scala
@@ -50,7 +50,7 @@ import symtab.Flags._;
case _ => false
}
- def duplicate: Tree = duplicator transform this;
+ def duplicate: this.type = (duplicator transform this).asInstanceOf[this.type];
def copyAttrs(tree: Tree): this.type = {
pos = tree.pos;
@@ -1047,6 +1047,7 @@ import symtab.Flags._;
stats foreach (stat =>
if (exprOwner != currentOwner && stat.isTerm) atOwner(exprOwner)(traverse(stat))
else traverse(stat));
+ def apply[T <: Tree](tree: T): T = { traverse(tree); tree }
def atOwner(owner: Symbol)(traverse: => unit): unit = {
val prevOwner = currentOwner;
@@ -1062,7 +1063,7 @@ import symtab.Flags._;
if (tree.tpe != null) tree.tpe = typeSubst(tree.tpe);
super.traverse(tree)
}
- def apply(tree: Tree): Tree = { val tree1 = tree.duplicate; traverse(tree1); tree1 }
+ override def apply[T <: Tree](tree: T): T = super.apply(tree.duplicate)
}
class TreeSymSubstituter(from: List[Symbol], to: List[Symbol]) extends Traverser {
@@ -1077,7 +1078,7 @@ import symtab.Flags._;
if (tree.hasSymbol) subst(from, to);
super.traverse(tree)
}
- def apply(tree: Tree): Tree = { val tree1 = tree.duplicate; traverse(tree1); tree1 }
+ override def apply[T <: Tree](tree: T): T = super.apply(tree.duplicate)
}
class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser {
diff --git a/sources/scala/tools/nsc/ast/parser/Parsers.scala b/sources/scala/tools/nsc/ast/parser/Parsers.scala
index 90b383f59c..59eaa4eb47 100755
--- a/sources/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/sources/scala/tools/nsc/ast/parser/Parsers.scala
@@ -1746,6 +1746,7 @@ import Tokens._;
accept(LBRACE);
val t = makePackaging(pkg, topStatSeq());
accept(RBRACE);
+ if (in.token == SEMI) in.nextToken();
t
}
} else {
diff --git a/sources/scala/tools/nsc/backend/icode/TypeStacks.scala b/sources/scala/tools/nsc/backend/icode/TypeStacks.scala
index d155399483..5d2267f2ec 100644
--- a/sources/scala/tools/nsc/backend/icode/TypeStacks.scala
+++ b/sources/scala/tools/nsc/backend/icode/TypeStacks.scala
@@ -16,8 +16,9 @@ trait TypeStacks: ICodes {
/* This class simulates the type of the opperand
* stack of the ICode.
*/
+ type Rep = List[TypeKind];
+
class TypeStack {
- type Rep = List[TypeKind];
var types: Rep = Nil;
diff --git a/sources/scala/tools/nsc/symtab/Types.scala b/sources/scala/tools/nsc/symtab/Types.scala
index 2d89000518..f326e58fd4 100755
--- a/sources/scala/tools/nsc/symtab/Types.scala
+++ b/sources/scala/tools/nsc/symtab/Types.scala
@@ -6,6 +6,7 @@
package scala.tools.nsc.symtab;
import scala.tools.util.Position;
+import nsc.util.ListBuffer;
import Flags._;
/* A standard type pattern match:
@@ -551,7 +552,62 @@ import Flags._;
try {
if (util.Statistics.enabled) compoundClosureCount = compoundClosureCount + 1;
//System.out.println("computing closure of " + symbol.tpe + " " + parents);//DEBUG
- addClosure(symbol.tpe, glbArray(parents map (.closure)));
+ val buf = new ListBuffer[Type];
+ buf += symbol.tpe;
+ var clSize = 1;
+ val nparents = parents.length;
+ if (nparents != 0) {
+ val pclosure = new Array[Array[Type]](nparents);
+ val index = new Array[int](nparents);
+ var i = 0;
+ for (val p <- parents) {
+ pclosure(i) = p.closure;
+ index(i) = 0;
+ i = i + 1
+ }
+ val limit = pclosure(0).length;
+ while (index(0) != limit) {
+ var minSym: Symbol = pclosure(0)(index(0)).symbol;
+ i = 1;
+ while (i < nparents) {
+ if (pclosure(i)(index(i)).symbol isLess minSym)
+ minSym = pclosure(i)(index(i)).symbol;
+ i = i + 1
+ }
+ var minTypes: List[Type] = List();
+ i = 0;
+ while (i < nparents) {
+ val tp = pclosure(i)(index(i));
+ if (tp.symbol == minSym) {
+ if (!(minTypes exists (tp =:=))) minTypes = tp :: minTypes;
+ index(i) = index(i) + 1
+ }
+ i = i + 1
+ }
+ buf += intersectionType(minTypes);
+ clSize = clSize + 1;
+ }
+ i = 0;
+ while (i < nparents) {
+ assert(index(i) == pclosure(i).length);
+ i = i + 1
+ }
+ }
+ closureCache = new Array[Type](clSize);
+ buf.copyToArray(closureCache, 0);
+ //System.out.println("closureCache of " + symbol.tpe + " = " + List.fromArray(closureCache));//DEBUG
+ var j = 0;
+ while (j < clSize) {
+ closureCache(j) match {
+ case RefinedType(parents, decls) =>
+ assert(decls.isEmpty);
+ closureCache(j) = glb(parents)
+ case _ =>
+ }
+ j = j + 1
+ }
+ //System.out.println("closure of " + symbol.tpe + " = " + List.fromArray(closureCache));//DEBUG
+ closureCache
} catch {
case ex: MalformedClosure =>
throw new MalformedType(
diff --git a/sources/scala/tools/nsc/transform/AddInterfaces.scala b/sources/scala/tools/nsc/transform/AddInterfaces.scala
index 00fe47c7ca..2319346f8b 100755
--- a/sources/scala/tools/nsc/transform/AddInterfaces.scala
+++ b/sources/scala/tools/nsc/transform/AddInterfaces.scala
@@ -45,7 +45,7 @@ abstract class AddInterfaces extends InfoTransform {
case None =>
atPhase(currentRun.erasurePhase) {
val implName = nme.implClassName(iface.name);
- var impl = if (iface.owner.isClass) iface.owner.info.decls.lookup(implName) else NoSymbol;
+ var impl = if (iface.owner.isClass) iface.owner.info.decl(implName) else NoSymbol;
if (impl == NoSymbol) {
impl = iface.cloneSymbolImpl(iface.owner);
impl.name = implName;
@@ -55,7 +55,7 @@ abstract class AddInterfaces extends InfoTransform {
impl.flags = iface.flags & ~(INTERFACE | lateINTERFACE);
impl setInfo new LazyImplClassType(iface);
implClassMap(iface) = impl;
- if (settings.debug.value) log("generating impl class " + impl);
+ if (settings.debug.value) log("generating impl class " + impl + " in " + iface.owner);//debug
impl
}
}
@@ -154,8 +154,7 @@ abstract class AddInterfaces extends InfoTransform {
implMethodMap.get(ifaceMethod) match {
case Some(implMethod) =>
tree.symbol = implMethod;
- new ChangeOwnerAndReturnTraverser(ifaceMethod, implMethod).traverse(tree);
- tree
+ new ChangeOwnerAndReturnTraverser(ifaceMethod, implMethod)(tree)
case None =>
throw new Error("implMethod missing for " + ifaceMethod)
}
@@ -169,9 +168,8 @@ abstract class AddInterfaces extends InfoTransform {
val templ1 = Template(templ.parents, templ.body map implMemberDef)
setPos templ.pos
setSymbol clazz.newLocalDummy(templ.pos);
- new ChangeOwnerTraverser(templ.symbol.owner, clazz).traverse(templ1);
- new ChangeOwnerTraverser(templ.symbol, templ1.symbol).traverse(templ1);
- templ1
+ new ChangeOwnerTraverser(templ.symbol.owner, clazz)(
+ new ChangeOwnerTraverser(templ.symbol, templ1.symbol)(templ1))
}
def implClassDefs(trees: List[Tree]): List[Tree] = {
diff --git a/sources/scala/tools/nsc/transform/Constructors.scala b/sources/scala/tools/nsc/transform/Constructors.scala
index 9d9230719c..38c260264f 100755
--- a/sources/scala/tools/nsc/transform/Constructors.scala
+++ b/sources/scala/tools/nsc/transform/Constructors.scala
@@ -62,10 +62,9 @@ abstract class Constructors extends Transform {
}
}
- def intoConstructor(oldowner: Symbol, tree: Tree) = {
- new ChangeOwnerTraverser(oldowner, constr.symbol).traverse(tree);
- intoConstructorTransformer.transform(tree)
- }
+ def intoConstructor(oldowner: Symbol, tree: Tree) =
+ intoConstructorTransformer.transform(
+ new ChangeOwnerTraverser(oldowner, constr.symbol)(tree));
def mkAssign(to: Symbol, from: Tree): Tree =
atPos(to.pos) {
diff --git a/sources/scala/tools/nsc/transform/Flatten.scala b/sources/scala/tools/nsc/transform/Flatten.scala
index 0af811cf3f..6632e50e09 100755
--- a/sources/scala/tools/nsc/transform/Flatten.scala
+++ b/sources/scala/tools/nsc/transform/Flatten.scala
@@ -40,7 +40,7 @@ abstract class Flatten extends InfoTransform {
var parents1 = parents;
val decls1 = new Scope();
if (clazz.isPackageClass) {
- atPhase(phase.next)(decls.toList foreach (decls1 enter))
+ atPhase(phase.next)(decls.toList foreach (decls1 enter));
} else {
val oldowner = clazz.owner;
atPhase(phase.next)(oldowner.info);
diff --git a/sources/scala/tools/nsc/transform/Mixin.scala b/sources/scala/tools/nsc/transform/Mixin.scala
index 6e70bfc31a..90e55f77de 100755
--- a/sources/scala/tools/nsc/transform/Mixin.scala
+++ b/sources/scala/tools/nsc/transform/Mixin.scala
@@ -237,17 +237,12 @@ abstract class Mixin extends InfoTransform {
case DefDef(mods, name, tparams, List(vparams), tpt, EmptyTree)
if (stat.symbol hasFlag SUPERACCESSOR) =>
assert(stat.symbol hasFlag MIXEDIN, stat);
- val rhs1 =
- postTransform {
- localTyper.typed {
- atPos(stat.pos) {
- Apply(Select(Super(clazz, nme.EMPTY.toTypeName), stat.symbol.alias),
- vparams map (vparam => Ident(vparam.symbol)))
- }
- }
- }
- //System.out.println("complete super acc " + stat.symbol + stat.symbol.locationString + " " + rhs1 + " " + stat.symbol.alias + stat.symbol.alias.locationString);//DEBUG
- copy.DefDef(stat, mods, name, tparams, List(vparams), tpt, localTyper.typed(rhs1))
+ val rhs0 =
+ Apply(Select(Super(clazz, nme.EMPTY.toTypeName), stat.symbol.alias),
+ vparams map (vparam => Ident(vparam.symbol)));
+ if (settings.debug.value) log("complete super acc " + stat.symbol + stat.symbol.locationString + " " + rhs0 + " " + stat.symbol.alias + stat.symbol.alias.locationString);//debug
+ val rhs1 = postTransform(localTyper.typed(atPos(stat.pos)(rhs0)));
+ copy.DefDef(stat, mods, name, tparams, List(vparams), tpt, rhs1)
case _ =>
stat
}
@@ -306,7 +301,8 @@ abstract class Mixin extends InfoTransform {
}
} else if (qual.isInstanceOf[Super] && (sym.owner hasFlag lateINTERFACE)) {
val sym1 = atPhase(phase.prev)(sym.overridingSymbol(sym.owner.implClass));
- assert(sym1 != NoSymbol, sym);
+ if (sym1 == NoSymbol)
+ assert(false, "" + sym + " " + sym.owner + " " + sym.owner.implClass + " " + sym.owner.owner + atPhase(phase.prev)(sym.owner.owner.info.decls.toList));//debug
localTyper.typed {
atPos(tree.pos) {
Apply(staticRef(sym1), gen.This(currentOwner.enclClass) :: args)
diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala
index 1b0ca1097f..71ebf56512 100755
--- a/sources/scala/tools/nsc/typechecker/Infer.scala
+++ b/sources/scala/tools/nsc/typechecker/Infer.scala
@@ -56,6 +56,7 @@ package scala.tools.nsc.typechecker;
case WildcardType | NoType =>
throw new NoInstance("undetermined type");
case TypeVar(origin, constr) =>
+ assert(constr.inst != null);//debug
if (constr.inst != NoType) instantiate(constr.inst)
else throw new DeferredNoInstance(() =>
"no unique instantiation of type variable " + origin + " could be found");
@@ -108,23 +109,23 @@ package scala.tools.nsc.typechecker;
if (bound.symbol != AnyClass) {
tvar.constr.hibounds =
bound.subst(tparams, tvars) :: tvar.constr.hibounds;
- for (val tparam2 <- tparams)
- if (tparam2.info.bounds.lo =:= tparam.tpe)
- tvar.constr.hibounds =
- tparam2.tpe.subst(tparams, tvars) :: tvar.constr.hibounds;
}
+ for (val tparam2 <- tparams)
+ if (tparam2.info.bounds.lo =:= tparam.tpe)
+ tvar.constr.hibounds =
+ tparam2.tpe.subst(tparams, tvars) :: tvar.constr.hibounds;
} else {
if (bound.symbol != AllClass && bound.symbol != tparam) {
tvar.constr.lobounds =
bound.subst(tparams, tvars) :: tvar.constr.lobounds;
- for (val tparam2 <- tparams)
- if (tparam2.info.bounds.hi =:= tparam.tpe)
- tvar.constr.lobounds =
- tparam2.tpe.subst(tparams, tvars) :: tvar.constr.lobounds;
}
+ for (val tparam2 <- tparams)
+ if (tparam2.info.bounds.hi =:= tparam.tpe)
+ tvar.constr.lobounds =
+ tparam2.tpe.subst(tparams, tvars) :: tvar.constr.lobounds;
}
- tvar.constr.inst = if (up) glb(tvar.constr.hibounds) else lub(tvar.constr.lobounds)
}
+ tvar.constr.inst = if (up) glb(tvar.constr.hibounds) else lub(tvar.constr.lobounds)
}
}
for (val Pair(tvar, Pair(tparam, variance)) <- config) solveOne(tvar, tparam, variance);
diff --git a/sources/scala/tools/nsc/typechecker/Namers.scala b/sources/scala/tools/nsc/typechecker/Namers.scala
index 9219ae330a..11944187aa 100755
--- a/sources/scala/tools/nsc/typechecker/Namers.scala
+++ b/sources/scala/tools/nsc/typechecker/Namers.scala
@@ -16,8 +16,10 @@ trait Namers: Analyzer {
def updatePosFlags(sym: Symbol, pos: int, mods: int): Symbol = {
if (settings.debug.value) log("overwriting " + sym);
+ val lockedFlag = sym.flags & LOCKED;
+ sym.reset(NoType);
sym setPos pos;
- sym.flags = mods | sym.flags & LOCKED;
+ sym.flags = mods | lockedFlag;
if (sym.isModule)
updatePosFlags(sym.moduleClass, pos, (mods & ModuleToClassFlags) | MODULE | FINAL);
if (sym.owner.isPackageClass && sym.linkedSym.rawInfo.isInstanceOf[loaders.SymbolLoader])
@@ -352,11 +354,15 @@ trait Namers: Analyzer {
case ModuleDef(_, _, impl) =>
val clazz = sym.moduleClass;
clazz.setInfo(new Namer(context.make(tree, clazz)).templateSig(impl));
+ //clazz.typeOfThis = singleType(sym.owner.thisType, sym);
clazz.tpe;
case DefDef(_, _, tparams, vparamss, tpt, rhs) =>
- checkContractive(sym,
- new Namer(context.makeNewScope(tree, sym)).methodSig(tparams, vparamss, tpt, rhs))
+ if (sym.isConstructor) sym.owner.setFlag(INCONSTRUCTOR);
+ val result =
+ new Namer(context.makeNewScope(tree, sym)).methodSig(tparams, vparamss, tpt, rhs);
+ if (sym.isConstructor) sym.owner.resetFlag(INCONSTRUCTOR);
+ checkContractive(sym, result)
case ValDef(_, _, tpt, rhs) =>
if (tpt.isEmpty)
diff --git a/sources/scala/tools/nsc/typechecker/Typers.scala b/sources/scala/tools/nsc/typechecker/Typers.scala
index 867c8d6b43..b4a585ed65 100755
--- a/sources/scala/tools/nsc/typechecker/Typers.scala
+++ b/sources/scala/tools/nsc/typechecker/Typers.scala
@@ -33,6 +33,17 @@ import collection.mutable.HashMap;
superDefs.clear;
}
+ val resetAttrs = new Traverser {
+ override def traverse(tree: Tree): unit = tree match {
+ case EmptyTree | TypeTree() =>
+ ;
+ case _ =>
+ if (tree.hasSymbol) tree.symbol = NoSymbol;
+ tree.tpe = null;
+ super.traverse(tree)
+ }
+ }
+
def newTyper(context: Context): Typer = new Typer(context);
class Typer(context0: Context) {
@@ -291,7 +302,6 @@ import collection.mutable.HashMap;
if ((mode & EXPRmode) != 0 && sym == ByNameParamClass) => // (2)
adapt(tree setType arg, mode, pt);
case PolyType(tparams, restpe) if ((mode & TAPPmode) == 0) => // (3)
- if (settings.debug.value && tree.symbol != null) log("adapting " + tree + " " + tree.symbol.tpe + " " + tree.symbol.getClass() + " " + tree.symbol.hasFlag(CASE));//debug
val tparams1 = cloneSymbols(tparams);
val tree1 = if (tree.isType) tree
else TypeApply(tree, tparams1 map (tparam =>
@@ -303,7 +313,9 @@ import collection.mutable.HashMap;
case mt: MethodType if ((mode & (EXPRmode | FUNmode)) == EXPRmode &&
isCompatible(tree.tpe, pt)) => // (4.2)
if (tree.symbol.isConstructor) errorTree(tree, "missing arguments for " + tree.symbol)
- else typed(etaExpand(tree), mode, pt)
+ else {
+ typed(etaExpand(tree), mode, pt)
+ }
case _ =>
if (tree.isType) {
val clazz = tree.tpe.symbol;
@@ -348,7 +360,7 @@ import collection.mutable.HashMap;
val tparams = context.undetparams;
context.undetparams = List();
inferExprInstance(tree, tparams, pt);
- tree
+ adapt(tree, mode, pt)
} else if (tree.tpe <:< pt) {
tree
} else {
@@ -366,8 +378,10 @@ import collection.mutable.HashMap;
}
if (context.reportGeneralErrors) { // (13); the condition prevents chains of views
val coercion = inferView(tree.pos, tree.tpe, pt, true);
- if (coercion != EmptyTree)
+ if (coercion != EmptyTree) {
+ if (settings.debug.value) log("inferred view from " + tree.tpe + " to " + pt + " = " + coercion + ":" + coercion.tpe);
return typed(Apply(coercion, List(tree)) setPos tree.pos, mode, pt);
+ }
}
}
if (settings.debug.value) log("error tree = " + tree);
@@ -676,9 +690,12 @@ import collection.mutable.HashMap;
val expr1 = typed(block.expr, mode & ~(FUNmode | QUALmode), pt);
val block1 = copy.Block(block, stats1, expr1)
setType (if (treeInfo.isPureExpr(block)) expr1.tpe else expr1.tpe.deconst);
- if (block1.tpe.symbol.isAnonymousClass)
- block1 setType intersectionType(block1.tpe.parents, block1.tpe.symbol.owner);
- if (isFullyDefined(pt)) block1 else checkNoEscaping.locals(context.scope, block1)
+ if (isFullyDefined(pt)) block1
+ else {
+ if (block1.tpe.symbol.isAnonymousClass)
+ block1 setType intersectionType(block1.tpe.parents, block1.tpe.symbol.owner);
+ checkNoEscaping.locals(context.scope, block1)
+ }
}
def typedCase(cdef: CaseDef, pattpe: Type, pt: Type): CaseDef = {
@@ -762,18 +779,13 @@ import collection.mutable.HashMap;
case Match(_, cases) =>
val substParam = new TreeSymSubstituter(List(vparams.head.symbol), List(idparam));
def transformCase(cdef: CaseDef): CaseDef =
- CaseDef(substParam(cdef.pat.duplicate),
- substParam(cdef.guard.duplicate),
- Literal(true));
- val result =
- if (cases exists treeInfo.isDefaultCase) Literal(true)
- else
- Match(
- Ident(idparam),
- (cases map transformCase) :::
- List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))));
- new ChangeOwnerTraverser(applyMethod, isDefinedAtMethod).traverse(result);
- result
+ resetAttrs(CaseDef(cdef.pat.duplicate, cdef.guard.duplicate, Literal(true)));
+ if (cases exists treeInfo.isDefaultCase) Literal(true)
+ else
+ Match(
+ Ident(idparam),
+ (cases map transformCase) :::
+ List(CaseDef(Ident(nme.WILDCARD), EmptyTree, Literal(false))))
}
members = DefDef(isDefinedAtMethod, vparamss => idbody(vparamss.head.head)) :: members;
}
@@ -820,7 +832,6 @@ import collection.mutable.HashMap;
if (tparams.length == args.length) {
val targs = args map (.tpe);
checkBounds(tree.pos, tparams, targs, "");
- if (settings.debug.value) log("type app " + tparams + " => " + targs + " = " + restpe.subst(tparams, targs));//debug
copy.TypeApply(tree, fun, args) setType restpe.subst(tparams, targs);
} else {
errorTree(tree, "wrong number of type parameters for " + treeSymTypeMsg(fun))
@@ -935,10 +946,12 @@ import collection.mutable.HashMap;
}
if (sym.info == NoType) {
if (settings.debug.value) log("qual = " + qual + ":" + qual.tpe + "\nSymbol=" + qual.tpe.symbol + "\nsymbol-info = " + qual.tpe.symbol.info + "\nscope-id = " + qual.tpe.symbol.info.decls.hashCode() + "\nmembers = " + qual.tpe.members + "\nfound = " + sym);
- errorTree(tree,
- decode(name) + " is not a member of " + qual.tpe.widen +
- (if (Position.line(tree.pos) > Position.line(qual.pos))
- "\npossible cause: maybe a semicolon is missing before `" + name + "'?" else ""))
+ if (!qual.tpe.isError)
+ error(tree.pos,
+ decode(name) + " is not a member of " + qual.tpe.widen +
+ (if (Position.line(tree.pos) > Position.line(qual.pos))
+ "\npossible cause: maybe a semicolon is missing before `" + name + "'?" else ""));
+ setError(tree)
} else {
val tree1 = tree match {
case Select(_, _) => copy.Select(tree, qual, name)
@@ -1417,7 +1430,7 @@ import collection.mutable.HashMap;
tree = typed1(tree, EXPRmode, pt);
if (settings.debug.value) log("typed implicit " + tree + ":" + tree.tpe + ", pt = " + pt);//debug
val tree1 = adapt(tree, EXPRmode, pt);
- if (settings.debug.value) log("adapted implicit " + tree.symbol + ":" + info.sym);//debug
+ if (settings.debug.value) log("adapted implicit " + tree.symbol + ":" + tree1.tpe + " to " + pt);//debug
if (info.sym == tree.symbol) tree1
else fail("syms differ: " + tree.symbol + " " + info.sym)
} catch {
@@ -1430,10 +1443,11 @@ import collection.mutable.HashMap;
if (util.Statistics.enabled) implcnt = implcnt + 1;
val startTime = if (util.Statistics.enabled) System.currentTimeMillis() else 0l;
- def isBetter(sym1: Symbol, tpe1: Type, sym2: Symbol, tpe2: Type): boolean =
+ def isBetter(sym1: Symbol, tpe1: Type, sym2: Symbol, tpe2: Type): boolean = {
+ System.out.println("is better " + sym1 + ":" + tpe1 + " than " + sym2 + ":" + tpe2);
sym2.isError ||
(sym1.owner != sym2.owner) && (sym1.owner isSubClass sym2.owner) && (tpe1 matches tpe2);
-
+ }
val tc = newTyper(context.makeImplicit(reportAmbiguous));
def searchImplicit(implicitInfoss: List[List[ImplicitInfo]], local: boolean): Tree = {
@@ -1458,7 +1472,7 @@ import collection.mutable.HashMap;
pos,
"ambiguous implicit value:\n" +
" both " + is0.head.sym + is0.head.sym.locationString + " of type " + tree.tpe +
- "\n and" + is.head.sym + is.head.sym.locationString + " of type " + tree1.tpe +
+ "\n and " + is.head.sym + is.head.sym.locationString + " of type " + tree1.tpe +
(if (isView)
"\n are possible conversion functions from " +
pt.typeArgs(0) + " to " + pt.typeArgs(1)
diff --git a/test/files/pos/MailBox.scala b/test/files/pos/MailBox.scala
index 4e275cedbd..b1ea818f60 100644
--- a/test/files/pos/MailBox.scala
+++ b/test/files/pos/MailBox.scala
@@ -8,7 +8,7 @@ class MailBox {
var next: LinkedList[a] = null;
}
- def insert[a](l: LinkedList[a], x: a): LinkedList[a] = {
+ private def insert[a](l: LinkedList[a], x: a): LinkedList[a] = {
l.next = new LinkedList[a];
l.next.elem = x;
l.next.next = l.next;
@@ -32,7 +32,7 @@ class MailBox {
r = r1; r1 = r1.next;
}
if (r1 != null) {
- r.next = r1.next; r1.elem.msg = msg; r1.elem.notify;
+ r.next = r1.next; r1.elem.msg = msg; r1.elem.notify();
} else {
lastSent = insert(lastSent, msg);
}
diff --git a/test/files/pos/S5.scala b/test/files/pos/S5.scala
index 08f5b2a6eb..f0b66a6e68 100644
--- a/test/files/pos/S5.scala
+++ b/test/files/pos/S5.scala
@@ -16,7 +16,7 @@ abstract class M() {
// module body of M
}
}
-abstract class N() {
+trait N {
val _N: N = this;
val n: _N.n = new _N.n();
val _M: M;
@@ -26,5 +26,5 @@ abstract class N() {
}
}
object O {
- val system = new M() with N() {}
+ val system = new M() with N {}
}
diff --git a/test/files/pos/bug115.scala b/test/files/pos/bug115.scala
index 970636f708..a250e3c090 100644
--- a/test/files/pos/bug115.scala
+++ b/test/files/pos/bug115.scala
@@ -3,7 +3,7 @@ class S[A](f: A => A, x: A) {
}
class T[B](f: B => B, y: B) extends S(x: B => f(x), y) {
}
-object Test with Application {
+object Test extends Application {
new T[Int](x => x * 2, 1);
val f = new S(x: Int => x, 1);
}
diff --git a/test/files/pos/bug159.scala b/test/files/pos/bug159.scala
index d6cdb97b47..ef6eba5255 100644
--- a/test/files/pos/bug159.scala
+++ b/test/files/pos/bug159.scala
@@ -3,7 +3,7 @@ object foo {
// the problem seems to appear only
// if "val _" is in the body of a case
def cooked( ckd:StringBuffer ):Unit =
- 'a'.match {
+ 'a' match {
case '-' =>
val _ = ckd.append( '_' );
case 'v' =>
@@ -13,7 +13,7 @@ object foo {
}
object foo1 {
def f():Unit = {
- 1.match {
+ 1 match {
case 2 => val _ = 1;
case 3 => val _ = 2;
case 4 => val _ = 2;
diff --git a/test/files/pos/bug211.scala b/test/files/pos/bug211.scala
index 6c5b73ec4a..8c5cf1dc1e 100644
--- a/test/files/pos/bug211.scala
+++ b/test/files/pos/bug211.scala
@@ -1,7 +1,7 @@
trait A;
trait B;
class Foo: (A with B) extends A with B;
-object Test with Application {
+object Test extends Application {
new Foo();
System.out.println("bug211 completed");
}
diff --git a/test/files/pos/bug245.scala b/test/files/pos/bug245.scala
index 3e5dee820b..b33dd9914f 100644
--- a/test/files/pos/bug245.scala
+++ b/test/files/pos/bug245.scala
@@ -1,9 +1,9 @@
-class Value {
- def coerce: Int = 0;
-}
+class Value {}
object Test {
+ implicit def view(v: Value): int = 0;
+
def foo(i: Int): Int = 0;
def fun0 : Value = null;
diff --git a/test/files/pos/bug267.scala b/test/files/pos/bug267.scala
index 3c220e5df1..d99b1fa1fc 100644
--- a/test/files/pos/bug267.scala
+++ b/test/files/pos/bug267.scala
@@ -17,7 +17,7 @@ trait Base {
}
}
-object testBase extends Base with Application {
+object testBase extends Application with Base {
type exp = Exp;
val term = new Num(2);
System.out.println(term.eval);
@@ -41,7 +41,7 @@ trait Show extends Base {
trait Exp1 extends Exp {
def show: String;
}
- class Num1(v: int): exp extends Num(v) with Exp1 {
+ class Num1(v: int): (exp with Num1) extends Num(v) with Exp1 {
def show = value.toString();
}
}
@@ -49,7 +49,7 @@ trait Show extends Base {
/** Operation extension: An extension of `BasePlus' with 'show' methods.
*/
trait ShowPlus extends BasePlus with Show {
- class Plus1(l: exp, r: exp): exp extends Plus(l, r) with Exp1 {
+ class Plus1(l: exp, r: exp): (exp with Plus1) extends Plus(l, r) with Exp1 {
def show = left.show + " + " + right.show
}
}
diff --git a/test/files/pos/bug289.scala b/test/files/pos/bug289.scala
index 18b4e74294..2fb91510d2 100644
--- a/test/files/pos/bug289.scala
+++ b/test/files/pos/bug289.scala
@@ -4,4 +4,4 @@ class A {
object B;
}
-object C with A;
+object C extends A;
diff --git a/test/files/pos/bug342.scala b/test/files/pos/bug342.scala
index f7e318e0a8..2e72ef220b 100644
--- a/test/files/pos/bug342.scala
+++ b/test/files/pos/bug342.scala
@@ -1,4 +1,4 @@
-object Main with Application {
+object Main extends Application {
//object Foo extends Enumeration { // 1: OK !
object Foo extends Enumeration(0, "Bar") { // 2
diff --git a/test/files/pos/bug348plus.scala b/test/files/pos/bug348plus.scala
new file mode 100755
index 0000000000..45f49a33fe
--- /dev/null
+++ b/test/files/pos/bug348plus.scala
@@ -0,0 +1,23 @@
+// bug #348
+trait Foo {
+ type bar <: this.Bar;
+ abstract class Bar;
+ case class Baz(r:bar) extends this.Bar;
+ case object NoBar extends this.Bar;
+}
+object Test extends Application {
+ object ConcreteFooBar extends Foo { // if moved to toplevel, it works
+ type bar = Bar;
+ }
+ def foo = {
+ import ConcreteFooBar._ ;
+ Baz( NoBar )
+ }
+}
+
+// bug #367
+
+object Bla {
+ def foo(): Unit = (return null).equals(null);
+}
+
diff --git a/test/files/pos/bug360.scala b/test/files/pos/bug360.scala
index 53af1e8a1c..0fcb5cb161 100644
--- a/test/files/pos/bug360.scala
+++ b/test/files/pos/bug360.scala
@@ -3,7 +3,7 @@
abstract class Bug360A: Bug360C {
def f: String = "hello";
}
-abstract class Bug360B: Bug360C {
+trait Bug360B: Bug360C {
object d {
System.out.println(f);
}
diff --git a/test/files/pos/bug361.scala b/test/files/pos/bug361.scala
index 61de238f8b..f48c906246 100644
--- a/test/files/pos/bug361.scala
+++ b/test/files/pos/bug361.scala
@@ -1,6 +1,6 @@
// $Id$
-class Bug361Global with Bug361Trees;
+class Bug361Global extends Bug361Trees;
abstract class Bug361Trees: Bug361Global {
diff --git a/test/files/pos/bug91.scala b/test/files/pos/bug91.scala
index e05365caf4..54c821b41c 100644
--- a/test/files/pos/bug91.scala
+++ b/test/files/pos/bug91.scala
@@ -1,6 +1,6 @@
class Bug {
def main(args: Array[String]) = {
- var msg: String = _; // no bug if "null" instead of "_"
+ var msg: String = null; // no bug if "null" instead of "_"
val f: PartialFunction[Any, unit] = { case 42 => msg = "coucou" };
}
}
diff --git a/test/files/pos/compile.scala b/test/files/pos/compile.scala
index 3979c9737a..f7ada3193c 100644
--- a/test/files/pos/compile.scala
+++ b/test/files/pos/compile.scala
@@ -138,7 +138,7 @@ trait Test3A[T] {
def fun: T = fun;
}
-class Test3B with Test3A[Test3Foo];
+class Test3B extends Test3A[Test3Foo];
trait Test3M extends Test3A[Test3Foo] {
override def fun: Test3Foo = super.fun;
diff --git a/test/files/pos/constfold.scala b/test/files/pos/constfold.scala
index ef71285f72..2eb31b4086 100644
--- a/test/files/pos/constfold.scala
+++ b/test/files/pos/constfold.scala
@@ -5,7 +5,7 @@ object A {
val s = "z is " + z;
}
-object Test with Application {
+object Test extends Application {
System.out.println(A.x);
System.out.println(A.y);
diff --git a/test/files/pos/failed.lst b/test/files/pos/failed.lst
new file mode 100755
index 0000000000..b5b75eb35c
--- /dev/null
+++ b/test/files/pos/failed.lst
@@ -0,0 +1,3 @@
+bug123.scala
+exceptions.scala
+context.scala
diff --git a/test/files/pos/gui.scala b/test/files/pos/gui.scala
index 27863f7368..b40759fb01 100644
--- a/test/files/pos/gui.scala
+++ b/test/files/pos/gui.scala
@@ -49,7 +49,7 @@ object GUI {
def enable(b: Boolean): this.type;
}
- trait MouseCtl with Ctl {
+ trait MouseCtl extends Ctl {
def mouseDown(p: Geom.Point): unit;
}
diff --git a/test/files/pos/matthias4.scala b/test/files/pos/matthias4.scala
index bcda93746b..c6ce79d682 100644
--- a/test/files/pos/matthias4.scala
+++ b/test/files/pos/matthias4.scala
@@ -29,7 +29,7 @@ trait _a extends Object with _b {
def setX(x: B.X): Unit;
}
}
-abstract class a123() extends Object with _a with _b {
+trait a123 extends Object with _a with _b {
val a: this.type = this;
val A: A = new A();
class A() extends AObject {
@@ -67,13 +67,13 @@ trait _m {
abstract class m() extends Object with _m with _b {
val m: this.type = this;
val M: M = new M();
- class M() extends MObject with a123() with Linker() {
+ class M() extends MObject with a123 with Linker {
def test() = {
val x: B.X = B.getX();
A.setX(x);
}
}
- abstract class Linker() {
+ trait Linker {
val b: m.this.b.type = m.this.b;
val B: m.this.B.type = m.this.B;
type B = m.this.B;
diff --git a/test/files/pos/michel1.scala b/test/files/pos/michel1.scala
index 2fc409b4e5..f930a682ef 100644
--- a/test/files/pos/michel1.scala
+++ b/test/files/pos/michel1.scala
@@ -4,6 +4,6 @@ class A[Ta] (a : Ta) {
trait C {}
-class B[Tb] (b : Tb) extends C with A[Tb] (b) {
+class B[Tb] (b : Tb) extends A[Tb] (b) with C {
def g = 2
}
diff --git a/test/files/pos/mixins.scala b/test/files/pos/mixins.scala
index 8d7e7dfa52..2b403a25e8 100644
--- a/test/files/pos/mixins.scala
+++ b/test/files/pos/mixins.scala
@@ -2,16 +2,21 @@ package mixins;
abstract class Super {
def foo: int;
}
-abstract class Mixin extends Super {
+trait Mixin extends Super {
abstract override def foo = super.foo;
}
-class Sub extends Super with Mixin {
- override def foo: int = 1;
+trait MixinSub extends Super with Mixin {
+ abstract override def foo: int = super.foo;
}
-abstract class Mixin1 extends Mixin {
+trait MixinSubSub extends MixinSub {
abstract override def foo = super.foo;
}
-abstract class Base0 extends Super with Mixin {
+class Sub extends Super {
+ def foo: int = 1
}
-class Base extends Sub with Mixin1 {
+class Base extends Sub with MixinSubSub {
+ override def foo = super.foo;
}
+trait Mixin1 extends Sub with MixinSubSub {}
+class Base1 extends Mixin1 {}
+
diff --git a/test/files/pos/nested.scala b/test/files/pos/nested.scala
index e81b710d72..b038fce39d 100644
--- a/test/files/pos/nested.scala
+++ b/test/files/pos/nested.scala
@@ -12,11 +12,13 @@ class A(pa : Int) {
}
}
-class M(x : Int) {
+trait M {
+ val x : Int;
def m1 = x
}
-class A1(x : Int) extends A(x) with M(x) {
+class A1(x0 : Int) extends A(x0) with M {
+ val x = x0;
class D() extends B(42) {
val c2 = new C(66);
class E() extends C(5) {
diff --git a/test/files/pos/ok.lst b/test/files/pos/ok.lst
new file mode 100755
index 0000000000..14184a7129
--- /dev/null
+++ b/test/files/pos/ok.lst
@@ -0,0 +1,138 @@
+304.scala
+A.scala
+List1.scala
+MailBox.scala
+S1.scala
+S3.scala
+S5.scala
+S8.scala
+X.scala
+Z.scala
+abstract.scala
+aliases.scala
+arrays2.scala
+attributes.scala
+bug082.scala
+bug1.scala
+bug115.scala
+bug116.scala
+bug119.scala
+bug121.scala
+bug124.scala
+bug151.scala
+bug159.scala
+bug160.scala
+bug17.scala
+bug175.scala
+bug177.scala
+bug183.scala
+bug193.scala
+bug2.scala
+bug20.scala
+bug201.scala
+bug204.scala
+bug210.scala
+bug211.scala
+bug229.scala
+bug245.scala
+bug267.scala
+bug287.scala
+bug289.scala
+bug29.scala
+bug295.scala
+bug30.scala
+bug304.scala
+bug31.scala
+bug318.scala
+bug32.scala
+bug342.scala
+bug348plus.scala
+bug359.scala
+bug36.scala
+bug360.scala
+bug361.scala
+bug372.scala
+bug39.scala
+bug49.scala
+bug53.scala
+bug54.scala
+bug61.scala
+bug64.scala
+bug66.scala
+bug68.scala
+bug69.scala
+bug76.scala
+bug81.scala
+bug91.scala
+bug93.scala
+cls.scala
+cls1.scala
+clsrefine.scala
+compile.scala
+compound.scala
+constfold.scala
+eta.scala
+expressions-current.scala
+gui.scala
+imports.scala
+infer.scala
+infer2.scala
+lambda.scala
+lambdalift.scala
+lambdalift1.scala
+localmodules.scala
+matthias1.scala
+matthias3.scala
+matthias4.scala
+matthias5.scala
+maxim1.scala
+michel1.scala
+michel2.scala
+michel3.scala
+michel4.scala
+michel5.scala
+michel6.scala
+mixins.scala
+modules.scala
+modules1.scala
+moduletrans.scala
+nested.scala
+null.scala
+orderedpoints.scala
+override.scala
+partialfun.scala
+patterns.scala
+patterns1.scala
+patterns2.scala
+patterns3.scala
+philippe1.scala
+philippe2.scala
+philippe3.scala
+philippe4.scala
+pmbug.scala
+propagate.scala
+rebind.scala
+refine.scala
+reftest.scala
+scoping1.scala
+scoping2.scala
+scoping3.scala
+seqtest2.scala
+simplelists.scala
+stable.scala
+strings.scala
+test1.scala
+test2.scala
+test4.scala
+test4a.scala
+test4refine.scala
+test5.scala
+test5refine.scala
+testcast.scala
+thistype.scala
+thistypes.scala
+traits.scala
+valdefs.scala
+viewtest1.scala
+viewtest2.scala
+viewtest3.scala
diff --git a/test/files/pos/orderedpoints.scala b/test/files/pos/orderedpoints.scala
index 466ada1363..7e56a663fe 100755
--- a/test/files/pos/orderedpoints.scala
+++ b/test/files/pos/orderedpoints.scala
@@ -1,3 +1,5 @@
+package test;
+
class Point1(x: int) extends Object with Ordered[Point1] {
val xCoord = x;
def compareTo [b >: Point1 <% Ordered[b]](that: b): int = that match {
@@ -5,7 +7,8 @@ class Point1(x: int) extends Object with Ordered[Point1] {
case _ => -that.compareTo(this)
}
}
-class Point2(x: int, y: int) extends Point1(x) with Ordered[Point2] {
+class Point2(x: int, y: int) extends Point1(x) with Ordered[Point2] {}
+/*
val yCoord = y;
override def compareTo [b >: Point2 <% Ordered[b]](that: b): int = that match {
case that1: Point2 =>
@@ -14,7 +17,7 @@ class Point2(x: int, y: int) extends Point1(x) with Ordered[Point2] {
case _ => -that.compareTo(this)
}
}
-object Test with Application {
+object Test extends Application {
val p1 = new Point1(1);
val q1 = new Point1(2);
System.out.println(p1 < q1);
@@ -24,3 +27,4 @@ object Test with Application {
System.out.println(p1 < q2);
System.out.println(p2 < q1);
}
+*/
diff --git a/test/files/pos/rebind.scala b/test/files/pos/rebind.scala
index 59afe82ffa..3b7b27ac34 100644
--- a/test/files/pos/rebind.scala
+++ b/test/files/pos/rebind.scala
@@ -4,7 +4,7 @@ abstract class Foo {
}
def foo: Inner;
}
-abstract class Bar {
+trait Bar {
type Inner;
def foo: Inner = foo;
}
diff --git a/test/files/pos/scoping1.scala b/test/files/pos/scoping1.scala
index c9bc14b563..23daf024fe 100644
--- a/test/files/pos/scoping1.scala
+++ b/test/files/pos/scoping1.scala
@@ -1,4 +1,4 @@
-object This with Application {
+object This extends Application {
trait A {
def foo(): unit;
}
diff --git a/test/files/pos/testcast.scala b/test/files/pos/testcast.scala
index 15aa01ba72..631b2c922b 100644
--- a/test/files/pos/testcast.scala
+++ b/test/files/pos/testcast.scala
@@ -15,7 +15,7 @@ class B1 {
}
object C {
- def view(x: A): B1 = null;
+ implicit def view(x: A): B1 = null;
}
object Test {
import C.view;
diff --git a/test/files/pos/viewtest1.scala b/test/files/pos/viewtest1.scala
index e908e2acb9..0a59fdad58 100755
--- a/test/files/pos/viewtest1.scala
+++ b/test/files/pos/viewtest1.scala
@@ -5,13 +5,13 @@ trait Ordered[a] {
}
object O {
- def view (x: String): Ordered[String] = new Ordered[String] {
+ implicit def view (x: String): Ordered[String] = new Ordered[String] {
def < (y: String) = x.compareTo(y) < 0;
}
}
object Empty extends Tree[All];
-case class Node[+c <% Ordered[c]](elem: c, l: Tree[c], r: Tree[c]) extends Tree[c];
+case class Node[c <% Ordered[c]](elem: c, l: Tree[c], r: Tree[c]) extends Tree[c];
trait Tree[+a <% Ordered[a]] {
def insert[b >: a <% Ordered[b]](x: b): Tree[b] = this match {
diff --git a/test/files/pos/viewtest2.scala b/test/files/pos/viewtest2.scala
index 0d580418d0..1958696c1f 100755
--- a/test/files/pos/viewtest2.scala
+++ b/test/files/pos/viewtest2.scala
@@ -24,20 +24,20 @@ trait Ordered[+a] {
object O {
- def view (x: String): Ordered[String] = new Ordered[String] {
+ implicit def view1(x: String): Ordered[String] = new Ordered[String] {
def compareTo [b >: String <% Ordered[b]](y: b): int = y match {
case y1: String => x compareTo y1;
case _ => -(y compareTo x)
}
}
- def view (x: char): Ordered[char] = new Ordered[char] {
+ implicit def view2(x: char): Ordered[char] = new Ordered[char] {
def compareTo [b >: char <% Ordered[b]](y: b): int = y match {
case y1: char => x - y1;
case _ => -(y compareTo x)
}
}
- def view[a <% Ordered[a]](x: List[a]): Ordered[List[a]] =
+ implicit def view3[a <% Ordered[a]](x: List[a]): Ordered[List[a]] =
new Ordered[List[a]] {
def compareTo [b >: List[a] <% Ordered[b]](y: b): int = y match {
case y1: List[a] => compareLists(x, y1);
@@ -54,6 +54,8 @@ object O {
}
}
}
+
+ implicit def view4[a](x: a): a = x;
}
trait Tree[+a <% Ordered[a]] {
@@ -66,7 +68,7 @@ object Empty extends Tree[All] {
def elements: List[All] = List();
}
-class Node[+a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] {
+class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] {
def insert[b >: a <% Ordered[b]](x: b): Tree[b] =
if (x == elem) this
else if (x < elem) new Node(elem, l insert x, r)
@@ -83,7 +85,7 @@ case class Str(elem: String) extends Ordered[Str] {
}
object Test {
- import O.view;
+ import O._;
private def toCharList(s: String): List[Char] =
if (s.length() == 0) List()
diff --git a/test/files/pos/viewtest3.scala b/test/files/pos/viewtest3.scala
index dfed0dbf52..89e32e48a8 100644
--- a/test/files/pos/viewtest3.scala
+++ b/test/files/pos/viewtest3.scala
@@ -10,7 +10,7 @@ object Empty extends Tree[All] {
def elements: List[All] = List();
}
-class Node[+a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] {
+class Node[a <% Ordered[a]](elem: a, l: Tree[a], r: Tree[a]) extends Tree[a] {
def insert[b >: a <% Ordered[b]](x: b): Tree[b] =
if (x == elem) this
else if (x < elem) new Node(elem, l insert x, r)