From ebe58d3ea7c3963198edf42f77d4c875cbdeb104 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 25 Nov 2020 12:41:06 -0600 Subject: [PATCH] add support for 3.0.0-M2 --- README.md | 2 +- build.sbt | 12 ++++++----- .../TypeNamePlatform.scala | 0 .../scala-3.0.0-M2/TypeNamePlatform.scala | 21 +++++++++++++++++++ 4 files changed, 29 insertions(+), 6 deletions(-) rename src/main/{scala-3 => scala-3.0.0-M1}/TypeNamePlatform.scala (100%) create mode 100644 src/main/scala-3.0.0-M2/TypeNamePlatform.scala diff --git a/README.md b/README.md index ee989ad..7156da7 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This is a Scala micro-library that provides: The intent is that you can use this instead of `TypeTag` or other heavy machinery. -TypeName is compiled for Scala **2.12**, **2.13**, and **3.0.0-M1**. +TypeName is compiled for Scala **2.12**, **2.13**, **3.0.0-M1**, and **3.0.0-M2**. ```scala diff --git a/build.sbt b/build.sbt index 85e2399..4d91606 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,9 @@ + // Our Scala versions. -lazy val `scala-3.0` = "3.0.0-M1" -lazy val `scala-2.12` = "2.12.12" -lazy val `scala-2.13` = "2.13.3" +lazy val `scala-3.0` = "3.0.0-M2" +lazy val `scala-3.0-prev` = "3.0.0-M1" +lazy val `scala-2.12` = "2.12.12" +lazy val `scala-2.13` = "2.13.3" // Publishing name := "typename" @@ -24,7 +26,7 @@ headerLicense := Some(HeaderLicense.Custom( // Compilation scalaVersion := `scala-2.13` -crossScalaVersions := Seq(`scala-2.12`, `scala-2.13`, `scala-3.0`) +crossScalaVersions := Seq(`scala-2.12`, `scala-2.13`, `scala-3.0-prev`, `scala-3.0`) Compile / doc / scalacOptions --= Seq("-Xfatal-warnings") Compile / doc / scalacOptions ++= Seq( "-groups", @@ -33,7 +35,7 @@ Compile / doc / scalacOptions ++= Seq( ) // MUnit -libraryDependencies += "org.scalameta" %% "munit" % "0.7.18" % Test +libraryDependencies += "org.scalameta" %% "munit" % "0.7.19" % Test testFrameworks += new TestFramework("munit.Framework") // Scala 2 needs scala-reflect diff --git a/src/main/scala-3/TypeNamePlatform.scala b/src/main/scala-3.0.0-M1/TypeNamePlatform.scala similarity index 100% rename from src/main/scala-3/TypeNamePlatform.scala rename to src/main/scala-3.0.0-M1/TypeNamePlatform.scala diff --git a/src/main/scala-3.0.0-M2/TypeNamePlatform.scala b/src/main/scala-3.0.0-M2/TypeNamePlatform.scala new file mode 100644 index 0000000..57b8de4 --- /dev/null +++ b/src/main/scala-3.0.0-M2/TypeNamePlatform.scala @@ -0,0 +1,21 @@ +// Copyright (c) 2020 by Rob Norris +// This software is licensed under the MIT License (MIT). +// For more information see LICENSE or https://opensource.org/licenses/MIT + +package org.tpolecat.typename + +import scala.quoted._ + +trait TypeNamePlatform { + + inline given [A] as TypeName[A] = + ${TypeNamePlatform.impl[A]} + +} + +object TypeNamePlatform { + + def impl[A](using t: Type[A], ctx: Quotes): Expr[TypeName[A]] = + '{TypeName[A](${Expr(Type.show[A])})} + +}