summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-05-05 23:46:31 +0000
committerPaul Phillips <paulp@improving.org>2011-05-05 23:46:31 +0000
commita0ea242f75c83717bc8019d1be7865a52fd6186f (patch)
tree26c7a021f34ab6f2e719ac63266d2be90fce3875 /src
parentd70e69e8a8a736e2a7f55e2abf651507b0c542a7 (diff)
downloadscala-a0ea242f75c83717bc8019d1be7865a52fd6186f.tar.gz
scala-a0ea242f75c83717bc8019d1be7865a52fd6186f.tar.bz2
scala-a0ea242f75c83717bc8019d1be7865a52fd6186f.zip
Be silent when compiling the repl extraction ob...
Be silent when compiling the repl extraction object to suppress spurious warnings. Also corrected the busted logic for spotting repl wrappers. Closes #4542, no review.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/ILoop.scala5
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/IMain.scala4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/NameManglers.scala1
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala8
-rw-r--r--src/partest/scala/tools/partest/ReplTest.scala47
-rw-r--r--src/partest/scala/tools/partest/SigTest.scala51
6 files changed, 68 insertions, 48 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
index 74a23d119d..7b57c11714 100644
--- a/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/ILoop.scala
@@ -532,7 +532,10 @@ class ILoop(in0: Option[BufferedReader], protected val out: PrintWriter)
echo("Unrecoverable error.")
throw ex
case _ =>
- def fn(): Boolean = in.readYesOrNo(replayQuestionMessage, { echo("\nYou must enter y or n.") ; fn() })
+ def fn(): Boolean =
+ try in.readYesOrNo(replayQuestionMessage, { echo("\nYou must enter y or n.") ; fn() })
+ catch { case _: RuntimeException => false }
+
if (fn()) replay()
else echo("\nAbandoning crashed session.")
}
diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
index a364f218da..fd8926ddc5 100644
--- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala
@@ -751,7 +751,9 @@ class IMain(val settings: Settings, protected val out: PrintWriter) extends Impo
typesOfDefinedTerms
// compile the result-extraction object
- lineRep compile ResultObjectSourceCode(handlers)
+ beSilentDuring {
+ lineRep compile ResultObjectSourceCode(handlers)
+ }
}
}
diff --git a/src/compiler/scala/tools/nsc/symtab/NameManglers.scala b/src/compiler/scala/tools/nsc/symtab/NameManglers.scala
index c40e1765ce..5ef0da8282 100644
--- a/src/compiler/scala/tools/nsc/symtab/NameManglers.scala
+++ b/src/compiler/scala/tools/nsc/symtab/NameManglers.scala
@@ -83,6 +83,7 @@ trait NameManglers {
def isLocalName(name: Name) = name endsWith LOCAL_SUFFIX_STRING
def isLoopHeaderLabel(name: Name) = (name startsWith WHILE_PREFIX) || (name startsWith DO_WHILE_PREFIX)
def isProtectedAccessorName(name: Name) = name startsWith PROTECTED_PREFIX
+ def isReplWrapperName(name: Name) = name containsName INTERPRETER_IMPORT_WRAPPER
def isSetterName(name: Name) = name endsWith SETTER_SUFFIX
def isTraitSetterName(name: Name) = isSetterName(name) && (name containsName TRAIT_SETTER_SEPARATOR_STRING)
def isSingletonName(name: Name) = name endsWith SINGLETON_SUFFIX
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 308eeeb590..281c8af4d5 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -426,12 +426,8 @@ trait Symbols extends reflect.generic.Symbols { self: SymbolTable =>
def elisionLevel = getAnnotation(ElidableMethodClass) flatMap { _.intArg(0) }
def implicitNotFoundMsg = getAnnotation(ImplicitNotFoundClass) flatMap { _.stringArg(0) }
- /** Does this symbol denote a wrapper object of the interpreter or its class? */
- final def isInterpreterWrapper =
- (isModule || isModuleClass) &&
- owner.isEmptyPackageClass &&
- (name startsWith nme.INTERPRETER_LINE_PREFIX) &&
- (name endsWith nme.INTERPRETER_WRAPPER_SUFFIX)
+ /** Does this symbol denote a wrapper created by the repl? */
+ final def isInterpreterWrapper = (isModule || isModuleClass) && nme.isReplWrapperName(name)
override def isEffectiveRoot = super.isEffectiveRoot || isInterpreterWrapper
diff --git a/src/partest/scala/tools/partest/ReplTest.scala b/src/partest/scala/tools/partest/ReplTest.scala
index b31c43ba6f..dd21e7906a 100644
--- a/src/partest/scala/tools/partest/ReplTest.scala
+++ b/src/partest/scala/tools/partest/ReplTest.scala
@@ -14,48 +14,15 @@ import java.lang.reflect.{ Method => JMethod, Field => JField }
*/
abstract class ReplTest extends App {
def code: String
- def settings: Settings = new Settings // override for custom settings
+ // override to add additional settings
+ def extraSettings: String = ""
+ def settings: Settings = {
+ val s = new Settings
+ s processArgumentString extraSettings
+ s
+ }
def eval() = ILoop.runForTranscript(code, settings).lines drop 1
def show() = eval() foreach println
show()
}
-
-trait SigTest {
- def mstr(m: JMethod) = " (m) %s%s".format(
- m.toGenericString,
- if (m.isBridge) " (bridge)" else ""
- )
- def fstr(f: JField) = " (f) %s".format(f.toGenericString)
-
- def isObjectMethodName(name: String) = classOf[Object].getMethods exists (_.getName == name)
-
- def fields[T: ClassManifest](p: JField => Boolean) = {
- val cl = classManifest[T].erasure
- val fs = (cl.getFields ++ cl.getDeclaredFields).distinct sortBy (_.getName)
-
- fs filter p
- }
- def methods[T: ClassManifest](p: JMethod => Boolean) = {
- val cl = classManifest[T].erasure
- val ms = (cl.getMethods ++ cl.getDeclaredMethods).distinct sortBy (x => (x.getName, x.isBridge))
-
- ms filter p
- }
- def allFields[T: ClassManifest]() = fields[T](_ => true)
- def allMethods[T: ClassManifest]() = methods[T](m => !isObjectMethodName(m.getName))
- def fieldsNamed[T: ClassManifest](name: String) = fields[T](_.getName == name)
- def methodsNamed[T: ClassManifest](name: String) = methods[T](_.getName == name)
-
- def allGenericStrings[T: ClassManifest]() =
- (allMethods[T]() map mstr) ++ (allFields[T]() map fstr)
-
- def genericStrings[T: ClassManifest](name: String) =
- (methodsNamed[T](name) map mstr) ++ (fieldsNamed[T](name) map fstr)
-
- def show[T: ClassManifest](name: String = "") = {
- println(classManifest[T].erasure.getName)
- if (name == "") allGenericStrings[T]() foreach println
- else genericStrings[T](name) foreach println
- }
-}
diff --git a/src/partest/scala/tools/partest/SigTest.scala b/src/partest/scala/tools/partest/SigTest.scala
new file mode 100644
index 0000000000..072ec006f9
--- /dev/null
+++ b/src/partest/scala/tools/partest/SigTest.scala
@@ -0,0 +1,51 @@
+/* NSC -- new Scala compiler
+ * Copyright 2005-2011 LAMP/EPFL
+ * @author Paul Phillips
+ */
+
+package scala.tools.partest
+
+import scala.tools.nsc.Settings
+import scala.tools.nsc.interpreter.ILoop
+import java.lang.reflect.{ Method => JMethod, Field => JField }
+
+/** Support code for testing signatures.
+ */
+trait SigTest {
+ def mstr(m: JMethod) = " (m) %s%s".format(
+ m.toGenericString,
+ if (m.isBridge) " (bridge)" else ""
+ )
+ def fstr(f: JField) = " (f) %s".format(f.toGenericString)
+
+ def isObjectMethodName(name: String) = classOf[Object].getMethods exists (_.getName == name)
+
+ def fields[T: ClassManifest](p: JField => Boolean) = {
+ val cl = classManifest[T].erasure
+ val fs = (cl.getFields ++ cl.getDeclaredFields).distinct sortBy (_.getName)
+
+ fs filter p
+ }
+ def methods[T: ClassManifest](p: JMethod => Boolean) = {
+ val cl = classManifest[T].erasure
+ val ms = (cl.getMethods ++ cl.getDeclaredMethods).distinct sortBy (x => (x.getName, x.isBridge))
+
+ ms filter p
+ }
+ def allFields[T: ClassManifest]() = fields[T](_ => true)
+ def allMethods[T: ClassManifest]() = methods[T](m => !isObjectMethodName(m.getName))
+ def fieldsNamed[T: ClassManifest](name: String) = fields[T](_.getName == name)
+ def methodsNamed[T: ClassManifest](name: String) = methods[T](_.getName == name)
+
+ def allGenericStrings[T: ClassManifest]() =
+ (allMethods[T]() map mstr) ++ (allFields[T]() map fstr)
+
+ def genericStrings[T: ClassManifest](name: String) =
+ (methodsNamed[T](name) map mstr) ++ (fieldsNamed[T](name) map fstr)
+
+ def show[T: ClassManifest](name: String = "") = {
+ println(classManifest[T].erasure.getName)
+ if (name == "") allGenericStrings[T]() foreach println
+ else genericStrings[T](name) foreach println
+ }
+}