Skip to content

Commit

Permalink
Merge pull request #477 from tgodzik/3.0.0-RC2
Browse files Browse the repository at this point in the history
Add support for Scala 3.0.0-RC2
  • Loading branch information
tgodzik authored Mar 29, 2021
2 parents 148621b + 8928494 commit b21694e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
- "'++2.12.12 test'"
- "'++2.12.13 test' scripted"
- "'++2.13.5 test'"
- "'++3.0.0-M3 test'"
- "'++3.0.0-RC1 test'"
- "'++3.0.0-RC2 test'"
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
Expand Down
1 change: 1 addition & 0 deletions bin/test-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ coursier fetch \
org.scalameta:mdoc_3.0.0-M2:$version \
org.scalameta:mdoc_3.0.0-M3:$version \
org.scalameta:mdoc_3.0.0-RC1:$version \
org.scalameta:mdoc_3.0.0-RC2:$version \
org.scalameta:mdoc-js_2.11:$version \
org.scalameta:mdoc-js_2.12.12:$version \
org.scalameta:mdoc-js_2.12:$version \
Expand Down
4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import scala.collection.mutable
def scala212 = "2.12.13"
def scala211 = "2.11.12"
def scala213 = "2.13.5"
def scala3 = List("3.0.0-RC1", "3.0.0-M3", "3.0.0-M2")
def scala3 = List("3.0.0-RC2", "3.0.0-RC1", "3.0.0-M3", "3.0.0-M2")

def scalajs = "1.5.0"
def scalajsBinaryVersion = "1"
Expand Down Expand Up @@ -111,7 +111,7 @@ lazy val sharedSettings = List(

val V = new {
val scalameta = "4.4.10"
val munit = "0.7.22"
val munit = "0.7.23"
val coursier = "1.0.3"
val scalacheck = "1.15.2"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package mdoc.internal.pprint

import scala.language.implicitConversions
import scala.quoted._
import scala.quoted.runtime.impl.printers.SyntaxHighlight

trait TPrint[T]{
def render: String
}

object TPrint {
inline given default[T]: TPrint[T] = ${ TypePrinter.typeString[T] }
}

object TypePrinter{

def typeString[T](using ctx: Quotes, tpe: Type[T]): Expr[TPrint[T]] = {
import ctx.reflect._

val valueType = TypeTree.of[T](using tpe).tpe.show(using Printer.TypeReprShortCode)

'{ new TPrint[T]{ def render: String = ${ Expr(valueType) } } }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mdoc.internal.sourcecode

import scala.language.implicitConversions
import scala.quoted._

trait StatementMacro {
inline implicit def generate[T](v: => T): SourceStatement[T] = ${ Macros.text('v) }
inline def apply[T](v: => T): SourceStatement[T] = ${ Macros.text('v) }
}

object Macros{

def text[T: Type](v: Expr[T])(using ctx: Quotes): Expr[SourceStatement[T]] = {
import ctx.reflect.{_, given}
val txt = v.asTerm.pos.sourceCode.getOrElse("")
'{SourceStatement[T]($v, ${Expr(txt)})}
}
}

0 comments on commit b21694e

Please sign in to comment.