summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--test/files/run/bug4542.check22
-rw-r--r--test/files/run/bug4542.scala11
8 files changed, 101 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
+ }
+}
diff --git a/test/files/run/bug4542.check b/test/files/run/bug4542.check
new file mode 100644
index 0000000000..cd7a2905e2
--- /dev/null
+++ b/test/files/run/bug4542.check
@@ -0,0 +1,22 @@
+Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> @deprecated("foooo", "ReplTest version 1.0-FINAL") class Foo() {
+ override def toString = "Bippy"
+}
+defined class Foo
+
+scala> val f = new Foo
+<console>:8: warning: class Foo is deprecated: foooo
+ val f = new Foo
+ ^
+<console>:8: warning: class Foo is deprecated: foooo
+ val f = new Foo
+ ^
+f: Foo = Bippy
+
+scala>
+
+scala>
diff --git a/test/files/run/bug4542.scala b/test/files/run/bug4542.scala
new file mode 100644
index 0000000000..5d6e8fe87c
--- /dev/null
+++ b/test/files/run/bug4542.scala
@@ -0,0 +1,11 @@
+import scala.tools.partest.ReplTest
+
+object Test extends ReplTest {
+ override def extraSettings = "-deprecation"
+ def code = """
+ |@deprecated("foooo", "ReplTest version 1.0-FINAL") class Foo() {
+ | override def toString = "Bippy"
+ |}
+ |val f = new Foo
+ """.stripMargin
+}