diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/Driver.scala | 26 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 12 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/Main.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala | 7 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaSettings.scala | 1 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/settings/ScalaVersion.scala | 6 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/Reporting.scala | 17 | ||||
-rw-r--r-- | src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala | 30 | ||||
-rw-r--r-- | src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala | 6 | ||||
-rw-r--r-- | test/files/run/scalapInvokedynamic.check | 5 | ||||
-rw-r--r-- | test/files/run/scalapInvokedynamic.scala | 11 | ||||
-rw-r--r-- | test/files/run/t8960.scala | 78 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala | 9 | ||||
-rw-r--r-- | test/junit/scala/tools/nsc/settings/SettingsTest.scala | 2 | ||||
-rw-r--r-- | test/pending/run/t8960.scala | 72 |
15 files changed, 182 insertions, 103 deletions
diff --git a/src/compiler/scala/tools/nsc/Driver.scala b/src/compiler/scala/tools/nsc/Driver.scala index 6befa76b3f..b30744c4df 100644 --- a/src/compiler/scala/tools/nsc/Driver.scala +++ b/src/compiler/scala/tools/nsc/Driver.scala @@ -1,7 +1,7 @@ package scala package tools.nsc -import scala.tools.nsc.reporters.ConsoleReporter +import scala.tools.nsc.reporters.{ ConsoleReporter, Reporter } import Properties.{ versionMsg, residentPromptString } import scala.reflect.internal.util.FakePos @@ -9,39 +9,43 @@ abstract class Driver { val prompt = residentPromptString - var reporter: ConsoleReporter = _ + var reporter: Reporter = _ protected var command: CompilerCommand = _ protected var settings: Settings = _ + /** Forward errors to the (current) reporter. */ protected def scalacError(msg: String): Unit = { reporter.error(FakePos("scalac"), msg + "\n scalac -help gives more information") } + /** True to continue compilation. */ protected def processSettingsHook(): Boolean = { - if (settings.version) { reporter echo versionMsg ; false } else true + if (settings.version) { reporter echo versionMsg ; false } + else !reporter.hasErrors } protected def newCompiler(): Global - protected def doCompile(compiler: Global) { + protected def doCompile(compiler: Global): Unit = { if (command.files.isEmpty) { reporter.echo(command.usageMsg) reporter.echo(compiler.pluginOptionsHelp) } else { val run = new compiler.Run() run compile command.files - reporter.printSummary() + reporter.finish() } } - def process(args: Array[String]) { + def process(args: Array[String]): Boolean = { val ss = new Settings(scalacError) - reporter = new ConsoleReporter(ss) + reporter = new ConsoleReporter(ss) // for reporting early config errors, before compiler is constructed command = new CompilerCommand(args.toList, ss) settings = command.settings if (processSettingsHook()) { val compiler = newCompiler() + reporter = compiler.reporter // adopt the configured reporter try { if (reporter.hasErrors) reporter.flush() @@ -57,11 +61,9 @@ abstract class Driver { case _ => throw ex // unexpected error, tell the outside world. } } - } + } else if (reporter.hasErrors) reporter.flush() + !reporter.hasErrors } - def main(args: Array[String]) { - process(args) - sys.exit(if (reporter.hasErrors) 1 else 0) - } + def main(args: Array[String]): Unit = sys.exit(if (process(args)) 0 else 1) } diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 778f2fed59..965f984367 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -15,7 +15,7 @@ import io.{ SourceReader, AbstractFile, Path } import reporters.{ Reporter, ConsoleReporter } import util.{ ClassFileLookup, ClassPath, MergedClassPath, StatisticsInfo, returning } import scala.reflect.ClassTag -import scala.reflect.internal.util.{ SourceFile, NoSourceFile, BatchSourceFile, ScriptSourceFile } +import scala.reflect.internal.util.{ ScalaClassLoader, SourceFile, NoSourceFile, BatchSourceFile, ScriptSourceFile } import scala.reflect.internal.pickling.PickleBuffer import symtab.{ Flags, SymbolTable, SymbolTrackers } import symtab.classfile.Pickler @@ -90,7 +90,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) this(new Settings(err => reporter.error(null, err)), reporter) def this(settings: Settings) = - this(settings, new ConsoleReporter(settings)) + this(settings, Global.reporter(settings)) def picklerPhase: Phase = if (currentRun.isDefined) currentRun.picklerPhase else NoPhase @@ -1703,4 +1703,12 @@ class Global(var currentSettings: Settings, var reporter: Reporter) object Global { def apply(settings: Settings, reporter: Reporter): Global = new Global(settings, reporter) + + def apply(settings: Settings): Global = new Global(settings, reporter(settings)) + + private def reporter(settings: Settings): Reporter = { + //val loader = ScalaClassLoader(getClass.getClassLoader) // apply does not make delegate + val loader = new ClassLoader(getClass.getClassLoader) with ScalaClassLoader + loader.create[Reporter](settings.reporter.value, settings.errorFn)(settings) + } } diff --git a/src/compiler/scala/tools/nsc/Main.scala b/src/compiler/scala/tools/nsc/Main.scala index a66ee572a9..e2cf49907b 100644 --- a/src/compiler/scala/tools/nsc/Main.scala +++ b/src/compiler/scala/tools/nsc/Main.scala @@ -17,7 +17,8 @@ class MainClass extends Driver with EvalLoop { new compiler.Run() compile command.files } - override def newCompiler(): Global = Global(settings, reporter) + override def newCompiler(): Global = Global(settings) + override def doCompile(compiler: Global) { if (settings.resident) resident(compiler) else super.doCompile(compiler) diff --git a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala index 5bf611a7b0..4bf92fd1fb 100644 --- a/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala +++ b/src/compiler/scala/tools/nsc/reporters/ConsoleReporter.scala @@ -11,8 +11,7 @@ import java.io.{ BufferedReader, IOException, PrintWriter } import scala.reflect.internal.util._ import StringOps._ -/** - * This class implements a Reporter that displays messages on a text console. +/** This class implements a Reporter that displays messages on a text console. */ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: PrintWriter) extends AbstractReporter { def this(settings: Settings) = this(settings, Console.in, new PrintWriter(Console.err, true)) @@ -85,5 +84,7 @@ class ConsoleReporter(val settings: Settings, reader: BufferedReader, writer: Pr } } - override def flush() { writer.flush() } + override def flush() = writer.flush() + + override def finish() = printSummary() } diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index c9d97a9469..c8251a542c 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -134,6 +134,7 @@ trait ScalaSettings extends AbsScalaSettings val Xshowobj = StringSetting ("-Xshow-object", "object", "Show internal representation of object.", "") val showPhases = BooleanSetting ("-Xshow-phases", "Print a synopsis of compiler phases.") val sourceReader = StringSetting ("-Xsource-reader", "classname", "Specify a custom method for reading source files.", "") + val reporter = StringSetting ("-Xreporter", "classname", "Specify a custom reporter for compiler messages.", "scala.tools.nsc.reporters.ConsoleReporter") val strictInference = BooleanSetting ("-Xstrict-inference", "Don't infer known-unsound types") val source = ScalaVersionSetting ("-Xsource", "version", "Treat compiler input as Scala source for the specified version, see SI-8126.", initial = ScalaVersion("2.11")) diff --git a/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala b/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala index 7e67b7bec6..0b051ef89d 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaVersion.scala @@ -77,10 +77,7 @@ object ScalaVersion { def apply(versionString: String, errorHandler: String => Unit): ScalaVersion = { def error() = errorHandler( - s"There was a problem parsing ${versionString}. " + - "Versions should be in the form major[.minor[.revision]] " + - "where each part is a positive number, as in 2.10.1. " + - "The minor and revision parts are optional." + s"Bad version (${versionString}) not major[.minor[.revision[-suffix]]]" ) def toInt(s: String) = s match { @@ -97,6 +94,7 @@ object ScalaVersion { versionString match { case "none" => NoScalaVersion + case "" => NoScalaVersion case "any" => AnyScalaVersion case vpat(majorS, minorS, revS, buildS) => SpecificScalaVersion(toInt(majorS), toInt(minorS), toInt(revS), toBuild(buildS)) diff --git a/src/reflect/scala/reflect/internal/Reporting.scala b/src/reflect/scala/reflect/internal/Reporting.scala index f2de83bc5d..2534f59c97 100644 --- a/src/reflect/scala/reflect/internal/Reporting.scala +++ b/src/reflect/scala/reflect/internal/Reporting.scala @@ -8,11 +8,11 @@ package reflect package internal /** Provides delegates to the reporter doing the actual work. - * All forwarding methods should be marked final, - * but some subclasses out of our reach stil override them. + * All forwarding methods should be marked final, + * but some subclasses out of our reach stil override them. * - * Eventually, this interface should be reduced to one method: `reporter`, - * and clients should indirect themselves (reduce duplication of forwarders). + * Eventually, this interface should be reduced to one method: `reporter`, + * and clients should indirect themselves (reduce duplication of forwarders). */ trait Reporting { self : Positions => def reporter: Reporter @@ -71,8 +71,8 @@ import util.Position /** Report information, warnings and errors. * - * This describes the (future) external interface for issuing information, warnings and errors. - * Currently, scala.tools.nsc.Reporter is used by sbt/ide/partest. + * This describes the (future) external interface for issuing information, warnings and errors. + * Currently, scala.tools.nsc.Reporter is used by sbt/ide/partest. */ abstract class Reporter { protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit @@ -101,7 +101,10 @@ abstract class Reporter { resetCount(ERROR) } - def flush(): Unit = { } + def flush(): Unit = () + + /** Finish reporting: print summaries, release resources. */ + def finish(): Unit = () } // TODO: move into superclass once partest cuts tie on Severity diff --git a/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala b/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala index 41011f6c6b..296934e253 100644 --- a/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala +++ b/src/reflect/scala/reflect/internal/util/ScalaClassLoader.scala @@ -11,7 +11,8 @@ import java.lang.reflect.{ Constructor, Modifier, Method } import java.io.{ File => JFile } import java.net.{ URLClassLoader => JURLClassLoader } import java.net.URL -import scala.reflect.runtime.ReflectionUtils.unwrapHandler +import scala.reflect.internal.FatalError +import scala.reflect.runtime.ReflectionUtils.{ show, unwrapHandler } import ScalaClassLoader._ import scala.util.control.Exception.{ catching } import scala.language.implicitConversions @@ -46,6 +47,33 @@ trait ScalaClassLoader extends JClassLoader { def create(path: String): AnyRef = tryToInitializeClass[AnyRef](path).map(_.newInstance()).orNull + /** Create an instance with ctor args, or invoke errorFn before throwing. */ + def create[T <: AnyRef : ClassTag](path: String, errorFn: String => Unit)(args: AnyRef*): T = { + def fail(msg: String) = error(msg, new IllegalArgumentException(msg)) + def error(msg: String, e: Throwable) = { errorFn(msg) ; throw e } + try { + val clazz = Class.forName(path, /*initialize =*/ true, /*loader =*/ this) + if (classTag[T].runtimeClass isAssignableFrom clazz) { + val ctor = { + val maybes = clazz.getConstructors filter (c => c.getParameterCount == args.size && + (c.getParameterTypes zip args).forall { case (k, a) => k isAssignableFrom a.getClass }) + if (maybes.size == 1) maybes.head + else fail(s"Constructor must accept arg list (${args map (_.getClass.getName) mkString ", "}): ${path}") + } + (ctor.newInstance(args: _*)).asInstanceOf[T] + } else { + errorFn(s"""Loader for ${classTag[T]}: [${show(classTag[T].runtimeClass.getClassLoader)}] + |Loader for ${clazz.getName}: [${show(clazz.getClassLoader)}]""".stripMargin) + fail(s"Not a ${classTag[T]}: ${path}") + } + } catch { + case e: ClassNotFoundException => + error(s"Class not found: ${path}", e) + case e @ (_: LinkageError | _: ReflectiveOperationException) => + error(s"Unable to create instance: ${path}: ${e.toString}", e) + } + } + /** The actual bytes for a class file, or an empty array if it can't be found. */ def classBytes(className: String): Array[Byte] = classAsStream(className) match { case null => Array() diff --git a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala index cfd750055b..eed76c3774 100644 --- a/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala +++ b/src/scalap/scala/tools/scalap/scalax/rules/scalasig/ClassFileParser.scala @@ -114,6 +114,9 @@ object ClassFileParser extends ByteCodeReader { val methodRef = memberRef("Method") val interfaceMethodRef = memberRef("InterfaceMethod") val nameAndType = u2 ~ u2 ^^ add1 { case name ~ descriptor => pool => "NameAndType: " + pool(name) + ", " + pool(descriptor) } + val methodHandle = u1 ~ u2 ^^ add1 { case referenceKind ~ referenceIndex => pool => "MethodHandle: " + referenceKind + ", " + pool(referenceIndex) } + val methodType = u2 ^^ add1 { case descriptorIndex => pool => "MethodType: " + pool(descriptorIndex) } + val invokeDynamic = u2 ~ u2 ^^ add1 { case bootstrapMethodAttrIndex ~ nameAndTypeIndex => pool => "InvokeDynamic: " + "bootstrapMethodAttrIndex = " + bootstrapMethodAttrIndex + ", " + pool(nameAndTypeIndex) } val constantPoolEntry = u1 >> { case 1 => utf8String @@ -127,6 +130,9 @@ object ClassFileParser extends ByteCodeReader { case 10 => methodRef case 11 => interfaceMethodRef case 12 => nameAndType + case 15 => methodHandle + case 16 => methodType + case 18 => invokeDynamic } val interfaces = u2 >> u2.times diff --git a/test/files/run/scalapInvokedynamic.check b/test/files/run/scalapInvokedynamic.check new file mode 100644 index 0000000000..8e4b08f234 --- /dev/null +++ b/test/files/run/scalapInvokedynamic.check @@ -0,0 +1,5 @@ +class C extends scala.AnyRef { + def this() = { /* compiled code */ } + def m: java.lang.String = { /* compiled code */ } +} + diff --git a/test/files/run/scalapInvokedynamic.scala b/test/files/run/scalapInvokedynamic.scala new file mode 100644 index 0000000000..670cf26662 --- /dev/null +++ b/test/files/run/scalapInvokedynamic.scala @@ -0,0 +1,11 @@ +class C { + def m = { + val f = (x: String) => x.trim + f(" H ae i ") + } +} + +object Test extends App { + val testClassesDir = System.getProperty("partest.output") + scala.tools.scalap.Main.main(Array("-cp", testClassesDir, "C")) +}
\ No newline at end of file diff --git a/test/files/run/t8960.scala b/test/files/run/t8960.scala new file mode 100644 index 0000000000..a43d5679d8 --- /dev/null +++ b/test/files/run/t8960.scala @@ -0,0 +1,78 @@ +object Test extends App { + def testAnonFunClass(o: AnyRef, sp: Boolean = false) = { + val isSpecialized = o.getClass.getSuperclass.getName contains "$sp" + val isDelambdafyMethod = o.getClass.getName contains "$lambda$" + assert( + // delambdafy:method doesn't currently emit specialized anonymous function classes + if (sp) (isSpecialized || isDelambdafyMethod) else !isSpecialized, + o.getClass.getName) + + val Some(f) = o.getClass.getDeclaredFields.find(_.getName == "serialVersionUID") + assert(f.getLong(null) == 0l) + } + + def testIndyLambda(o: AnyRef, sp: Boolean = false) = { + val isSpecialized = o.getClass.getInterfaces.exists(_.getName contains "$sp") + assert(sp == isSpecialized, o.getClass.getName) + } + + + testIndyLambda(() => (), sp = true) + testIndyLambda(() => 1, sp = true) + testIndyLambda(() => "") + + testIndyLambda((x: Int) => x, sp = true) + testIndyLambda((x: Boolean) => x) + testIndyLambda((x: Int) => "") + + testIndyLambda((x1: Int, x2: Int) => 0d, sp = true) + testIndyLambda((x1: Int, x2: AnyRef) => 0d) + testIndyLambda((x1: Any, x2: Any) => x1) + + // scala> println((for (i <- 3 to 22) yield (for (j <- 1 to i) yield s"x$j: Int").mkString(" testIndyLambda((", ", ", ") => x1)")).mkString("\n")) + + testIndyLambda((x1: Int, x2: Int, x3: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1) + testIndyLambda((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1) + + testAnonFunClass({ + case x: Int => x + }: PartialFunction[Int, Int], sp = true) + + testAnonFunClass({ + case x: Int => x + }: PartialFunction[Any, Any]) + + testAnonFunClass({ + case x: Int => () + }: PartialFunction[Int, Unit], sp = true) + + testAnonFunClass({ + case x: String => 1 + }: PartialFunction[String, Int]) + + testAnonFunClass({ + case x: String => () + }: PartialFunction[String, Unit]) + + testAnonFunClass({ + case x: String => x + }: PartialFunction[String, String]) +} diff --git a/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala b/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala index acbf39fe23..3717f80362 100644 --- a/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala +++ b/test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala @@ -56,5 +56,14 @@ class ScalaVersionTest { assertThrows[NumberFormatException] { ScalaVersion("2-") } assertThrows[NumberFormatException] { ScalaVersion("2-.") } // scalacheck territory assertThrows[NumberFormatException] { ScalaVersion("any.7") } + + assertThrows[NumberFormatException] ( ScalaVersion("2.11-ok"), _ == + "Bad version (2.11-ok) not major[.minor[.revision[-suffix]]]" ) + + } + + // SI-9377 + @Test def `missing version is as good as none`() { + assertEquals(NoScalaVersion, ScalaVersion("")) } } diff --git a/test/junit/scala/tools/nsc/settings/SettingsTest.scala b/test/junit/scala/tools/nsc/settings/SettingsTest.scala index 96f83c4c2f..1a2d695d68 100644 --- a/test/junit/scala/tools/nsc/settings/SettingsTest.scala +++ b/test/junit/scala/tools/nsc/settings/SettingsTest.scala @@ -178,6 +178,6 @@ class SettingsTest { check(expected = "2.12", "-Xsource:2.12") assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>") assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource", "2.11"), _ == "-Xsource requires an argument, the syntax is -Xsource:<version>") - assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "There was a problem parsing 2.invalid") + assertThrows[IllegalArgumentException](check(expected = "2.11", "-Xsource:2.invalid"), _ contains "Bad version (2.invalid)") } } diff --git a/test/pending/run/t8960.scala b/test/pending/run/t8960.scala deleted file mode 100644 index a58ac53d33..0000000000 --- a/test/pending/run/t8960.scala +++ /dev/null @@ -1,72 +0,0 @@ -object Test extends App { - def test(o: AnyRef, sp: Boolean = false) = { - val isSpecialized = o.getClass.getSuperclass.getName contains "$sp" - val isDelambdafyMethod = o.getClass.getName contains "$lambda$" - assert( - // delambdafy:method doesn't currently emit specialized anonymous function classes - if (sp) (isSpecialized || isDelambdafyMethod) else !isSpecialized, - o.getClass.getName) - - val Some(f) = o.getClass.getDeclaredFields.find(_.getName == "serialVersionUID") - assert(f.getLong(null) == 0l) - } - - test(() => (), sp = true) - test(() => 1, sp = true) - test(() => "") - - test((x: Int) => x, sp = true) - test((x: Boolean) => x) - test((x: Int) => "") - - test((x1: Int, x2: Int) => 0d, sp = true) - test((x1: Int, x2: AnyRef) => 0d) - test((x1: Any, x2: Any) => x1) - - // scala> println((for (i <- 3 to 22) yield (for (j <- 1 to i) yield s"x$j: Int").mkString(" test((", ", ", ") => x1)")).mkString("\n")) - - test((x1: Int, x2: Int, x3: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int) => x1) - test((x1: Int, x2: Int, x3: Int, x4: Int, x5: Int, x6: Int, x7: Int, x8: Int, x9: Int, x10: Int, x11: Int, x12: Int, x13: Int, x14: Int, x15: Int, x16: Int, x17: Int, x18: Int, x19: Int, x20: Int, x21: Int, x22: Int) => x1) - - test({ - case x: Int => x - }: PartialFunction[Int, Int], sp = true) - - test({ - case x: Int => x - }: PartialFunction[Any, Any]) - - test({ - case x: Int => () - }: PartialFunction[Int, Unit], sp = true) - - test({ - case x: String => 1 - }: PartialFunction[String, Int]) - - test({ - case x: String => () - }: PartialFunction[String, Unit]) - - test({ - case x: String => x - }: PartialFunction[String, String]) -} |