diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-03 10:15:10 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-03 11:36:37 -0700 |
commit | 80ac7d006350c0d60ff1b293ee955c3435288a9e (patch) | |
tree | 1cb3f2dfbec47cb1a966b7bc459907a14f937f1b /src/compiler/scala/tools/nsc/typechecker | |
parent | 6eb33d4ad15ae3548c21535de652ea246582a44f (diff) | |
download | scala-80ac7d006350c0d60ff1b293ee955c3435288a9e.tar.gz scala-80ac7d006350c0d60ff1b293ee955c3435288a9e.tar.bz2 scala-80ac7d006350c0d60ff1b293ee955c3435288a9e.zip |
Absolutized paths involving the scala package.
Confusing, now-it-happens now-it-doesn't mysteries lurk
in the darkness. When scala packages are declared like this:
package scala.collection.mutable
Then paths relative to scala can easily be broken via the unlucky
presence of an empty (or nonempty) directory. Example:
// a.scala
package scala.foo
class Bar { new util.Random }
% scalac ./a.scala
% mkdir util
% scalac ./a.scala
./a.scala:4: error: type Random is not a member of package util
new util.Random
^
one error found
There are two ways to play defense against this:
- don't use relative paths; okay sometimes, less so others
- don't "opt out" of the scala package
This commit mostly pursues the latter, with occasional doses
of the former.
I created a scratch directory containing these empty directories:
actors annotation ant api asm beans cmd collection compat
concurrent control convert docutil dtd duration event factory
forkjoin generic hashing immutable impl include internal io
logging macros man1 matching math meta model mutable nsc parallel
parsing partest persistent process pull ref reflect reify remote
runtime scalap scheduler script swing sys text threadpool tools
transform unchecked util xml
I stopped when I could compile the main src directories
even with all those empties on my classpath.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
4 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala index 65bfd8e34e..56ed0ee16c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ConstantFolder.scala @@ -3,7 +3,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package typechecker import java.lang.ArithmeticException diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 875aa5a9d3..2ad4ec43f7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -8,7 +8,8 @@ //todo: disallow C#D in superclass //todo: treat :::= correctly -package scala.tools.nsc +package scala +package tools.nsc package typechecker import scala.annotation.tailrec @@ -167,7 +168,7 @@ trait Implicits { override def isFailure = true override def isDivergent = true } - + lazy val AmbiguousSearchFailure = new SearchResult(EmptyTree, EmptyTreeTypeSubstituter) { override def isFailure = true override def isAmbiguousFailure = true @@ -799,16 +800,16 @@ trait Implicits { // Initially null, will be saved on first diverging expansion. private var implicitSym: Symbol = _ private var countdown: Int = 1 - + def sym: Symbol = implicitSym - def apply(search: SearchResult, i: ImplicitInfo): SearchResult = + def apply(search: SearchResult, i: ImplicitInfo): SearchResult = if (search.isDivergent && countdown > 0) { countdown -= 1 implicitSym = i.sym log("discarding divergent implicit ${implicitSym} during implicit search") SearchFailure } else search - } + } /** Sorted list of eligible implicits. */ diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index 75aa4c46e2..3f7e6d7665 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -4,7 +4,8 @@ * @author Martin Odersky */ -package scala.tools.nsc +package scala +package tools.nsc package typechecker import scala.collection.{ mutable, immutable } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index f501ff468d..001808e6bc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -9,7 +9,8 @@ // Added: Thu Apr 12 18:23:58 2007 //todo: disallow C#D in superclass //todo: treat :::= correctly -package scala.tools.nsc +package scala +package tools.nsc package typechecker import scala.collection.mutable |