From daf310e686a2b3dacb488ef51d18ebff4f9812dc Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 11 Oct 2016 20:19:14 +0300 Subject: [PATCH 1/2] reorganize project for faster testing workflow Inspired by https://github.com/scalameta/paradise/pull/60 --- .scalafmt.conf | 4 +- build.sbt | 224 ++++++++++++++++++ project/build.properties | 2 +- project/build.scala | 198 ---------------- .../src/main/scala/append.scala | 41 ++++ .../src/main/scala/companion.scala} | 7 +- .../src/main/scala/helloWorld.scala | 9 + .../src/main/scala/identity.scala | 7 + .../src/main/scala/mainWithParams.scala | 9 + .../src/main/scala/namedParam.scala | 9 + .../src/main/scala}/placebo.scala | 0 .../src/main/scala/repeatedParam.scala | 7 + .../src/test/scala/compile/Desugaring.scala} | 2 +- .../src/test/scala/compile/Expansion.scala} | 42 +++- .../src/test/scala/compile/Identity.scala} | 18 +- .../src/test/scala/repl}/Repl.scala | 2 +- .../src/main/scala}/argumentative.scala | 0 .../src/main/scala}/doubler.scala | 0 .../src/main/scala}/explorer.scala | 0 .../src/main/scala}/funny.scala | 0 .../src/main/scala}/happytee.scala | 0 .../src/main/scala}/hello.scala | 0 .../src/main/scala}/identity.scala | 0 .../src/main/scala}/kase.scala | 0 .../src/main/scala/placebo.scala | 5 + .../src/main/scala}/pretty.scala | 0 .../src/main/scala}/shove.scala | 0 .../src/main/scala}/simulacrum.scala | 0 .../src/main/scala}/social.scala | 0 .../src/main/scala}/thingy.scala | 0 .../src/test/resources/doc}/Simulacrum.check | 0 .../test/resources/doc}/Simulacrum/Test.scala | 0 .../src/test/scala/compile}/42/42.scala | 0 .../src/test/scala/compile}/Acyclic.scala | 0 .../test/scala/compile}/Argumentative.scala | 0 .../src/test/scala/compile}/Assorted.scala | 0 .../src/test/scala/compile}/Definition.scala | 0 .../scala/compile}/InteropCaseSynthesis.scala | 0 .../src/test/scala/compile}/Issue09.scala | 0 .../src/test/scala/compile}/Issue10.scala | 0 .../src/test/scala/compile}/KaseClass.scala | 0 .../scala/compile}/KaseIdentityClass.scala | 0 .../scala/compile}/KaseIdentityObject.scala | 0 .../src/test/scala/compile}/KaseObject.scala | 0 .../scala/compile}/KasePlaceboClass.scala | 0 .../scala/compile}/KasePlaceboObject.scala | 0 .../test/scala/compile}/KaseThorough.scala | 0 .../src/test/scala/compile}/Multiple.scala | 0 .../test/scala/compile}/NameResolution.scala | 0 .../test/scala/compile}/PackageObject.scala | 0 .../scala/compile}/PackagePackageObject.scala | 0 .../src/test/scala/compile}/Parameters.scala | 0 .../test/scala/compile}/PlaceboAssorted.scala | 0 .../test/scala/compile}/PlaceboClass.scala | 0 .../test/scala/compile}/PlaceboObject.scala | 0 .../scala/compile}/PlaceboParameters.scala | 0 .../src/test/scala/compile}/Recursive.scala | 0 .../src/test/scala/compile}/Scopes.scala | 0 .../src/test/scala/compile}/TypeArgs.scala | 0 .../src/test/scala/compile}/acyclic-a/C.scala | 0 .../src/test/scala/compile}/acyclic-a/D.scala | 0 .../src/test/scala/compile}/acyclic-b/C.scala | 0 .../src/test/scala/compile}/acyclic-b/D.scala | 0 .../compile}/companion-symbol-of/A.scala | 0 .../compile}/companion-symbol-of/B.scala | 0 .../compile}/companion-symbol-of/C.scala | 0 .../test/scala/compile}/issue10/Test1.scala | 0 .../test/scala/compile}/issue10/Test2.scala | 0 .../test/scala/compile}/issue14/Test1.scala | 0 .../test/scala/compile}/issue14/Test2.scala | 0 .../test/scala/compile}/issue46/Test.scala | 0 .../test/scala/compile}/issue48/Test1.scala | 0 .../test/scala/compile}/issue48/Test2.scala | 0 .../test/scala/compile}/issue64/Test.scala | 0 .../test/scala/compile}/module-class/A.scala | 0 .../test/scala/compile}/module-class/B.scala | 0 .../src/test/scala/compile}/scopes/A.scala | 0 .../src/test/scala/compile}/scopes/B.scala | 0 .../src/test/scala/doc/Scaladoc.scala} | 6 +- .../src/test/scala}/repl/Repl.scala | 2 +- .../src/main}/scala/DisableScalaColor.scala | 0 .../src/main}/scala/ReplSuite.scala | 4 +- .../src/main}/scala/ToolSuite.scala | 4 +- .../scala/annotations/new/main/Defs.scala | 86 ------- .../scala/annotations/new/main/Macros.scala | 16 -- .../new/main/MacrosWithParams.scala | 34 --- .../annotations/new/main/Companion.scala | 19 -- .../annotations/new/main/PrintDefn.scala | 9 - .../annotations/new/main/TestParams.scala | 12 - .../old/neg/macro-annotation-abort.check | 10 - .../neg/macro-annotation-abort/Macros_1.scala | 14 -- .../neg/macro-annotation-abort/Test_2.scala | 4 - .../neg/macro-annotation-annottees-a.check | 7 - .../Macros_1.scala | 14 -- .../macro-annotation-annottees-a/Test_2.scala | 4 - .../neg/macro-annotation-annottees-b.check | 7 - .../Macros_1.scala | 14 -- .../macro-annotation-annottees-b/Test_2.scala | 4 - .../old/neg/macro-annotation-baddecl.check | 10 - .../macro-annotation-baddecl/Macros_1.scala | 54 ----- .../neg/macro-annotation-baddecl/Test_2.scala | 7 - .../old/neg/macro-annotation-badsig.check | 33 --- .../macro-annotation-badsig/Macros_1.scala | 47 ---- .../neg/macro-annotation-badsig/Test_2.scala | 7 - .../old/neg/macro-annotation-crash.check | 43 ---- .../neg/macro-annotation-crash/Macros_1.scala | 14 -- .../neg/macro-annotation-crash/Test_2.scala | 4 - .../old/neg/macro-annotation-cyclic-a.check | 4 - .../macro-annotation-cyclic-a/Macros_1.scala | 35 --- .../macro-annotation-cyclic-a/Test_2.scala | 7 - .../old/neg/macro-annotation-cyclic-b.check | 4 - .../macro-annotation-cyclic-b/Macros_1.scala | 18 -- .../macro-annotation-cyclic-b/Test_2.scala | 3 - .../neg/macro-annotation-packageobject.check | 4 - .../Macros_1.scala | 33 --- .../Pkg_2.scala | 1 - .../old/neg/macro-annotation-qqq.check | 10 - .../neg/macro-annotation-qqq/Macros_1.scala | 7 - .../old/neg/macro-annotation-qqq/Test_2.scala | 4 - .../old/neg/macro-annotation-toplevel.check | 40 ---- .../macro-annotation-toplevel/Macros_1.scala | 51 ---- .../macro-annotation-toplevel/Test_2.scala | 28 --- .../neg/macro-annotation-unrecognized-a.check | 4 - .../Macros_1.scala | 31 --- .../Test_2.scala | 4 - .../neg/macro-annotation-unrecognized-b.check | 4 - .../Macros_Test_1.scala | 35 --- 127 files changed, 365 insertions(+), 1037 deletions(-) create mode 100644 build.sbt delete mode 100644 project/build.scala create mode 100644 tests/annotations-meta/src/main/scala/append.scala rename tests/{src/main/scala/annotations/new/main/CompanionMacros.scala => annotations-meta/src/main/scala/companion.scala} (87%) create mode 100644 tests/annotations-meta/src/main/scala/helloWorld.scala create mode 100644 tests/annotations-meta/src/main/scala/identity.scala create mode 100644 tests/annotations-meta/src/main/scala/mainWithParams.scala create mode 100644 tests/annotations-meta/src/main/scala/namedParam.scala rename tests/{src/main/scala/annotations/old => annotations-meta/src/main/scala}/placebo.scala (100%) create mode 100644 tests/annotations-meta/src/main/scala/repeatedParam.scala rename tests/{src/test/scala/annotations/new/transform/Transform.scala => annotations-meta/src/test/scala/compile/Desugaring.scala} (97%) rename tests/{src/test/scala/annotations/new/main/ExpansionTests.scala => annotations-meta/src/test/scala/compile/Expansion.scala} (77%) rename tests/{src/test/scala/annotations/new/main/TestMods.scala => annotations-meta/src/test/scala/compile/Identity.scala} (60%) rename tests/{src/test/scala/annotations/new/syntax => annotations-meta/src/test/scala/repl}/Repl.scala (96%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/argumentative.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/doubler.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/explorer.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/funny.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/happytee.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/hello.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/identity.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/kase.scala (100%) create mode 100644 tests/annotations-reflect/src/main/scala/placebo.scala rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/pretty.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/shove.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/simulacrum.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/social.scala (100%) rename tests/{src/main/scala/annotations/old => annotations-reflect/src/main/scala}/thingy.scala (100%) rename tests/{src/test/scala/annotations/old/scaladoc/resources => annotations-reflect/src/test/resources/doc}/Simulacrum.check (100%) rename tests/{src/test/scala/annotations/old/scaladoc/resources => annotations-reflect/src/test/resources/doc}/Simulacrum/Test.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/42/42.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Acyclic.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Argumentative.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Assorted.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Definition.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/InteropCaseSynthesis.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Issue09.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Issue10.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KaseClass.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KaseIdentityClass.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KaseIdentityObject.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KaseObject.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KasePlaceboClass.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KasePlaceboObject.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/KaseThorough.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Multiple.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/NameResolution.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/PackageObject.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/PackagePackageObject.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Parameters.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/PlaceboAssorted.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/PlaceboClass.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/PlaceboObject.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/PlaceboParameters.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Recursive.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/Scopes.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/TypeArgs.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/acyclic-a/C.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/acyclic-a/D.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/acyclic-b/C.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/acyclic-b/D.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/companion-symbol-of/A.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/companion-symbol-of/B.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/companion-symbol-of/C.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue10/Test1.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue10/Test2.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue14/Test1.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue14/Test2.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue46/Test.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue48/Test1.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue48/Test2.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/issue64/Test.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/module-class/A.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/module-class/B.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/scopes/A.scala (100%) rename tests/{src/test/scala/annotations/old/run => annotations-reflect/src/test/scala/compile}/scopes/B.scala (100%) rename tests/{src/test/scala/annotations/old/scaladoc/ScaladocSuite.scala => annotations-reflect/src/test/scala/doc/Scaladoc.scala} (75%) rename tests/{src/test/scala/annotations/old => annotations-reflect/src/test/scala}/repl/Repl.scala (98%) rename tests/{src/test => common/src/main}/scala/DisableScalaColor.scala (100%) rename tests/{src/test => common/src/main}/scala/ReplSuite.scala (94%) rename tests/{src/test => common/src/main}/scala/ToolSuite.scala (94%) delete mode 100644 tests/src/main/scala/annotations/new/main/Defs.scala delete mode 100644 tests/src/main/scala/annotations/new/main/Macros.scala delete mode 100644 tests/src/main/scala/annotations/new/main/MacrosWithParams.scala delete mode 100644 tests/src/test/scala/annotations/new/main/Companion.scala delete mode 100644 tests/src/test/scala/annotations/new/main/PrintDefn.scala delete mode 100644 tests/src/test/scala/annotations/new/main/TestParams.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-abort.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-badsig.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-crash.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Pkg_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-qqq.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Macros_1.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Test_2.scala delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b.check delete mode 100644 tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b/Macros_Test_1.scala diff --git a/.scalafmt.conf b/.scalafmt.conf index 659a3a18..c9838cae 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -3,8 +3,6 @@ maxColumn = 100 optIn.breakChainOnFirstMethodDot = true project.git = true project.excludeFilters = [ - tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Pkg_2.scala, - tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Test_2.scala, - tests/src/main/scala/annotations/old/kase.scala + tests/annotations-reflect/src/main/scala/kase.scala ] runner.dialect = Paradise211 diff --git a/build.sbt b/build.sbt new file mode 100644 index 00000000..025be52a --- /dev/null +++ b/build.sbt @@ -0,0 +1,224 @@ +import sbtassembly.Plugin._ +import AssemblyKeys._ + +lazy val ScalaVersions = Seq("2.11.8") +lazy val MetaVersion = "1.1.0" + +// ========================================== +// Settings +// ========================================== + +lazy val sharedSettings: Seq[Def.Setting[_]] = + Defaults.defaultSettings ++ + Seq( + scalaVersion := ScalaVersions.head, + crossVersion := CrossVersion.full, + version := "3.0.0-SNAPSHOT", + organization := "org.scalameta", + description := "Empowers production Scala compiler with latest macro developments", + resolvers += Resolver.sonatypeRepo("releases"), + publishMavenStyle := true, + publishArtifact in Test := false, + scalacOptions ++= Seq("-deprecation", "-feature"), + logBuffered := false, + triggeredMessage in ThisBuild := Watched.clearWhenTriggered + ) + +lazy val usePluginSettings: Seq[Def.Setting[_]] = Seq( + scalacOptions in Compile <++= (Keys.`package` in (plugin, Compile)) map { (jar: File) => + System.setProperty("sbt.paths.plugin.jar", jar.getAbsolutePath) + val addPlugin = "-Xplugin:" + jar.getAbsolutePath + // Thanks Jason for this cool idea (taken from https://github.com/retronym/boxer) + // add plugin timestamp to compiler options to trigger recompile of + // main after editing the plugin. (Otherwise a 'clean' is needed.) + val dummy = "-Jdummy=" + jar.lastModified + Seq(addPlugin, dummy) + } +) + +lazy val testSettings: Seq[Def.Setting[_]] = Seq( + libraryDependencies += "org.scalameta" %% "scalameta" % MetaVersion, + libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value, + libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value, + libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.0", + scalacOptions += "-Ywarn-unused-import", + scalacOptions += "-Xfatal-warnings", + publishArtifact in Compile := false, + scalacOptions in Compile ++= Seq() +) + +def exposePaths(projectName: String, config: Configuration) = { + def uncapitalize(s: String) = + if (s.length == 0) "" + else { val chars = s.toCharArray; chars(0) = chars(0).toLower; new String(chars) } + val prefix = "sbt.paths." + projectName + "." + uncapitalize(config.name) + "." + Seq( + sourceDirectory in config := { + val defaultValue = (sourceDirectory in config).value + System.setProperty(prefix + "sources", defaultValue.getAbsolutePath) + defaultValue + }, + resourceDirectory in config := { + val defaultValue = (resourceDirectory in config).value + System.setProperty(prefix + "resources", defaultValue.getAbsolutePath) + defaultValue + }, + fullClasspath in config := { + val defaultValue = (fullClasspath in config).value + val classpath = defaultValue.files.map(_.getAbsolutePath) + val scalaLibrary = classpath.map(_.toString).find(_.contains("scala-library")).get + System.setProperty("sbt.paths.scalalibrary.classes", scalaLibrary) + System.setProperty(prefix + "classes", classpath.mkString(java.io.File.pathSeparator)) + defaultValue + } + ) +} + +def loadCredentials(): List[Credentials] = { + val mavenSettingsFile = System.getProperty("maven.settings.file") + if (mavenSettingsFile != null) { + println("Loading Sonatype credentials from " + mavenSettingsFile) + try { + import scala.xml._ + val settings = XML.loadFile(mavenSettingsFile) + def readServerConfig(key: String) = + (settings \\ "settings" \\ "servers" \\ "server" \\ key).head.text + List( + Credentials( + "Sonatype Nexus Repository Manager", + "oss.sonatype.org", + readServerConfig("username"), + readServerConfig("password") + )) + } catch { + case ex: Exception => + println("Failed to load Maven settings from " + mavenSettingsFile + ": " + ex) + Nil + } + } else { + // println("Sonatype credentials cannot be loaded: -Dmaven.settings.file is not specified.") + Nil + } +} + +// ========================================== +// Projects +// ========================================== + +lazy val root = project + .in(file(".")) + .settings( + sharedSettings, + packagedArtifacts := Map.empty + ) + .aggregate( + plugin, + testsAnnotationsMeta, + testsAnnotationsReflect + ) + +// main scala.meta paradise plugin +lazy val plugin = Project(id = "paradise", base = file("plugin")) + .settings( + sharedSettings, + assemblySettings, + resourceDirectory in Compile <<= + baseDirectory(_ / "src" / "main" / "scala" / "org" / "scalameta" / "paradise" / "embedded"), + libraryDependencies ++= Seq( + "org.scalameta" %% "scalameta" % MetaVersion, + "org.scala-lang" % "scala-library" % scalaVersion.value, + "org.scala-lang" % "scala-reflect" % scalaVersion.value, + "org.scala-lang" % "scala-compiler" % scalaVersion.value + ), + // NOTE: here we depend on the old paradise to build the new one. this is intended. + addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full), + test in assembly := {}, + logLevel in assembly := Level.Error, + jarName in assembly := name.value + "_" + scalaVersion.value + "-" + version.value + "-assembly.jar", + assemblyOption in assembly ~= { _.copy(includeScala = false) }, + Keys.`package` in Compile := { + val slimJar = (Keys.`package` in Compile).value + val fatJar = + new File(crossTarget.value + "/" + (jarName in assembly).value) + val _ = assembly.value + IO.copy(List(fatJar -> slimJar), overwrite = true) + slimJar + }, + packagedArtifact in Compile in packageBin := { + val temp = (packagedArtifact in Compile in packageBin).value + val (art, slimJar) = temp + val fatJar = + new File(crossTarget.value + "/" + (jarName in assembly).value) + val _ = assembly.value + IO.copy(List(fatJar -> slimJar), overwrite = true) + (art, slimJar) + }, + publishMavenStyle := true, + publishArtifact in Test := false, + publishTo <<= version { v: String => + val nexus = "https://oss.sonatype.org/" + if (v.trim.endsWith("SNAPSHOT")) + Some("snapshots" at nexus + "content/repositories/snapshots") + else + Some("releases" at nexus + "service/local/staging/deploy/maven2") + }, + pomIncludeRepository := { x => + false + }, + pomExtra := ( + https://github.com/scalameta/paradise + 2012 + + + BSD 3-Clause + https://github.com/scalameta/paradise/blob/master/LICENSE.md + repo + + + + git://github.com/scalameta/paradise.git + scm:git:git://github.com/scalameta/paradise.git + + + GitHub + https://github.com/scalameta/paradise/issues + + + + xeno-by + Eugene Burmako + http://xeno.by + + + ), + credentials ++= loadCredentials() + ) + +lazy val testsCommon = project + .in(file("tests/common")) + .settings( + sharedSettings, + testSettings + ) + +// macro annotation tests, requires a clean on every compile to outsmart incremental compiler. +lazy val testsAnnotationsReflect = project + .in(file("tests/annotations-reflect")) + .settings( + sharedSettings, + usePluginSettings, + testSettings, + exposePaths("testsAnnotationsReflect", Test) + ) + .dependsOn(testsCommon) + +// macro annotation tests, requires a clean on every compile to outsmart incremental compiler. +lazy val testsAnnotationsMeta = project + .in(file("tests/annotations-meta")) + .settings( + sharedSettings, + usePluginSettings, + testSettings, + exposePaths("testsAnnotationsMeta", Test) + ) + .dependsOn(testsCommon) diff --git a/project/build.properties b/project/build.properties index be6c454f..43b8278c 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.5 +sbt.version=0.13.11 diff --git a/project/build.scala b/project/build.scala deleted file mode 100644 index 8ecdd1a1..00000000 --- a/project/build.scala +++ /dev/null @@ -1,198 +0,0 @@ -import sbt._ -import Keys._ -import sbtassembly.Plugin._ -import AssemblyKeys._ - -object build extends Build { - lazy val ScalaVersions = Seq("2.11.8") - lazy val MetaVersion = "1.2.0-SNAPSHOT" - - lazy val sharedSettings = Defaults.defaultSettings ++ Seq( - scalaVersion := ScalaVersions.head, - crossVersion := CrossVersion.full, - version := "3.0.0-SNAPSHOT", - organization := "org.scalameta", - description := "Empowers production Scala compiler with latest macro developments", - resolvers += Resolver.sonatypeRepo("snapshots"), - resolvers += Resolver.sonatypeRepo("releases"), - publishMavenStyle := true, - publishArtifact in Test := false, - scalacOptions ++= Seq("-deprecation", "-feature"), - parallelExecution in Test := false, // hello, reflection sync!! - logBuffered := false, - scalaHome := { - val scalaHome = System.getProperty("paradise.scala.home") - if (scalaHome != null) { - println(s"Going for custom scala home at $scalaHome") - Some(file(scalaHome)) - } else None - } - ) - - def loadCredentials(): List[Credentials] = { - val mavenSettingsFile = System.getProperty("maven.settings.file") - if (mavenSettingsFile != null) { - println("Loading Sonatype credentials from " + mavenSettingsFile) - try { - import scala.xml._ - val settings = XML.loadFile(mavenSettingsFile) - def readServerConfig(key: String) = - (settings \\ "settings" \\ "servers" \\ "server" \\ key).head.text - List( - Credentials( - "Sonatype Nexus Repository Manager", - "oss.sonatype.org", - readServerConfig("username"), - readServerConfig("password") - )) - } catch { - case ex: Exception => - println("Failed to load Maven settings from " + mavenSettingsFile + ": " + ex) - Nil - } - } else { - // println("Sonatype credentials cannot be loaded: -Dmaven.settings.file is not specified.") - Nil - } - } - - lazy val root = Project( - id = "root", - base = file("root") - ) settings ( - sharedSettings: _* - ) settings ( - packagedArtifacts := Map.empty, - aggregate in test := false, - test := (test in tests in Test).value - ) aggregate ( - plugin, - tests - ) - - lazy val plugin = Project( - id = "paradise", - base = file("plugin") - ) settings ( - sharedSettings: _* - ) settings ( - assemblySettings: _* - ) settings ( - resourceDirectory in Compile <<= baseDirectory( - _ / "src" / "main" / "scala" / "org" / "scalameta" / "paradise" / "embedded"), - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-library" % _), - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _), - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _), - libraryDependencies += "org.scalameta" %% "scalameta" % MetaVersion, - // NOTE: here we depend on the old paradise to build the new one. this is intended. - addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full), - test in assembly := {}, - logLevel in assembly := Level.Error, - jarName in assembly := name.value + "_" + scalaVersion.value + "-" + version.value + "-assembly.jar", - assemblyOption in assembly ~= { _.copy(includeScala = false) }, - Keys.`package` in Compile := { - val slimJar = (Keys.`package` in Compile).value - val fatJar = new File(crossTarget.value + "/" + (jarName in assembly).value) - val _ = assembly.value - IO.copy(List(fatJar -> slimJar), overwrite = true) - slimJar - }, - packagedArtifact in Compile in packageBin := { - val temp = (packagedArtifact in Compile in packageBin).value - val (art, slimJar) = temp - val fatJar = new File(crossTarget.value + "/" + (jarName in assembly).value) - val _ = assembly.value - IO.copy(List(fatJar -> slimJar), overwrite = true) - (art, slimJar) - }, - publishMavenStyle := true, - publishArtifact in Test := false, - publishTo <<= version { v: String => - val nexus = "https://oss.sonatype.org/" - if (v.trim.endsWith("SNAPSHOT")) - Some("snapshots" at nexus + "content/repositories/snapshots") - else - Some("releases" at nexus + "service/local/staging/deploy/maven2") - }, - pomIncludeRepository := { x => - false - }, - pomExtra := ( - https://github.com/scalameta/paradise - 2012 - - - BSD-like - http://www.scala-lang.org/downloads/license.html - repo - - - - git://github.com/scalameta/paradise.git - scm:git:git://github.com/scalameta/paradise.git - - - GitHub - https://github.com/scalameta/paradise/issues - - - - xeno-by - Eugene Burmako - http://xeno.by - - - ), - credentials ++= loadCredentials() - ) - - lazy val usePluginSettings = Seq( - scalacOptions in Compile <++= (Keys.`package` in (plugin, Compile)) map { (jar: File) => - System.setProperty("sbt.paths.plugin.jar", jar.getAbsolutePath) - val addPlugin = "-Xplugin:" + jar.getAbsolutePath - // Thanks Jason for this cool idea (taken from https://github.com/retronym/boxer) - // add plugin timestamp to compiler options to trigger recompile of - // main after editing the plugin. (Otherwise a 'clean' is needed.) - val dummy = "-Jdummy=" + jar.lastModified - Seq(addPlugin, dummy) - } - ) - - lazy val tests = Project( - id = "tests", - base = file("tests") - ) settings ( - sharedSettings ++ usePluginSettings: _* - ) settings ( - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-reflect" % _), - libraryDependencies <+= (scalaVersion)("org.scala-lang" % "scala-compiler" % _), - libraryDependencies += "org.scalameta" %% "scalameta" % MetaVersion, - libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.0" % "test", - libraryDependencies += "org.scalacheck" % "scalacheck_2.11" % "1.10.2-SNAPSHOT" % "test", - scalacOptions += "-Ywarn-unused-import", - scalacOptions += "-Xfatal-warnings", - publishArtifact in Compile := false, - unmanagedSourceDirectories in Test <<= (scalaSource in Test) { (root: File) => - // TODO: I haven't yet ported negative tests to SBT, so for now I'm excluding them - val (anns :: Nil, others) = root.listFiles.toList.partition(_.getName == "annotations") - val oldAnns = anns.listFiles.find(_.getName == "old").get - val (oldNegAnns, oldOtherAnns) = oldAnns.listFiles.toList.partition(_.getName == "neg") - val newAnns = anns.listFiles.find(_.getName == "new").get - val newAllAnns = newAnns.listFiles.toList - System.setProperty( - "sbt.paths.tests.scaladoc", - oldAnns.listFiles.toList.filter(_.getName == "scaladoc").head.getAbsolutePath) - others ++ oldOtherAnns ++ newAllAnns - }, - fullClasspath in Test := { - val testcp = (fullClasspath in Test).value.files - .map(_.getAbsolutePath) - .mkString(java.io.File.pathSeparatorChar.toString) - sys.props("sbt.paths.tests.classpath") = testcp - (fullClasspath in Test).value - }, - scalacOptions ++= Seq() - // scalacOptions ++= Seq("-Xprint:typer") - // scalacOptions ++= Seq("-Xlog-implicits") - ) -} diff --git a/tests/annotations-meta/src/main/scala/append.scala b/tests/annotations-meta/src/main/scala/append.scala new file mode 100644 index 00000000..a54f8e01 --- /dev/null +++ b/tests/annotations-meta/src/main/scala/append.scala @@ -0,0 +1,41 @@ +import scala.annotation.StaticAnnotation +import scala.meta._ + +class appendA extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + AppendHelpers.appendStat(defn, "letters += 'a'") + } +} + +class appendB extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + AppendHelpers.appendStat(defn, "letters += 'b'") + + } +} + +class appendC extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + AppendHelpers.appendStat(defn, "letters += 'c'") + } +} + +object AppendHelpers { + def appendStat(defn: Tree, stat: String) = { + val parsedStat = stat.parse[Stat].get + + defn match { + case q"""..$mods def $name[..$tparams](...$paramss): $tpeopt = { + ..${ stats: scala.collection.immutable.Seq[Stat] } + }""" => + q"..$mods def $name[..$tparams](...$paramss): $tpeopt = { ..$stats; $parsedStat}" + case q"..$mods def $name[..$tparams](...$paramss): $tpeopt = $expr" => + q"..$mods def $name[..$tparams](...$paramss): $tpeopt = { $expr; $parsedStat }" + } + + } +} + +package placebo { + class appendA extends StaticAnnotation +} diff --git a/tests/src/main/scala/annotations/new/main/CompanionMacros.scala b/tests/annotations-meta/src/main/scala/companion.scala similarity index 87% rename from tests/src/main/scala/annotations/new/main/CompanionMacros.scala rename to tests/annotations-meta/src/main/scala/companion.scala index 93b80f6c..4b733fdb 100644 --- a/tests/src/main/scala/annotations/new/main/CompanionMacros.scala +++ b/tests/annotations-meta/src/main/scala/companion.scala @@ -1,10 +1,7 @@ -package main - -import scala.annotation.compileTimeOnly +import scala.annotation.StaticAnnotation import scala.meta._ -@compileTimeOnly("@classMacro not expanded") -class classMacro extends scala.annotation.StaticAnnotation { +class companion extends StaticAnnotation { inline def apply(stats: Any): Any = meta { def extractClass(classDefn: Defn.Class): Stat = { diff --git a/tests/annotations-meta/src/main/scala/helloWorld.scala b/tests/annotations-meta/src/main/scala/helloWorld.scala new file mode 100644 index 00000000..08a70c62 --- /dev/null +++ b/tests/annotations-meta/src/main/scala/helloWorld.scala @@ -0,0 +1,9 @@ +import scala.annotation.StaticAnnotation +import scala.meta._ + +class helloWorld extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + val q"..$mods def $name[..$tparams](...$paramss): $tpeopt = $expr" = defn + q"""..$mods def $name[..$tparams](...$paramss): $tpeopt = "hello world"""" + } +} \ No newline at end of file diff --git a/tests/annotations-meta/src/main/scala/identity.scala b/tests/annotations-meta/src/main/scala/identity.scala new file mode 100644 index 00000000..4f383132 --- /dev/null +++ b/tests/annotations-meta/src/main/scala/identity.scala @@ -0,0 +1,7 @@ +import scala.annotation.StaticAnnotation + +class identity extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + defn + } +} diff --git a/tests/annotations-meta/src/main/scala/mainWithParams.scala b/tests/annotations-meta/src/main/scala/mainWithParams.scala new file mode 100644 index 00000000..4f22e72f --- /dev/null +++ b/tests/annotations-meta/src/main/scala/mainWithParams.scala @@ -0,0 +1,9 @@ +import scala.annotation.StaticAnnotation +import scala.meta._ + +class param(some: String) extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + val q"new $_($string)" = this + defn + } +} diff --git a/tests/annotations-meta/src/main/scala/namedParam.scala b/tests/annotations-meta/src/main/scala/namedParam.scala new file mode 100644 index 00000000..f7b2eeef --- /dev/null +++ b/tests/annotations-meta/src/main/scala/namedParam.scala @@ -0,0 +1,9 @@ +import scala.annotation.StaticAnnotation +import scala.meta._ + +class namedParam(some: String) extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + val q"new $_(some = $string)" = this + defn + } +} diff --git a/tests/src/main/scala/annotations/old/placebo.scala b/tests/annotations-meta/src/main/scala/placebo.scala similarity index 100% rename from tests/src/main/scala/annotations/old/placebo.scala rename to tests/annotations-meta/src/main/scala/placebo.scala diff --git a/tests/annotations-meta/src/main/scala/repeatedParam.scala b/tests/annotations-meta/src/main/scala/repeatedParam.scala new file mode 100644 index 00000000..cb8d20e0 --- /dev/null +++ b/tests/annotations-meta/src/main/scala/repeatedParam.scala @@ -0,0 +1,7 @@ +import scala.annotation.StaticAnnotation + +class repeatedParam(foos: Any*) extends StaticAnnotation { + inline def apply(defn: Any): Any = meta { + defn + } +} diff --git a/tests/src/test/scala/annotations/new/transform/Transform.scala b/tests/annotations-meta/src/test/scala/compile/Desugaring.scala similarity index 97% rename from tests/src/test/scala/annotations/new/transform/Transform.scala rename to tests/annotations-meta/src/test/scala/compile/Desugaring.scala index 8f710887..489e41d3 100644 --- a/tests/src/test/scala/annotations/new/transform/Transform.scala +++ b/tests/annotations-meta/src/test/scala/compile/Desugaring.scala @@ -2,7 +2,7 @@ import java.io._ import scala.compat.Platform.EOL import scala.tools.nsc._ -class Transform extends ToolSuite { +class Desugaring extends ToolSuite("testsAnnotationsMeta") { test("simple transform") { val testDir = File.createTempFile("testDir", System.nanoTime.toString) if (!testDir.delete) sys.error("fatal error: can't delete " + testDir.getAbsolutePath) diff --git a/tests/src/test/scala/annotations/new/main/ExpansionTests.scala b/tests/annotations-meta/src/test/scala/compile/Expansion.scala similarity index 77% rename from tests/src/test/scala/annotations/new/main/ExpansionTests.scala rename to tests/annotations-meta/src/test/scala/compile/Expansion.scala index eb1f0bd1..19b7d1fe 100644 --- a/tests/src/test/scala/annotations/new/main/ExpansionTests.scala +++ b/tests/annotations-meta/src/test/scala/compile/Expansion.scala @@ -1,8 +1,7 @@ -import main._ import org.scalatest.FunSuite // TODO: DavidDudson: simplify with argument macros -class ExpansionTests extends FunSuite { +class Expansion extends FunSuite { test("Nested macro should expand with identity") { @identity @@ -166,7 +165,7 @@ class ExpansionTests extends FunSuite { assert(letters === "a") } - test("Placebo in package doesnt accidentally get removed if second") { + test("Placebo in package doesn't accidentally get removed if second") { var letters = "" @appendA @@ -178,7 +177,7 @@ class ExpansionTests extends FunSuite { assert(letters === "a") } - test("Placebo in package doesnt accidentally get removed if first") { + test("Placebo in package doesn't accidentally get removed if first") { var letters = "" @placebo.appendA @@ -189,4 +188,39 @@ class ExpansionTests extends FunSuite { assert(letters === "a") } + + test("Regular arguments are supported") { + @param("hello world") + class SomeClass1 + } + + test("Named arguments are supported") { + @namedParam(some = "text") + class SomeClass2 + } + + test("Repeated arguments are supported") { + @repeatedParam(foos: _*) + class SomeClass3 + } + + test("Annotations on classes expand not only classes, but also companion objects") { + trait Bar { + val k: Int = 3 + } + + @companion + class Foo(id: Int) { + val i: Int = 1 + } + + object Foo extends Bar { + val j: Int = 2 + } + + @companion + class Baz(id: Int) { + val a: String = "abc" + } + } } diff --git a/tests/src/test/scala/annotations/new/main/TestMods.scala b/tests/annotations-meta/src/test/scala/compile/Identity.scala similarity index 60% rename from tests/src/test/scala/annotations/new/main/TestMods.scala rename to tests/annotations-meta/src/test/scala/compile/Identity.scala index a5ee484c..8b26f550 100644 --- a/tests/src/test/scala/annotations/new/main/TestMods.scala +++ b/tests/annotations-meta/src/test/scala/compile/Identity.scala @@ -1,15 +1,13 @@ -package main - @identity case class Test1() @identity() case class Test2() -@main.identity +@identity case class Test3() -@main.identity() +@identity() case class Test4() @identity @@ -17,18 +15,6 @@ object Test5 { override val toString = "Test5" } -@main -object TestMods { - case class Message(msg: String) - println(Message("hello world").msg) - - println(Test1().productPrefix) - println(Test2().productPrefix) - println(Test3().productPrefix) - println(Test4().productPrefix) - println(Test5.toString) -} - @identity object NamedArg { case class MyCaseClass(a: Int, b: Int) diff --git a/tests/src/test/scala/annotations/new/syntax/Repl.scala b/tests/annotations-meta/src/test/scala/repl/Repl.scala similarity index 96% rename from tests/src/test/scala/annotations/new/syntax/Repl.scala rename to tests/annotations-meta/src/test/scala/repl/Repl.scala index 54b012b8..7a81f87a 100644 --- a/tests/src/test/scala/annotations/new/syntax/Repl.scala +++ b/tests/annotations-meta/src/test/scala/repl/Repl.scala @@ -1,4 +1,4 @@ -class NewRepl extends ReplSuite { +class Repl extends ReplSuite("testsAnnotationsMeta") { // TODO: testing this would require filtering the classpath // so that it doesn't have scala.meta libraries anymore // diff --git a/tests/src/main/scala/annotations/old/argumentative.scala b/tests/annotations-reflect/src/main/scala/argumentative.scala similarity index 100% rename from tests/src/main/scala/annotations/old/argumentative.scala rename to tests/annotations-reflect/src/main/scala/argumentative.scala diff --git a/tests/src/main/scala/annotations/old/doubler.scala b/tests/annotations-reflect/src/main/scala/doubler.scala similarity index 100% rename from tests/src/main/scala/annotations/old/doubler.scala rename to tests/annotations-reflect/src/main/scala/doubler.scala diff --git a/tests/src/main/scala/annotations/old/explorer.scala b/tests/annotations-reflect/src/main/scala/explorer.scala similarity index 100% rename from tests/src/main/scala/annotations/old/explorer.scala rename to tests/annotations-reflect/src/main/scala/explorer.scala diff --git a/tests/src/main/scala/annotations/old/funny.scala b/tests/annotations-reflect/src/main/scala/funny.scala similarity index 100% rename from tests/src/main/scala/annotations/old/funny.scala rename to tests/annotations-reflect/src/main/scala/funny.scala diff --git a/tests/src/main/scala/annotations/old/happytee.scala b/tests/annotations-reflect/src/main/scala/happytee.scala similarity index 100% rename from tests/src/main/scala/annotations/old/happytee.scala rename to tests/annotations-reflect/src/main/scala/happytee.scala diff --git a/tests/src/main/scala/annotations/old/hello.scala b/tests/annotations-reflect/src/main/scala/hello.scala similarity index 100% rename from tests/src/main/scala/annotations/old/hello.scala rename to tests/annotations-reflect/src/main/scala/hello.scala diff --git a/tests/src/main/scala/annotations/old/identity.scala b/tests/annotations-reflect/src/main/scala/identity.scala similarity index 100% rename from tests/src/main/scala/annotations/old/identity.scala rename to tests/annotations-reflect/src/main/scala/identity.scala diff --git a/tests/src/main/scala/annotations/old/kase.scala b/tests/annotations-reflect/src/main/scala/kase.scala similarity index 100% rename from tests/src/main/scala/annotations/old/kase.scala rename to tests/annotations-reflect/src/main/scala/kase.scala diff --git a/tests/annotations-reflect/src/main/scala/placebo.scala b/tests/annotations-reflect/src/main/scala/placebo.scala new file mode 100644 index 00000000..6f90b00e --- /dev/null +++ b/tests/annotations-reflect/src/main/scala/placebo.scala @@ -0,0 +1,5 @@ +class placebo extends scala.annotation.StaticAnnotation + +package pkg { + class placebo extends scala.annotation.StaticAnnotation +} \ No newline at end of file diff --git a/tests/src/main/scala/annotations/old/pretty.scala b/tests/annotations-reflect/src/main/scala/pretty.scala similarity index 100% rename from tests/src/main/scala/annotations/old/pretty.scala rename to tests/annotations-reflect/src/main/scala/pretty.scala diff --git a/tests/src/main/scala/annotations/old/shove.scala b/tests/annotations-reflect/src/main/scala/shove.scala similarity index 100% rename from tests/src/main/scala/annotations/old/shove.scala rename to tests/annotations-reflect/src/main/scala/shove.scala diff --git a/tests/src/main/scala/annotations/old/simulacrum.scala b/tests/annotations-reflect/src/main/scala/simulacrum.scala similarity index 100% rename from tests/src/main/scala/annotations/old/simulacrum.scala rename to tests/annotations-reflect/src/main/scala/simulacrum.scala diff --git a/tests/src/main/scala/annotations/old/social.scala b/tests/annotations-reflect/src/main/scala/social.scala similarity index 100% rename from tests/src/main/scala/annotations/old/social.scala rename to tests/annotations-reflect/src/main/scala/social.scala diff --git a/tests/src/main/scala/annotations/old/thingy.scala b/tests/annotations-reflect/src/main/scala/thingy.scala similarity index 100% rename from tests/src/main/scala/annotations/old/thingy.scala rename to tests/annotations-reflect/src/main/scala/thingy.scala diff --git a/tests/src/test/scala/annotations/old/scaladoc/resources/Simulacrum.check b/tests/annotations-reflect/src/test/resources/doc/Simulacrum.check similarity index 100% rename from tests/src/test/scala/annotations/old/scaladoc/resources/Simulacrum.check rename to tests/annotations-reflect/src/test/resources/doc/Simulacrum.check diff --git a/tests/src/test/scala/annotations/old/scaladoc/resources/Simulacrum/Test.scala b/tests/annotations-reflect/src/test/resources/doc/Simulacrum/Test.scala similarity index 100% rename from tests/src/test/scala/annotations/old/scaladoc/resources/Simulacrum/Test.scala rename to tests/annotations-reflect/src/test/resources/doc/Simulacrum/Test.scala diff --git a/tests/src/test/scala/annotations/old/run/42/42.scala b/tests/annotations-reflect/src/test/scala/compile/42/42.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/42/42.scala rename to tests/annotations-reflect/src/test/scala/compile/42/42.scala diff --git a/tests/src/test/scala/annotations/old/run/Acyclic.scala b/tests/annotations-reflect/src/test/scala/compile/Acyclic.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Acyclic.scala rename to tests/annotations-reflect/src/test/scala/compile/Acyclic.scala diff --git a/tests/src/test/scala/annotations/old/run/Argumentative.scala b/tests/annotations-reflect/src/test/scala/compile/Argumentative.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Argumentative.scala rename to tests/annotations-reflect/src/test/scala/compile/Argumentative.scala diff --git a/tests/src/test/scala/annotations/old/run/Assorted.scala b/tests/annotations-reflect/src/test/scala/compile/Assorted.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Assorted.scala rename to tests/annotations-reflect/src/test/scala/compile/Assorted.scala diff --git a/tests/src/test/scala/annotations/old/run/Definition.scala b/tests/annotations-reflect/src/test/scala/compile/Definition.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Definition.scala rename to tests/annotations-reflect/src/test/scala/compile/Definition.scala diff --git a/tests/src/test/scala/annotations/old/run/InteropCaseSynthesis.scala b/tests/annotations-reflect/src/test/scala/compile/InteropCaseSynthesis.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/InteropCaseSynthesis.scala rename to tests/annotations-reflect/src/test/scala/compile/InteropCaseSynthesis.scala diff --git a/tests/src/test/scala/annotations/old/run/Issue09.scala b/tests/annotations-reflect/src/test/scala/compile/Issue09.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Issue09.scala rename to tests/annotations-reflect/src/test/scala/compile/Issue09.scala diff --git a/tests/src/test/scala/annotations/old/run/Issue10.scala b/tests/annotations-reflect/src/test/scala/compile/Issue10.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Issue10.scala rename to tests/annotations-reflect/src/test/scala/compile/Issue10.scala diff --git a/tests/src/test/scala/annotations/old/run/KaseClass.scala b/tests/annotations-reflect/src/test/scala/compile/KaseClass.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KaseClass.scala rename to tests/annotations-reflect/src/test/scala/compile/KaseClass.scala diff --git a/tests/src/test/scala/annotations/old/run/KaseIdentityClass.scala b/tests/annotations-reflect/src/test/scala/compile/KaseIdentityClass.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KaseIdentityClass.scala rename to tests/annotations-reflect/src/test/scala/compile/KaseIdentityClass.scala diff --git a/tests/src/test/scala/annotations/old/run/KaseIdentityObject.scala b/tests/annotations-reflect/src/test/scala/compile/KaseIdentityObject.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KaseIdentityObject.scala rename to tests/annotations-reflect/src/test/scala/compile/KaseIdentityObject.scala diff --git a/tests/src/test/scala/annotations/old/run/KaseObject.scala b/tests/annotations-reflect/src/test/scala/compile/KaseObject.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KaseObject.scala rename to tests/annotations-reflect/src/test/scala/compile/KaseObject.scala diff --git a/tests/src/test/scala/annotations/old/run/KasePlaceboClass.scala b/tests/annotations-reflect/src/test/scala/compile/KasePlaceboClass.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KasePlaceboClass.scala rename to tests/annotations-reflect/src/test/scala/compile/KasePlaceboClass.scala diff --git a/tests/src/test/scala/annotations/old/run/KasePlaceboObject.scala b/tests/annotations-reflect/src/test/scala/compile/KasePlaceboObject.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KasePlaceboObject.scala rename to tests/annotations-reflect/src/test/scala/compile/KasePlaceboObject.scala diff --git a/tests/src/test/scala/annotations/old/run/KaseThorough.scala b/tests/annotations-reflect/src/test/scala/compile/KaseThorough.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/KaseThorough.scala rename to tests/annotations-reflect/src/test/scala/compile/KaseThorough.scala diff --git a/tests/src/test/scala/annotations/old/run/Multiple.scala b/tests/annotations-reflect/src/test/scala/compile/Multiple.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Multiple.scala rename to tests/annotations-reflect/src/test/scala/compile/Multiple.scala diff --git a/tests/src/test/scala/annotations/old/run/NameResolution.scala b/tests/annotations-reflect/src/test/scala/compile/NameResolution.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/NameResolution.scala rename to tests/annotations-reflect/src/test/scala/compile/NameResolution.scala diff --git a/tests/src/test/scala/annotations/old/run/PackageObject.scala b/tests/annotations-reflect/src/test/scala/compile/PackageObject.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/PackageObject.scala rename to tests/annotations-reflect/src/test/scala/compile/PackageObject.scala diff --git a/tests/src/test/scala/annotations/old/run/PackagePackageObject.scala b/tests/annotations-reflect/src/test/scala/compile/PackagePackageObject.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/PackagePackageObject.scala rename to tests/annotations-reflect/src/test/scala/compile/PackagePackageObject.scala diff --git a/tests/src/test/scala/annotations/old/run/Parameters.scala b/tests/annotations-reflect/src/test/scala/compile/Parameters.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Parameters.scala rename to tests/annotations-reflect/src/test/scala/compile/Parameters.scala diff --git a/tests/src/test/scala/annotations/old/run/PlaceboAssorted.scala b/tests/annotations-reflect/src/test/scala/compile/PlaceboAssorted.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/PlaceboAssorted.scala rename to tests/annotations-reflect/src/test/scala/compile/PlaceboAssorted.scala diff --git a/tests/src/test/scala/annotations/old/run/PlaceboClass.scala b/tests/annotations-reflect/src/test/scala/compile/PlaceboClass.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/PlaceboClass.scala rename to tests/annotations-reflect/src/test/scala/compile/PlaceboClass.scala diff --git a/tests/src/test/scala/annotations/old/run/PlaceboObject.scala b/tests/annotations-reflect/src/test/scala/compile/PlaceboObject.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/PlaceboObject.scala rename to tests/annotations-reflect/src/test/scala/compile/PlaceboObject.scala diff --git a/tests/src/test/scala/annotations/old/run/PlaceboParameters.scala b/tests/annotations-reflect/src/test/scala/compile/PlaceboParameters.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/PlaceboParameters.scala rename to tests/annotations-reflect/src/test/scala/compile/PlaceboParameters.scala diff --git a/tests/src/test/scala/annotations/old/run/Recursive.scala b/tests/annotations-reflect/src/test/scala/compile/Recursive.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Recursive.scala rename to tests/annotations-reflect/src/test/scala/compile/Recursive.scala diff --git a/tests/src/test/scala/annotations/old/run/Scopes.scala b/tests/annotations-reflect/src/test/scala/compile/Scopes.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/Scopes.scala rename to tests/annotations-reflect/src/test/scala/compile/Scopes.scala diff --git a/tests/src/test/scala/annotations/old/run/TypeArgs.scala b/tests/annotations-reflect/src/test/scala/compile/TypeArgs.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/TypeArgs.scala rename to tests/annotations-reflect/src/test/scala/compile/TypeArgs.scala diff --git a/tests/src/test/scala/annotations/old/run/acyclic-a/C.scala b/tests/annotations-reflect/src/test/scala/compile/acyclic-a/C.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/acyclic-a/C.scala rename to tests/annotations-reflect/src/test/scala/compile/acyclic-a/C.scala diff --git a/tests/src/test/scala/annotations/old/run/acyclic-a/D.scala b/tests/annotations-reflect/src/test/scala/compile/acyclic-a/D.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/acyclic-a/D.scala rename to tests/annotations-reflect/src/test/scala/compile/acyclic-a/D.scala diff --git a/tests/src/test/scala/annotations/old/run/acyclic-b/C.scala b/tests/annotations-reflect/src/test/scala/compile/acyclic-b/C.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/acyclic-b/C.scala rename to tests/annotations-reflect/src/test/scala/compile/acyclic-b/C.scala diff --git a/tests/src/test/scala/annotations/old/run/acyclic-b/D.scala b/tests/annotations-reflect/src/test/scala/compile/acyclic-b/D.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/acyclic-b/D.scala rename to tests/annotations-reflect/src/test/scala/compile/acyclic-b/D.scala diff --git a/tests/src/test/scala/annotations/old/run/companion-symbol-of/A.scala b/tests/annotations-reflect/src/test/scala/compile/companion-symbol-of/A.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/companion-symbol-of/A.scala rename to tests/annotations-reflect/src/test/scala/compile/companion-symbol-of/A.scala diff --git a/tests/src/test/scala/annotations/old/run/companion-symbol-of/B.scala b/tests/annotations-reflect/src/test/scala/compile/companion-symbol-of/B.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/companion-symbol-of/B.scala rename to tests/annotations-reflect/src/test/scala/compile/companion-symbol-of/B.scala diff --git a/tests/src/test/scala/annotations/old/run/companion-symbol-of/C.scala b/tests/annotations-reflect/src/test/scala/compile/companion-symbol-of/C.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/companion-symbol-of/C.scala rename to tests/annotations-reflect/src/test/scala/compile/companion-symbol-of/C.scala diff --git a/tests/src/test/scala/annotations/old/run/issue10/Test1.scala b/tests/annotations-reflect/src/test/scala/compile/issue10/Test1.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue10/Test1.scala rename to tests/annotations-reflect/src/test/scala/compile/issue10/Test1.scala diff --git a/tests/src/test/scala/annotations/old/run/issue10/Test2.scala b/tests/annotations-reflect/src/test/scala/compile/issue10/Test2.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue10/Test2.scala rename to tests/annotations-reflect/src/test/scala/compile/issue10/Test2.scala diff --git a/tests/src/test/scala/annotations/old/run/issue14/Test1.scala b/tests/annotations-reflect/src/test/scala/compile/issue14/Test1.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue14/Test1.scala rename to tests/annotations-reflect/src/test/scala/compile/issue14/Test1.scala diff --git a/tests/src/test/scala/annotations/old/run/issue14/Test2.scala b/tests/annotations-reflect/src/test/scala/compile/issue14/Test2.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue14/Test2.scala rename to tests/annotations-reflect/src/test/scala/compile/issue14/Test2.scala diff --git a/tests/src/test/scala/annotations/old/run/issue46/Test.scala b/tests/annotations-reflect/src/test/scala/compile/issue46/Test.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue46/Test.scala rename to tests/annotations-reflect/src/test/scala/compile/issue46/Test.scala diff --git a/tests/src/test/scala/annotations/old/run/issue48/Test1.scala b/tests/annotations-reflect/src/test/scala/compile/issue48/Test1.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue48/Test1.scala rename to tests/annotations-reflect/src/test/scala/compile/issue48/Test1.scala diff --git a/tests/src/test/scala/annotations/old/run/issue48/Test2.scala b/tests/annotations-reflect/src/test/scala/compile/issue48/Test2.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue48/Test2.scala rename to tests/annotations-reflect/src/test/scala/compile/issue48/Test2.scala diff --git a/tests/src/test/scala/annotations/old/run/issue64/Test.scala b/tests/annotations-reflect/src/test/scala/compile/issue64/Test.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/issue64/Test.scala rename to tests/annotations-reflect/src/test/scala/compile/issue64/Test.scala diff --git a/tests/src/test/scala/annotations/old/run/module-class/A.scala b/tests/annotations-reflect/src/test/scala/compile/module-class/A.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/module-class/A.scala rename to tests/annotations-reflect/src/test/scala/compile/module-class/A.scala diff --git a/tests/src/test/scala/annotations/old/run/module-class/B.scala b/tests/annotations-reflect/src/test/scala/compile/module-class/B.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/module-class/B.scala rename to tests/annotations-reflect/src/test/scala/compile/module-class/B.scala diff --git a/tests/src/test/scala/annotations/old/run/scopes/A.scala b/tests/annotations-reflect/src/test/scala/compile/scopes/A.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/scopes/A.scala rename to tests/annotations-reflect/src/test/scala/compile/scopes/A.scala diff --git a/tests/src/test/scala/annotations/old/run/scopes/B.scala b/tests/annotations-reflect/src/test/scala/compile/scopes/B.scala similarity index 100% rename from tests/src/test/scala/annotations/old/run/scopes/B.scala rename to tests/annotations-reflect/src/test/scala/compile/scopes/B.scala diff --git a/tests/src/test/scala/annotations/old/scaladoc/ScaladocSuite.scala b/tests/annotations-reflect/src/test/scala/doc/Scaladoc.scala similarity index 75% rename from tests/src/test/scala/annotations/old/scaladoc/ScaladocSuite.scala rename to tests/annotations-reflect/src/test/scala/doc/Scaladoc.scala index eebe4a9e..ef200ced 100644 --- a/tests/src/test/scala/annotations/old/scaladoc/ScaladocSuite.scala +++ b/tests/annotations-reflect/src/test/scala/doc/Scaladoc.scala @@ -3,9 +3,9 @@ import scala.compat.Platform.EOL import scala.io.Source import scala.tools.nsc.ScalaDoc -class ScaladocSuite extends ToolSuite { - val resourceDir = new File( - System.getProperty("sbt.paths.tests.scaladoc") + File.separatorChar + "resources") +class Scaladoc extends ToolSuite("testsAnnotationsReflect") { + val resourceDir = new File(System + .getProperty("sbt.paths.testsAnnotationsReflect.test.resources") + File.separatorChar + "doc") val testDirs = resourceDir .listFiles() .filter(_.isDirectory) diff --git a/tests/src/test/scala/annotations/old/repl/Repl.scala b/tests/annotations-reflect/src/test/scala/repl/Repl.scala similarity index 98% rename from tests/src/test/scala/annotations/old/repl/Repl.scala rename to tests/annotations-reflect/src/test/scala/repl/Repl.scala index fd4dff46..5db2dc28 100644 --- a/tests/src/test/scala/annotations/old/repl/Repl.scala +++ b/tests/annotations-reflect/src/test/scala/repl/Repl.scala @@ -1,4 +1,4 @@ -class Repl extends ReplSuite { +class Repl extends ReplSuite("testsAnnotationsReflect") { test("precompiled macros expand") { assert(repl(""" |@thingy class Thingy diff --git a/tests/src/test/scala/DisableScalaColor.scala b/tests/common/src/main/scala/DisableScalaColor.scala similarity index 100% rename from tests/src/test/scala/DisableScalaColor.scala rename to tests/common/src/main/scala/DisableScalaColor.scala diff --git a/tests/src/test/scala/ReplSuite.scala b/tests/common/src/main/scala/ReplSuite.scala similarity index 94% rename from tests/src/test/scala/ReplSuite.scala rename to tests/common/src/main/scala/ReplSuite.scala index 47c67c8f..1e412c56 100644 --- a/tests/src/test/scala/ReplSuite.scala +++ b/tests/common/src/main/scala/ReplSuite.scala @@ -4,12 +4,12 @@ import scala.compat.Platform.EOL import scala.tools.nsc.interpreter._ import scala.tools.nsc.{Settings, MainGenericRunner} -trait ReplSuite extends ToolSuite with DisableScalaColor { +class ReplSuite(project: String) extends ToolSuite(project) with DisableScalaColor { private def replViaILoop(code: String): String = { val s = new Settings s.Xnojline.value = true s.usejavacp.value = false - s.classpath.value = sys.props("sbt.paths.tests.classpath") + s.classpath.value = sys.props("sbt.paths." + project + ".test.classes") s.plugin.value = List(sys.props("sbt.paths.plugin.jar")) val lines = ILoop.runForTranscript(code, s).lines.toList lines diff --git a/tests/src/test/scala/ToolSuite.scala b/tests/common/src/main/scala/ToolSuite.scala similarity index 94% rename from tests/src/test/scala/ToolSuite.scala rename to tests/common/src/main/scala/ToolSuite.scala index d385ec0c..fecaba7a 100644 --- a/tests/src/test/scala/ToolSuite.scala +++ b/tests/common/src/main/scala/ToolSuite.scala @@ -3,7 +3,7 @@ import java.io._ import java.nio.charset.Charset import java.security.Permission -trait ToolSuite extends FunSuite { +class ToolSuite(project: String) extends FunSuite { private def virtualizedPopen(input: String, body: => Unit): (Int, String) = { val inputStream = new ByteArrayInputStream(input.getBytes(Charset.forName("UTF-8"))) val outputStorage = new ByteArrayOutputStream() @@ -26,7 +26,7 @@ trait ToolSuite extends FunSuite { } private def commonOptions: List[String] = { - val cp = List("-cp", sys.props("sbt.paths.tests.classpath")) + val cp = List("-cp", sys.props("sbt.paths." + project + ".test.classes")) val paradise = List("-Xplugin:" + sys.props("sbt.paths.plugin.jar"), "-Xplugin-require:macroparadise") val tempDir = File.createTempFile("temp", System.nanoTime.toString); tempDir.delete(); diff --git a/tests/src/main/scala/annotations/new/main/Defs.scala b/tests/src/main/scala/annotations/new/main/Defs.scala deleted file mode 100644 index ee8b4744..00000000 --- a/tests/src/main/scala/annotations/new/main/Defs.scala +++ /dev/null @@ -1,86 +0,0 @@ -package main - -import scala.annotation.compileTimeOnly -import scala.collection.immutable -import scala.meta._ - -@compileTimeOnly("@printDef not expanded") -class printDef extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - assert(defn.is[Defn.Def]) - q"println(${defn.toString})" - } -} - -@compileTimeOnly("@printVal not expanded") -class printVal extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - assert(defn.is[Defn.Val]) - q"println(${defn.toString})" - } -} - -@compileTimeOnly("@printClass not expanded") -class printClass extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - assert(defn.is[Defn.Class]) - q"println(${defn.toString})" - } -} - -@compileTimeOnly("@identity not expanded") -class identity extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - defn - } -} - -@compileTimeOnly("@populateDef not expanded") -class helloWorld extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - val q"..$mods def $name[..$tparams](...$paramss): $tpeopt = $expr" = defn - q"""..$mods def $name[..$tparams](...$paramss): $tpeopt = "hello world"""" - } -} - -@compileTimeOnly("@appendA not expanded") -class appendA extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - Helpers.appendStat(defn, "letters += 'a'") - } -} - -@compileTimeOnly("@appendB not expanded") -class appendB extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - Helpers.appendStat(defn, "letters += 'b'") - - } -} - -@compileTimeOnly("@appendC not expanded") -class appendC extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - Helpers.appendStat(defn, "letters += 'c'") - } -} - -object Helpers { - def appendStat(defn: Tree, stat: String) = { - val parsedStat = stat.parse[Stat].get - - defn match { - case q"""..$mods def $name[..$tparams](...$paramss): $tpeopt = { - ..${ stats: immutable.Seq[Stat] } - }""" => - q"..$mods def $name[..$tparams](...$paramss): $tpeopt = { ..$stats; $parsedStat}" - case q"..$mods def $name[..$tparams](...$paramss): $tpeopt = $expr" => - q"..$mods def $name[..$tparams](...$paramss): $tpeopt = { $expr; $parsedStat }" - } - - } -} - -package placebo { - class appendA extends scala.annotation.StaticAnnotation -} diff --git a/tests/src/main/scala/annotations/new/main/Macros.scala b/tests/src/main/scala/annotations/new/main/Macros.scala deleted file mode 100644 index fc4ff862..00000000 --- a/tests/src/main/scala/annotations/new/main/Macros.scala +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import scala.annotation.compileTimeOnly -import scala.meta._ - -@compileTimeOnly("@main not expanded") -class main extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - val q"object $name { ..$stats }" = defn - - val main = q""" - def main(args: Array[String]): Unit = { ..$stats } - """ - q"object $name { $main }" - } -} diff --git a/tests/src/main/scala/annotations/new/main/MacrosWithParams.scala b/tests/src/main/scala/annotations/new/main/MacrosWithParams.scala deleted file mode 100644 index b2862bea..00000000 --- a/tests/src/main/scala/annotations/new/main/MacrosWithParams.scala +++ /dev/null @@ -1,34 +0,0 @@ -package mainWithParams - -import scala.annotation.compileTimeOnly -import scala.meta._ - -@compileTimeOnly("@mainWithParams not expanded") -class mainWithParams(greeting: String) extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - val q"new $_($greeting)" = this - val q"object $name { ..$stats }" = defn - - val main = q""" - def main(args: Array[String]): Unit = { - println($greeting) - ..$stats - } - """ - q"object $name { $main }" - } -} - -final class namedParam(some: String) extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - val q"new $_(some = $string)" = this - defn - } -} - -// todo reorganize all tests -class argRepeated(foos: Any*) extends scala.annotation.StaticAnnotation { - inline def apply(defn: Any): Any = meta { - defn - } -} diff --git a/tests/src/test/scala/annotations/new/main/Companion.scala b/tests/src/test/scala/annotations/new/main/Companion.scala deleted file mode 100644 index 9d042122..00000000 --- a/tests/src/test/scala/annotations/new/main/Companion.scala +++ /dev/null @@ -1,19 +0,0 @@ -package main - -trait Bar { - val k: Int = 3 -} - -@classMacro -class Foo(id: Int) { - val i: Int = 1 -} - -object Foo extends Bar { - val j: Int = 2 -} - -@classMacro -class Baz(id: Int) { - val a: String = "abc" -} diff --git a/tests/src/test/scala/annotations/new/main/PrintDefn.scala b/tests/src/test/scala/annotations/new/main/PrintDefn.scala deleted file mode 100644 index c1828fad..00000000 --- a/tests/src/test/scala/annotations/new/main/PrintDefn.scala +++ /dev/null @@ -1,9 +0,0 @@ -package main - -object PrintDefn extends App { - @printDef - def Def = ??? - - @printVal - val Val = ??? -} diff --git a/tests/src/test/scala/annotations/new/main/TestParams.scala b/tests/src/test/scala/annotations/new/main/TestParams.scala deleted file mode 100644 index 7da5f6e1..00000000 --- a/tests/src/test/scala/annotations/new/main/TestParams.scala +++ /dev/null @@ -1,12 +0,0 @@ -package mainWithParams - -@mainWithParams("hello world") -object Test { - println("bye-bye world") -} - -@namedParam(some = "text") -class SomeClass1 - -@argRepeated(foos: _*) -class SomeClass2 \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-abort.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-abort.check deleted file mode 100644 index 53fe1d25..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-abort.check +++ /dev/null @@ -1,10 +0,0 @@ -Test_2.scala:1: error: denied! -@identity - ^ -Test_2.scala:3: error: denied! - @identity def foo(@identity x: Int) = ??? - ^ -Test_2.scala:3: error: denied! - @identity def foo(@identity x: Int) = ??? - ^ -three errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Macros_1.scala deleted file mode 100644 index 98341ca7..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Macros_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object identityMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - c.abort(c.enclosingPosition, "denied!") - } -} - -class identity extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro identityMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Test_2.scala deleted file mode 100644 index 6f1f9a72..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-abort/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -@identity -object Test extends App { - @identity def foo(@identity x: Int) = ??? -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a.check deleted file mode 100644 index 88a82cdf..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a.check +++ /dev/null @@ -1,7 +0,0 @@ -Test_2.scala:2: error: illegal start of declaration - type T1 = List[T] forSome { @identity type T <: Int } - ^ -Test_2.scala:3: error: illegal start of declaration - type T2 = List[Int] { @identity def head: Int } - ^ -two errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Macros_1.scala deleted file mode 100644 index 7346dd89..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Macros_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object identityMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - c.Expr[Any](Block(annottees.map(_.tree).toList, Literal(Constant(())))) - } -} - -class identity extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro identityMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Test_2.scala deleted file mode 100644 index ac9c63f7..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-a/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - type T1 = List[T] forSome { @identity type T <: Int } - type T2 = List[Int] { @identity def head: Int } -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b.check deleted file mode 100644 index 37a103d4..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b.check +++ /dev/null @@ -1,7 +0,0 @@ -Test_2.scala:2: error: macro annotations can only be put on definitions - def foo[@identity T]: T @identity = ??? - ^ -Test_2.scala:3: error: macro annotations can only be put on definitions - println(2: @identity) - ^ -two errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Macros_1.scala deleted file mode 100644 index 7346dd89..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Macros_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object identityMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - c.Expr[Any](Block(annottees.map(_.tree).toList, Literal(Constant(())))) - } -} - -class identity extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro identityMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Test_2.scala deleted file mode 100644 index f92235ca..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-annottees-b/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - def foo[@identity T]: T @identity = ??? - println(2: @identity) -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl.check deleted file mode 100644 index 839aa44c..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl.check +++ /dev/null @@ -1,10 +0,0 @@ -Macros_1.scala:26: error: macro annotation must extend scala.annotation.StaticAnnotation -class doubler1 extends Annotation { - ^ -Macros_1.scala:31: error: macro annotation cannot be @Inherited -class doubler2 extends StaticAnnotation { - ^ -Macros_1.scala:48: error: macro annotation cannot be a member of another class - class doubler5 extends StaticAnnotation { - ^ -three errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Macros_1.scala deleted file mode 100644 index c7778a9d..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Macros_1.scala +++ /dev/null @@ -1,54 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.{Annotation, StaticAnnotation} - -object doublerMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = { - def double[T <: Name](name: T): T = { - val sdoubled = name.toString + name.toString - val doubled = if (name.isTermName) newTermName(sdoubled) else newTypeName(sdoubled) - doubled.asInstanceOf[T] - } - annottees.map(_.tree).toList match { - case ClassDef(mods, name, tparams, impl) :: rest => - ClassDef(mods, double(name), tparams, impl) :: rest - case ModuleDef(mods, name, impl) :: rest => ModuleDef(mods, double(name), impl) :: rest - case DefDef(mods, name, tparams, vparamss, tpt, rhs) :: rest => - DefDef(mods, double(name), tparams, vparamss, tpt, rhs) :: rest - case TypeDef(mods, name, tparams, rhs) :: rest => - TypeDef(mods, double(name), tparams, rhs) :: rest - case ValDef(mods, name, tpt, rhs) :: rest => ValDef(mods, double(name), tpt, rhs) :: rest - } - } - c.Expr[Any](Block(result, Literal(Constant(())))) - } -} - -class doubler1 extends Annotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl -} - -@java.lang.annotation.Inherited -class doubler2 extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl -} - -package pkg { - class doubler3 extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl - } -} - -object Object { - class doubler4 extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl - } -} - -trait Trait { - class doubler5 extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl - } -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Test_2.scala deleted file mode 100644 index df8cfc75..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-baddecl/Test_2.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test extends App { - @doubler1 object C - @doubler2 object C - @doubler3 object C - @doubler4 object C - @doubler5 object C -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig.check deleted file mode 100644 index ff87aa85..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig.check +++ /dev/null @@ -1,33 +0,0 @@ -Macros_1.scala:30: error: macro annotation has wrong shape: - required: def macroTransform(annottees: Any*) = macro ... - found : def macroTransform(annottees: Any*) = ... -class doubler2 extends StaticAnnotation { - ^ -Macros_1.scala:35: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(annottee: c.Expr[Any]): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(annottees: c.Expr[Any]*): c.Expr[Any] -parameter names differ: annottee != annottees - def macroTransform(annottee: Any) = macro doublerMacro.impl - ^ -Macros_1.scala:34: error: macro annotation has wrong shape: - required: def macroTransform(annottees: Any*) = macro ... - found : def macroTransform(annottee: Any) = macro ... -class doubler3 extends StaticAnnotation { - ^ -Macros_1.scala:39: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(myAnnottees: c.Expr[Any]*): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(annottees: c.Expr[Any]*): c.Expr[Any] -parameter names differ: myAnnottees != annottees - def macroTransform(myAnnottees: Any*) = macro doublerMacro.impl - ^ -Macros_1.scala:38: error: macro annotation has wrong shape: - required: def macroTransform(annottees: Any*) = macro ... - found : def macroTransform(myAnnottees: Any*) = macro ... -class doubler4 extends StaticAnnotation { - ^ -Macros_1.scala:42: error: macro annotation has wrong shape: - required: def macroTransform(annottees: Any*) = macro ... - found : def macroTransform[T](annottees: Any*) = macro ... -class doubler5 extends StaticAnnotation { - ^ -6 errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Macros_1.scala deleted file mode 100644 index 2420fab0..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Macros_1.scala +++ /dev/null @@ -1,47 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object doublerMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = { - def double[T <: Name](name: T): T = { - val sdoubled = name.toString + name.toString - val doubled = if (name.isTermName) newTermName(sdoubled) else newTypeName(sdoubled) - doubled.asInstanceOf[T] - } - annottees.map(_.tree).toList match { - case ClassDef(mods, name, tparams, impl) :: rest => - ClassDef(mods, double(name), tparams, impl) :: rest - case ModuleDef(mods, name, impl) :: rest => ModuleDef(mods, double(name), impl) :: rest - case DefDef(mods, name, tparams, vparamss, tpt, rhs) :: rest => - DefDef(mods, double(name), tparams, vparamss, tpt, rhs) :: rest - case TypeDef(mods, name, tparams, rhs) :: rest => - TypeDef(mods, double(name), tparams, rhs) :: rest - case ValDef(mods, name, tpt, rhs) :: rest => ValDef(mods, double(name), tpt, rhs) :: rest - } - } - c.Expr[Any](Block(result, Literal(Constant(())))) - } -} - -class doubler1 extends StaticAnnotation { - def transform(annottees: Any*) = macro doublerMacro.impl -} - -class doubler2 extends StaticAnnotation { - def macroTransform(annottees: Any*) = ??? -} - -class doubler3 extends StaticAnnotation { - def macroTransform(annottee: Any) = macro doublerMacro.impl -} - -class doubler4 extends StaticAnnotation { - def macroTransform(myAnnottees: Any*) = macro doublerMacro.impl -} - -class doubler5 extends StaticAnnotation { - def macroTransform[T](annottees: Any*) = macro doublerMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Test_2.scala deleted file mode 100644 index df8cfc75..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-badsig/Test_2.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test extends App { - @doubler1 object C - @doubler2 object C - @doubler3 object C - @doubler4 object C - @doubler5 object C -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-crash.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-crash.check deleted file mode 100644 index e2e1cde5..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-crash.check +++ /dev/null @@ -1,43 +0,0 @@ -Test_2.scala:1: error: exception during macro expansion: -scala.NotImplementedError: an implementation is missing - at scala.Predef$.$qmark$qmark$qmark(Predef.scala:252) - at identityMacro$.impl(Macros_1.scala:8) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) - at java.lang.reflect.Method.invoke(Method.java:597) - at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544) - at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544) - at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpandWithRuntime(Macros.scala:830) - -@identity - ^ -Test_2.scala:3: error: exception during macro expansion: -scala.NotImplementedError: an implementation is missing - at scala.Predef$.$qmark$qmark$qmark(Predef.scala:252) - at identityMacro$.impl(Macros_1.scala:8) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) - at java.lang.reflect.Method.invoke(Method.java:597) - at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544) - at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544) - at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpandWithRuntime(Macros.scala:830) - - @identity def foo(@identity x: Int) = ??? - ^ -Test_2.scala:3: error: exception during macro expansion: -scala.NotImplementedError: an implementation is missing - at scala.Predef$.$qmark$qmark$qmark(Predef.scala:252) - at identityMacro$.impl(Macros_1.scala:8) - at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) - at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) - at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) - at java.lang.reflect.Method.invoke(Method.java:597) - at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544) - at scala.tools.nsc.typechecker.Macros$$anonfun$scala$tools$nsc$typechecker$Macros$$macroRuntime$3$$anonfun$apply$8.apply(Macros.scala:544) - at scala.tools.nsc.typechecker.Macros$class.scala$tools$nsc$typechecker$Macros$$macroExpandWithRuntime(Macros.scala:830) - - @identity def foo(@identity x: Int) = ??? - ^ -three errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Macros_1.scala deleted file mode 100644 index 0cca8b43..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Macros_1.scala +++ /dev/null @@ -1,14 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object identityMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - ??? - } -} - -class identity extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro identityMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Test_2.scala deleted file mode 100644 index 6f1f9a72..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-crash/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -@identity -object Test extends App { - @identity def foo(@identity x: Int) = ??? -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a.check deleted file mode 100644 index e1169b58..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a.check +++ /dev/null @@ -1,4 +0,0 @@ -Test_2.scala:1: error: illegal cyclic reference involving class B -@xrefCyclist class A - ^ -one error found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Macros_1.scala deleted file mode 100644 index 9e58090a..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Macros_1.scala +++ /dev/null @@ -1,35 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object xrefCyclistMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - import Flag._ - val name = annottees.head.tree.asInstanceOf[MemberDef].name.toString - val a = c.mirror.staticClass("A") - val b = c.mirror.staticClass("B") - if (name == "A") b.typeSignature - if (name == "B") a.typeSignature - c.Expr[Any](Block(annottees.map(_.tree).toList, Literal(Constant()))) - } -} - -class xrefCyclist extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro xrefCyclistMacro.impl -} - -object introspectCyclistMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - import Flag._ - val name = annottees.head.tree.asInstanceOf[MemberDef].name.toString - val cclass = c.mirror.staticClass("C") - println(cclass.typeSignature) - c.Expr[Any](Block(annottees.map(_.tree).toList, Literal(Constant()))) - } -} - -class introspectCyclist extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro introspectCyclistMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Test_2.scala deleted file mode 100644 index dba23bd2..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-a/Test_2.scala +++ /dev/null @@ -1,7 +0,0 @@ -@xrefCyclist class A - -@xrefCyclist class B - -class C { - @introspectCyclist def x = 2 -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b.check deleted file mode 100644 index 50532dd8..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b.check +++ /dev/null @@ -1,4 +0,0 @@ -Test_2.scala:1: error: illegal cyclic reference involving class C -class C { - ^ -one error found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Macros_1.scala deleted file mode 100644 index 88ed8ac4..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Macros_1.scala +++ /dev/null @@ -1,18 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object introspectCyclistMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - import Flag._ - val name = annottees.head.tree.asInstanceOf[MemberDef].name.toString - val cclass = c.mirror.staticClass("C") - cclass.typeSignature - c.Expr[Any](Block(annottees.map(_.tree).toList, Literal(Constant()))) - } -} - -class introspectCyclist extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro introspectCyclistMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Test_2.scala deleted file mode 100644 index dc19c215..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-cyclic-b/Test_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class C { - @introspectCyclist def x = 2 -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject.check deleted file mode 100644 index dd1f284d..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject.check +++ /dev/null @@ -1,4 +0,0 @@ -Pkg_2.scala:1: error: expected start of definition -@doubler package object pkg - ^ -one error found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Macros_1.scala deleted file mode 100644 index 0b4120e9..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Macros_1.scala +++ /dev/null @@ -1,33 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -package pkg { - object doublerMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = { - def double[T <: Name](name: T): T = { - val sdoubled = name.toString + name.toString - val doubled = if (name.isTermName) newTermName(sdoubled) else newTypeName(sdoubled) - doubled.asInstanceOf[T] - } - annottees.map(_.tree).toList match { - case ClassDef(mods, name, tparams, impl) :: rest => - ClassDef(mods, double(name), tparams, impl) :: rest - case ModuleDef(mods, name, impl) :: rest => ModuleDef(mods, double(name), impl) :: rest - case DefDef(mods, name, tparams, vparamss, tpt, rhs) :: rest => - DefDef(mods, double(name), tparams, vparamss, tpt, rhs) :: rest - case TypeDef(mods, name, tparams, rhs) :: rest => - TypeDef(mods, double(name), tparams, rhs) :: rest - case ValDef(mods, name, tpt, rhs) :: rest => ValDef(mods, double(name), tpt, rhs) :: rest - } - } - c.Expr[Any](Block(result, Literal(Constant(())))) - } - } - - class doubler extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl - } -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Pkg_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Pkg_2.scala deleted file mode 100644 index a4fedd7f..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-packageobject/Pkg_2.scala +++ /dev/null @@ -1 +0,0 @@ -@doubler package object pkg \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq.check deleted file mode 100644 index 6920f461..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq.check +++ /dev/null @@ -1,10 +0,0 @@ -Test_2.scala:1: error: macro implementation is missing -@identity - ^ -Test_2.scala:3: error: macro implementation is missing - @identity def foo(@identity x: Int) = ??? - ^ -Test_2.scala:3: error: macro implementation is missing - @identity def foo(@identity x: Int) = ??? - ^ -three errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Macros_1.scala deleted file mode 100644 index 977a6b5b..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Macros_1.scala +++ /dev/null @@ -1,7 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -class identity extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro ??? -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Test_2.scala deleted file mode 100644 index 6f1f9a72..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-qqq/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -@identity -object Test extends App { - @identity def foo(@identity x: Int) = ??? -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel.check deleted file mode 100644 index ac38399a..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel.check +++ /dev/null @@ -1,40 +0,0 @@ -Test_2.scala:1: error: top-level class without companion can only expand either into an eponymous class or into a block consisting in eponymous companions -@doubler class C1 - ^ -Test_2.scala:3: error: top-level object can only expand into an eponymous object -@doubler object C2 - ^ -Test_2.scala:5: error: top-level class with companion can only expand into a block consisting in eponymous companions -@doubler class C3 - ^ -Test_2.scala:9: error: top-level object can only expand into an eponymous object -@doubler object C4 - ^ -Test_2.scala:11: error: top-level class with companion can only expand into a block consisting in eponymous companions -@doubler class C5 - ^ -Test_2.scala:12: error: top-level object can only expand into an eponymous object -@doubler object C5 - ^ -Test_2.scala:14: error: top-level class with companion can only expand into a block consisting in eponymous companions -@egoist class C6 - ^ -Test_2.scala:17: error: top-level class without companion can only expand either into an eponymous class or into a block consisting in eponymous companions -@suicider class C7 - ^ -Test_2.scala:19: error: top-level object can only expand into an eponymous object -@suicider object C8 - ^ -Test_2.scala:21: error: top-level class with companion can only expand into a block consisting in eponymous companions -@suicider class C9 - ^ -Test_2.scala:25: error: top-level object can only expand into an eponymous object -@suicider object C10 - ^ -Test_2.scala:27: error: top-level class with companion can only expand into a block consisting in eponymous companions -@suicider class C11 - ^ -Test_2.scala:28: error: top-level object can only expand into an eponymous object -@suicider object C11 - ^ -13 errors found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Macros_1.scala deleted file mode 100644 index 5377316a..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Macros_1.scala +++ /dev/null @@ -1,51 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object Macros { - def doubler(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = { - def double[T <: Name](name: T): T = { - val sdoubled = name.toString + name.toString - val doubled = if (name.isTermName) newTermName(sdoubled) else newTypeName(sdoubled) - doubled.asInstanceOf[T] - } - annottees.map(_.tree).toList match { - case ClassDef(mods, name, tparams, impl) :: rest => - ClassDef(mods, double(name), tparams, impl) :: rest - case ModuleDef(mods, name, impl) :: rest => ModuleDef(mods, double(name), impl) :: rest - case DefDef(mods, name, tparams, vparamss, tpt, rhs) :: rest => - DefDef(mods, double(name), tparams, vparamss, tpt, rhs) :: rest - case TypeDef(mods, name, tparams, rhs) :: rest => - TypeDef(mods, double(name), tparams, rhs) :: rest - case ValDef(mods, name, tpt, rhs) :: rest => ValDef(mods, double(name), tpt, rhs) :: rest - } - } - c.Expr[Any](Block(result, Literal(Constant(())))) - } - - def egoist(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = List(annottees.map(_.tree).head) - c.Expr[Any](Block(result, Literal(Constant(())))) - } - - def suicider(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = annottees.map(_.tree).tail.toList - c.Expr[Any](Block(result, Literal(Constant(())))) - } -} - -class doubler extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro Macros.doubler -} - -class egoist extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro Macros.egoist -} - -class suicider extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro Macros.suicider -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Test_2.scala deleted file mode 100644 index 1a169ab1..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-toplevel/Test_2.scala +++ /dev/null @@ -1,28 +0,0 @@ -@doubler class C1 - -@doubler object C2 - -@doubler class C3 -object C3 - -class C4 -@doubler object C4 - -@doubler class C5 -@doubler object C5 - -@egoist class C6 -object C6 - -@suicider class C7 - -@suicider object C8 - -@suicider class C9 -object C9 - -class C10 -@suicider object C10 - -@suicider class C11 -@suicider object C11 \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a.check deleted file mode 100644 index 747cdc53..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a.check +++ /dev/null @@ -1,4 +0,0 @@ -Test_2.scala:3: error: not found: value CC - println(CC) - ^ -one error found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Macros_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Macros_1.scala deleted file mode 100644 index 506e01cb..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Macros_1.scala +++ /dev/null @@ -1,31 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object doublerMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = { - def double[T <: Name](name: T): T = { - val sdoubled = name.toString + name.toString - val doubled = if (name.isTermName) newTermName(sdoubled) else newTypeName(sdoubled) - doubled.asInstanceOf[T] - } - annottees.map(_.tree).toList match { - case ClassDef(mods, name, tparams, impl) :: rest => - ClassDef(mods, double(name), tparams, impl) :: rest - case ModuleDef(mods, name, impl) :: rest => ModuleDef(mods, double(name), impl) :: rest - case DefDef(mods, name, tparams, vparamss, tpt, rhs) :: rest => - DefDef(mods, double(name), tparams, vparamss, tpt, rhs) :: rest - case TypeDef(mods, name, tparams, rhs) :: rest => - TypeDef(mods, double(name), tparams, rhs) :: rest - case ValDef(mods, name, tpt, rhs) :: rest => ValDef(mods, double(name), tpt, rhs) :: rest - } - } - c.Expr[Any](Block(result, Literal(Constant(())))) - } -} - -class doubler extends StaticAnnotation { - def transform(annottees: Any*) = macro doublerMacro.impl -} diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Test_2.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Test_2.scala deleted file mode 100644 index 207e56e1..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-a/Test_2.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends App { - @doubler object C // i feel really silly writing stuff like that, and i'm enjoying it - println(CC) -} \ No newline at end of file diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b.check b/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b.check deleted file mode 100644 index 8b9c9270..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b.check +++ /dev/null @@ -1,4 +0,0 @@ -Macros_Test_1.scala:31: error: macro annotations cannot be used in the same compilation run that defines them - @doubler object C - ^ -one error found diff --git a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b/Macros_Test_1.scala b/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b/Macros_Test_1.scala deleted file mode 100644 index 8526cc33..00000000 --- a/tests/src/test/scala/annotations/old/neg/macro-annotation-unrecognized-b/Macros_Test_1.scala +++ /dev/null @@ -1,35 +0,0 @@ -import scala.reflect.macros.Context -import scala.language.experimental.macros -import scala.annotation.StaticAnnotation - -object doublerMacro { - def impl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = { - import c.universe._ - val result = { - def double[T <: Name](name: T): T = { - val sdoubled = name.toString + name.toString - val doubled = if (name.isTermName) newTermName(sdoubled) else newTypeName(sdoubled) - doubled.asInstanceOf[T] - } - annottees.map(_.tree).toList match { - case ClassDef(mods, name, tparams, impl) :: rest => - ClassDef(mods, double(name), tparams, impl) :: rest - case ModuleDef(mods, name, impl) :: rest => ModuleDef(mods, double(name), impl) :: rest - case DefDef(mods, name, tparams, vparamss, tpt, rhs) :: rest => - DefDef(mods, double(name), tparams, vparamss, tpt, rhs) :: rest - case TypeDef(mods, name, tparams, rhs) :: rest => - TypeDef(mods, double(name), tparams, rhs) :: rest - case ValDef(mods, name, tpt, rhs) :: rest => ValDef(mods, double(name), tpt, rhs) :: rest - } - } - c.Expr[Any](Block(result, Literal(Constant(())))) - } -} - -class doubler extends StaticAnnotation { - def macroTransform(annottees: Any*) = macro doublerMacro.impl -} - -object Test extends App { - @doubler object C -} From fc6fe3951b95ae1a7392faec0ca21bf48937dcff Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Tue, 11 Oct 2016 20:36:37 +0300 Subject: [PATCH 2/2] `sbt publish` no longer publishes auxiliary projects --- build.sbt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index 025be52a..40f1908a 100644 --- a/build.sbt +++ b/build.sbt @@ -18,7 +18,7 @@ lazy val sharedSettings: Seq[Def.Setting[_]] = description := "Empowers production Scala compiler with latest macro developments", resolvers += Resolver.sonatypeRepo("releases"), publishMavenStyle := true, - publishArtifact in Test := false, + publishArtifact := false, scalacOptions ++= Seq("-deprecation", "-feature"), logBuffered := false, triggeredMessage in ThisBuild := Watched.clearWhenTriggered @@ -43,7 +43,6 @@ lazy val testSettings: Seq[Def.Setting[_]] = Seq( libraryDependencies += "org.scalatest" % "scalatest_2.11" % "3.0.0", scalacOptions += "-Ywarn-unused-import", scalacOptions += "-Xfatal-warnings", - publishArtifact in Compile := false, scalacOptions in Compile ++= Seq() ) @@ -109,7 +108,11 @@ lazy val root = project .in(file(".")) .settings( sharedSettings, - packagedArtifacts := Map.empty + packagedArtifacts := Map.empty, + aggregate in publish := false, + publish := { + val publishPlugin = (publish in plugin).value + } ) .aggregate( plugin, @@ -154,7 +157,7 @@ lazy val plugin = Project(id = "paradise", base = file("plugin")) (art, slimJar) }, publishMavenStyle := true, - publishArtifact in Test := false, + publishArtifact in Compile := true, publishTo <<= version { v: String => val nexus = "https://oss.sonatype.org/" if (v.trim.endsWith("SNAPSHOT"))