summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-08 20:11:41 +0000
committerPaul Phillips <paulp@improving.org>2010-11-08 20:11:41 +0000
commitb2559b3cf4516f751ad050480c50e348e03952d7 (patch)
treefd4859c561a1abacb572cf1ee4162b5f2349c53b /src/compiler/scala/tools
parent71f765bc4f9ef4599855a7550dd79347c4c578ba (diff)
downloadscala-b2559b3cf4516f751ad050480c50e348e03952d7.tar.gz
scala-b2559b3cf4516f751ad050480c50e348e03952d7.tar.bz2
scala-b2559b3cf4516f751ad050480c50e348e03952d7.zip
Deprecation patrol.
the same issues as JavaConversions with respect to overloading implicit methods making them inaccessible to view bounds. Fixed JavaConverters. Added a warning for when people overload parameterized implicits: in almost all cases the name is irrelevant so there's little point in unwittingly suffering degraded functionality. No review.
Diffstat (limited to 'src/compiler/scala/tools')
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala8
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
10 files changed, 25 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 073bebad04..2acfa20c50 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -378,7 +378,7 @@ abstract class TreeGen {
if (treeInfo.isPureExpr(expr)) {
within(() => if (used) expr.duplicate else { used = true; expr })
} else {
- val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName(expr.pos, "ev$"))
+ val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName("ev$"))
.setFlag(SYNTHETIC).setInfo(expr.tpe)
val containing = within(() => Ident(temp) setPos temp.pos.focus setType expr.tpe)
ensureNonOverlapping(containing, List(expr))
@@ -398,7 +398,7 @@ abstract class TreeGen {
() => if (used(idx)) expr.duplicate else { used(idx) = true; expr }
}
} else {
- val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName(expr.pos, "ev$"))
+ val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName("ev$"))
.setFlag(SYNTHETIC).setInfo(expr.tpe)
vdefs += ValDef(temp, expr)
exprs1 += (() => Ident(temp) setPos temp.pos.focus setType expr.tpe)
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index d68b678610..ca9ab7007c 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1771,7 +1771,7 @@ abstract class GenICode extends SubComponent {
val sym = t.symbol
def getLabel(pos: Position, name: Name) =
labels.getOrElseUpdate(sym,
- method.newLabel(sym.pos, unit.fresh.newName(pos, name.toString)) setInfo sym.tpe
+ method.newLabel(sym.pos, unit.fresh.newName(name.toString)) setInfo sym.tpe
)
t match {
@@ -2028,7 +2028,7 @@ abstract class GenICode extends SubComponent {
/** Make a fresh local variable. It ensures the 'name' is unique. */
def makeLocal(pos: Position, tpe: Type, name: String): Local = {
- val sym = method.symbol.newVariable(pos, unit.fresh.newName(pos, name))
+ val sym = method.symbol.newVariable(pos, unit.fresh.newName(name))
.setInfo(tpe)
.setFlag(Flags.SYNTHETIC)
this.method.addLocal(new Local(sym, toTypeKind(tpe), false))
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index af41bb97e9..73886420c1 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -92,8 +92,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
* type variable. */
case ad@ApplyDynamic(qual0, params) =>
def mkName(s: String = "") =
- if (s == "") unit.fresh newName ad.pos
- else unit.fresh.newName(ad.pos, s)
+ if (s == "") unit.fresh.newName()
+ else unit.fresh.newName(s)
def mkTerm(s: String = "") = newTermName(mkName(s))
val typedPos = typedWithPos(ad.pos) _
@@ -553,7 +553,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
case theTry @ Try(block, catches, finalizer)
if theTry.tpe.typeSymbol != definitions.UnitClass && theTry.tpe.typeSymbol != definitions.NothingClass =>
val tpe = theTry.tpe.widen
- val tempVar = currentOwner.newVariable(theTry.pos, unit.fresh.newName(theTry.pos, nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe)
+ val tempVar = currentOwner.newVariable(theTry.pos, unit.fresh.newName(nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe)
def assignBlock(rhs: Tree) = super.transform(BLOCK(Ident(tempVar) === transform(rhs)))
val newBlock = assignBlock(block)
@@ -627,7 +627,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
*/
private def getSymbolStaticField(pos: Position, symname: String, rhs: Tree, tree: Tree): Symbol =
symbolsStoredAsStatic.getOrElseUpdate(symname, {
- val freshname = unit.fresh.newName(pos, "symbol$")
+ val freshname = unit.fresh.newName("symbol$")
val theTyper = typer.atOwner(tree, currentClass)
// create a symbol for the static field
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index 9f6117dcf1..7a25df6dc3 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -353,7 +353,7 @@ abstract class ExplicitOuter extends InfoTransform
var nselector = transform(selector)
def makeGuardDef(vs: List[Symbol], guard: Tree) = {
- val gdname = unit.fresh.newName(guard.pos, "gd")
+ val gdname = unit.fresh.newName("gd")
val method = currentOwner.newMethod(tree.pos, gdname) setFlag SYNTHETIC
val fmls = vs map (_.tpe)
val tpe = new MethodType(method newSyntheticValueParams fmls, BooleanClass.tpe)
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index e3f1427360..b32f0ed6bf 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -254,7 +254,7 @@ abstract class LambdaLift extends InfoTransform {
sym.owner.name + "$"
else ""
)
- val fresh = unit.fresh.newName(sym.pos, base)
+ val fresh = unit.fresh.newName(base)
sym.name = if (sym.name.isTypeName) fresh.toTypeName else fresh
if (settings.debug.value) log("renamed: " + sym.name)
}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 45fbf7b708..eaaff2d2de 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -206,7 +206,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
/** Return non-local return key for given method */
private def nonLocalReturnKey(meth: Symbol) =
nonLocalReturnKeys.getOrElseUpdate(meth, {
- meth.newValue(meth.pos, unit.fresh.newName(meth.pos, "nonLocalReturnKey"))
+ meth.newValue(meth.pos, unit.fresh.newName("nonLocalReturnKey"))
.setFlag (SYNTHETIC)
.setInfo (ObjectClass.tpe)
})
@@ -500,7 +500,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
def liftTree(tree: Tree) = {
if (settings.debug.value)
log("lifting tree at: " + (tree.pos))
- val sym = currentOwner.newMethod(tree.pos, unit.fresh.newName(tree.pos, "liftedTree"))
+ val sym = currentOwner.newMethod(tree.pos, unit.fresh.newName("liftedTree"))
sym.setInfo(MethodType(List(), tree.tpe))
new ChangeOwnerTraverser(currentOwner, sym).traverse(tree)
localTyper.typed {
@@ -654,7 +654,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
case Try(body, catches, finalizer) =>
if (catches forall treeInfo.isCatchCase) tree
else {
- val exname = unit.fresh.newName(tree.pos, "ex$")
+ val exname = unit.fresh.newName("ex$")
val cases =
if ((catches exists treeInfo.isDefaultCase) || (catches.last match { // bq: handle try { } catch { ... case ex:Throwable => ...}
case CaseDef(Typed(Ident(nme.WILDCARD), tpt), EmptyTree, _) if (tpt.tpe =:= ThrowableClass.tpe) =>
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 151a851f23..9ad7776898 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -148,7 +148,7 @@ trait NamesDefaults { self: Analyzer =>
// never used for constructor calls, they always have a stable qualifier
def blockWithQualifier(qual: Tree, selected: Name) = {
- val sym = blockTyper.context.owner.newValue(qual.pos, unit.fresh.newName(qual.pos, "qual$"))
+ val sym = blockTyper.context.owner.newValue(qual.pos, unit.fresh.newName("qual$"))
.setInfo(qual.tpe)
blockTyper.context.scope.enter(sym)
val vd = atPos(sym.pos)(ValDef(sym, qual).setType(NoType))
@@ -258,7 +258,7 @@ trait NamesDefaults { self: Analyzer =>
case _ =>
(seqType(arg.tpe), true)
} else (arg.tpe, false)
- val s = context.owner.newValue(arg.pos, unit.fresh.newName(arg.pos, "x$"))
+ val s = context.owner.newValue(arg.pos, unit.fresh.newName("x$"))
val valType = if (byName) functionType(List(), argTpe)
else if (repeated) argTpe
else argTpe
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index c49acf3f01..b524f2e99a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -96,7 +96,7 @@ abstract class RefChecks extends InfoTransform {
var checkedCombinations = Set[List[Type]]()
// only one overloaded alternative is allowed to define default arguments
- private def checkDefaultsInOverloaded(clazz: Symbol) {
+ private def checkOverloadedRestrictions(clazz: Symbol) {
def check(members: List[Symbol]): Unit = members match {
case x :: xs =>
if (x.hasParamWhich(_.hasDefaultFlag) && !nme.isProtectedAccessorName(x.name)) {
@@ -116,6 +116,11 @@ abstract class RefChecks extends InfoTransform {
check(xs)
case _ => ()
}
+ clazz.info.decls filter (x => x.isImplicit && x.typeParams.nonEmpty) foreach { sym =>
+ val alts = clazz.info.decl(sym.name).alternatives
+ if (alts.size > 1)
+ alts foreach (x => unit.warning(x.pos, "parameterized overloaded implicit methods are not visible as view bounds"))
+ }
check(clazz.info.members)
}
@@ -1293,7 +1298,7 @@ abstract class RefChecks extends InfoTransform {
case Template(parents, self, body) =>
localTyper = localTyper.atOwner(tree, currentOwner)
validateBaseTypes(currentOwner)
- checkDefaultsInOverloaded(currentOwner)
+ checkOverloadedRestrictions(currentOwner)
val bridges = addVarargBridges(currentOwner)
checkAllOverrides(currentOwner)
diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
index 545aab4c79..d4cb11b122 100644
--- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala
@@ -182,7 +182,7 @@ trait SyntheticMethods extends ast.TreeDSL {
// returns (Apply, Bind)
def makeTrees(acc: Symbol, cpt: Type): (Tree, Bind) = {
- val varName = context.unit.fresh.newName(clazz.pos.focus, acc.name + "$")
+ val varName = context.unit.fresh.newName(acc.name + "$")
val isRepeated = isRepeatedParamType(cpt)
val binding = if (isRepeated) Star(WILD()) else WILD()
val eqMethod: Tree =
@@ -221,7 +221,7 @@ trait SyntheticMethods extends ast.TreeDSL {
def newAccessorMethod(tree: Tree): Tree = tree match {
case DefDef(_, _, _, _, _, rhs) =>
var newAcc = tree.symbol.cloneSymbol
- newAcc.name = context.unit.fresh.newName(tree.symbol.pos.focus, tree.symbol.name + "$")
+ newAcc.name = context.unit.fresh.newName(tree.symbol.name + "$")
newAcc setFlag SYNTHETIC resetFlag (ACCESSOR | PARAMACCESSOR | PRIVATE | PROTECTED)
newAcc.privateWithin = NoSymbol
newAcc = newAcc.owner.info.decls enter newAcc
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 6911d226bf..3d3fbae811 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3916,7 +3916,7 @@ trait Typers { self: Analyzer =>
val params = for (i <- List.range(0, arity)) yield
atPos(tree.pos.focusStart) {
ValDef(Modifiers(PARAM | SYNTHETIC),
- unit.fresh.newName(tree.pos, "x" + i + "$"), TypeTree(), EmptyTree)
+ unit.fresh.newName("x" + i + "$"), TypeTree(), EmptyTree)
}
val ids = for (p <- params) yield Ident(p.name)
val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) }