summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2010-03-19 09:09:00 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2010-03-19 09:09:00 +0000
commitbf2da77cefaed778008a2ede6b129a58adc86913 (patch)
tree1b682c39ff93610c631de3139dd0c8c83ff20ad0
parent46ddf14b459ff18f7fd1904249c6916384030546 (diff)
downloadscala-bf2da77cefaed778008a2ede6b129a58adc86913.tar.gz
scala-bf2da77cefaed778008a2ede6b129a58adc86913.tar.bz2
scala-bf2da77cefaed778008a2ede6b129a58adc86913.zip
Fixes #3054. No review.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala22
-rw-r--r--src/partest/scala/tools/partest/nest/FileManager.scala30
-rw-r--r--src/partest/scala/tools/partest/nest/Worker.scala10
-rw-r--r--test/files/buildmanager/t3054/bar/Bar.java7
-rw-r--r--test/files/buildmanager/t3054/foo/Foo.scala5
-rw-r--r--test/files/buildmanager/t3054/t3054.check3
-rw-r--r--test/files/buildmanager/t3054/t3054.test1
7 files changed, 60 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 0ddd838303..9edc245327 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -1201,26 +1201,38 @@ trait Namers { self: Analyzer =>
}
true
}
+
+ def isValidSelector(from: Name)(fun : => Unit) {
+ if (base.nonLocalMember(from) == NoSymbol &&
+ base.nonLocalMember(from.toTypeName) == NoSymbol) fun
+ }
+
def checkSelectors(selectors: List[ImportSelector]): Unit = selectors match {
case ImportSelector(from, _, to, _) :: rest =>
if (from != nme.WILDCARD && base != ErrorType) {
- if (base.nonLocalMember(from) == NoSymbol &&
- base.nonLocalMember(from.toTypeName) == NoSymbol) {
+ isValidSelector(from) {
if (currentRun.compileSourceFor(expr, from))
return typeSig(tree)
- context.error(tree.pos, from.decode + " is not a member of " + expr)
+ // for Java code importing Scala objects
+ if (from.endsWith(nme.DOLLARraw))
+ isValidSelector(from.subName(0, from.length -1)) {
+ context.error(tree.pos, from.decode + " is not a member of " + expr)
+ }
+ else
+ context.error(tree.pos, from.decode + " is not a member of " + expr)
}
if (checkNotRedundant(tree.pos, from, to))
checkNotRedundant(tree.pos, from.toTypeName, to.toTypeName)
}
if (from != nme.WILDCARD && (rest.exists (sel => sel.name == from)))
- context.error(tree.pos, from.decode + " is renamed twice");
+ context.error(tree.pos, from.decode + " is renamed twice")
if ((to ne null) && to != nme.WILDCARD && (rest exists (sel => sel.rename == to)))
- context.error(tree.pos, to.decode + " appears twice as a target of a renaming");
+ context.error(tree.pos, to.decode + " appears twice as a target of a renaming")
checkSelectors(rest)
case Nil =>
}
+
checkSelectors(selectors)
ImportType(expr1)
}
diff --git a/src/partest/scala/tools/partest/nest/FileManager.scala b/src/partest/scala/tools/partest/nest/FileManager.scala
index 12a4fdf40f..bdbb34b3c4 100644
--- a/src/partest/scala/tools/partest/nest/FileManager.scala
+++ b/src/partest/scala/tools/partest/nest/FileManager.scala
@@ -73,16 +73,26 @@ trait FileManager {
def overwriteFileWith(dest: File, file: File) =
dest.isFile && copyFile(file, dest)
- def copyFile(from: File, to: File): Boolean =
- try {
- val appender = StreamAppender(from, to)
- appender.run()
- appender.closeAll()
- true
- }
- catch {
- case _: IOException => false
- }
+
+ def copyFile(from: File, dest: File): Boolean = {
+ def copyFile0(from: File, to: File): Boolean =
+ try {
+ val appender = StreamAppender(from, to)
+ appender.run()
+ appender.closeAll()
+ true
+ } catch {
+ case _: IOException => false
+ }
+
+ if (from.isDirectory) {
+ assert(dest.isDirectory, "cannot copy directory to file")
+ val subDir:Directory = Path(dest) / Directory(from.getName)
+ subDir.createDirectory()
+ from.listFiles.toList.forall(copyFile(_, subDir))
+ } else
+ copyFile0(from, if (dest.isDirectory) new File(dest, from.getName) else dest)
+ }
def mapFile(file: File, suffix: String, dir: File, replace: String => String) {
val tmpFile = File.createTempFile("tmp", suffix, dir) // prefix required by API
diff --git a/src/partest/scala/tools/partest/nest/Worker.scala b/src/partest/scala/tools/partest/nest/Worker.scala
index 39137d8bd0..992ceba99f 100644
--- a/src/partest/scala/tools/partest/nest/Worker.scala
+++ b/src/partest/scala/tools/partest/nest/Worker.scala
@@ -511,6 +511,8 @@ class Worker(val fileManager: FileManager) extends Actor {
val changesDir = new File(file, fileBase + ".changes")
if (changesDir.isFile || !testFile.isFile) {
// if changes exists then it has to be a dir
+ if (!testFile.isFile) NestUI.verbose("invalid build manager test file")
+ if (changesDir.isFile) NestUI.verbose("invalid build manager changes directory")
succeeded = false
(null, null, null, null)
} else {
@@ -1050,9 +1052,11 @@ class Worker(val fileManager: FileManager) extends Actor {
fs flatMap (s => Option(AbstractFile getFile (pre + s))) toSet
private def copyTestFiles(testDir: File, destDir: File) {
- testDir.listFiles.toList filter (f => isJavaOrScala(f) && f.isFile) foreach { f =>
- fileManager.copyFile(f, new File(destDir, f.getName))
- }
+ val invalidExts = List("changes", "svn", "obj")
+ testDir.listFiles.toList filter (
+ f => (isJavaOrScala(f) && f.isFile) ||
+ (f.isDirectory && !(invalidExts.contains(SFile(f).extension)))) foreach
+ { f => fileManager.copyFile(f, destDir) }
}
def showLog(logFile: File) {
diff --git a/test/files/buildmanager/t3054/bar/Bar.java b/test/files/buildmanager/t3054/bar/Bar.java
new file mode 100644
index 0000000000..e1b056d4e5
--- /dev/null
+++ b/test/files/buildmanager/t3054/bar/Bar.java
@@ -0,0 +1,7 @@
+package bar;
+import foo.Foo$;
+
+
+public class Bar {
+ void bar() { Foo$.MODULE$.foo(); }
+}
diff --git a/test/files/buildmanager/t3054/foo/Foo.scala b/test/files/buildmanager/t3054/foo/Foo.scala
new file mode 100644
index 0000000000..c4838b9958
--- /dev/null
+++ b/test/files/buildmanager/t3054/foo/Foo.scala
@@ -0,0 +1,5 @@
+package foo
+
+class Foo {
+ def foo = println("foo")
+}
diff --git a/test/files/buildmanager/t3054/t3054.check b/test/files/buildmanager/t3054/t3054.check
new file mode 100644
index 0000000000..97cca8862e
--- /dev/null
+++ b/test/files/buildmanager/t3054/t3054.check
@@ -0,0 +1,3 @@
+builder > bar/Bar.java foo/Foo.scala
+compiling Set(bar/Bar.java, foo/Foo.scala)
+Changes: Map()
diff --git a/test/files/buildmanager/t3054/t3054.test b/test/files/buildmanager/t3054/t3054.test
new file mode 100644
index 0000000000..903df24b13
--- /dev/null
+++ b/test/files/buildmanager/t3054/t3054.test
@@ -0,0 +1 @@
+>>compile bar/Bar.java foo/Foo.scala