diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-14 07:18:12 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-14 10:12:06 -0700 |
commit | 55b609458fd14de248c21132a3e4a4672de4ce4b (patch) | |
tree | 6db61304dacb4f59fb53859e7ef0afc6e937e9ff /src/compiler/scala/tools/cmd | |
parent | f68201c469725c255ae2786f0ac1e37bc5f30a7a (diff) | |
download | scala-55b609458fd14de248c21132a3e4a4672de4ce4b.tar.gz scala-55b609458fd14de248c21132a3e4a4672de4ce4b.tar.bz2 scala-55b609458fd14de248c21132a3e4a4672de4ce4b.zip |
Eliminate breaking relative names in source.
These things are killing me. Constructions like
package scala.foo.bar.baz
import foo.Other
DO NOT WORK in general. Such files are not really in the
"scala" package, because it is not declared
package scala
package foo.bar.baz
And there is a second problem: using a relative path name means
compilation will fail in the presence of a directory of the same
name, e.g.
% mkdir reflect
% scalac src/reflect/scala/reflect/internal/util/Position.scala
src/reflect/scala/reflect/internal/util/Position.scala:9: error:
object ClassTag is not a member of package reflect
import reflect.ClassTag
^
src/reflect/scala/reflect/internal/util/Position.scala:10: error:
object base is not a member of package reflect
import reflect.base.Attachments
^
As a rule, do not use relative package paths unless you have
explicitly imported the path to which you think you are relative.
Better yet, don't use them at all. Unfortunately they mostly work
because scala variously thinks everything scala.* is in the scala
package and/or because you usually aren't bootstrapping and it
falls through to an existing version of the class already on the
classpath.
Making the paths explicit is not a complete solution -
in particular, we remain enormously vulnerable to any directory
or package called "scala" which isn't ours - but it greatly
limts the severity of the problem.
Diffstat (limited to 'src/compiler/scala/tools/cmd')
-rw-r--r-- | src/compiler/scala/tools/cmd/Property.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/cmd/Reference.scala | 2 | ||||
-rw-r--r-- | src/compiler/scala/tools/cmd/gen/AnyVals.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/cmd/gen/Codegen.scala | 2 |
4 files changed, 7 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/cmd/Property.scala b/src/compiler/scala/tools/cmd/Property.scala index aae5bebcc8..bde7bb8cb8 100644 --- a/src/compiler/scala/tools/cmd/Property.scala +++ b/src/compiler/scala/tools/cmd/Property.scala @@ -64,7 +64,7 @@ trait Property extends Reference { propertiesToOptions(loadProperties(file)) def propertiesToOptions(props: java.util.Properties): List[String] = { - import collection.JavaConversions._ + import scala.collection.JavaConversions._ propertiesToOptions(props.toList) } def propertiesToOptions(props: List[(String, String)]) = props flatMap propMapper diff --git a/src/compiler/scala/tools/cmd/Reference.scala b/src/compiler/scala/tools/cmd/Reference.scala index 77fe01051e..b6c564e9fb 100644 --- a/src/compiler/scala/tools/cmd/Reference.scala +++ b/src/compiler/scala/tools/cmd/Reference.scala @@ -6,7 +6,7 @@ package scala.tools package cmd -import collection.mutable.ListBuffer +import scala.collection.mutable.ListBuffer import nsc.Properties.envOrNone /** Mixes in the specification trait and uses the vals therein to diff --git a/src/compiler/scala/tools/cmd/gen/AnyVals.scala b/src/compiler/scala/tools/cmd/gen/AnyVals.scala index 7842603af7..910804245b 100644 --- a/src/compiler/scala/tools/cmd/gen/AnyVals.scala +++ b/src/compiler/scala/tools/cmd/gen/AnyVals.scala @@ -14,7 +14,7 @@ trait AnyValReps { sealed abstract class AnyValNum(name: String, repr: Option[String], javaEquiv: String) extends AnyValRep(name,repr,javaEquiv) { case class Op(val op : String, val doc : String) - + private def companionCoercions(tos: AnyValRep*) = { tos.toList map (to => """implicit def @javaequiv@2%s(x: @name@): %s = x.to%s""".format(to.javaEquiv, to.name, to.name) @@ -24,7 +24,7 @@ trait AnyValReps { def coercionComment = """ /** Language mandated coercions from @name@ to "wider" types.%s */""".format(coercionCommentExtra) - + def implicitCoercions: List[String] = { val coercions = this match { case B => companionCoercions(S, I, L, F, D) @@ -247,7 +247,7 @@ trait AnyValReps { def classDoc = interpolate(classDocTemplate) def objectDoc = "" def mkImports = "" - + def mkClass = assemble("final abstract class " + name + " private extends AnyVal", classLines) def mkObject = assemble("object " + name + " extends AnyValCompanion", objectLines) def make() = List[String]( @@ -281,7 +281,7 @@ trait AnyValTemplates { %s package scala -import language.implicitConversions +import scala.language.implicitConversions """.trim.format(timestampString) + "\n\n") diff --git a/src/compiler/scala/tools/cmd/gen/Codegen.scala b/src/compiler/scala/tools/cmd/gen/Codegen.scala index b94c640f1c..ff3d41c8b7 100644 --- a/src/compiler/scala/tools/cmd/gen/Codegen.scala +++ b/src/compiler/scala/tools/cmd/gen/Codegen.scala @@ -6,7 +6,7 @@ package scala.tools.cmd package gen -import language.postfixOps +import scala.language.postfixOps class Codegen(args: List[String]) extends { val parsed = CodegenSpec(args: _*) |