Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Scala 3.0.0-RC3 #486

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-RC1 test'"
- "'++3.0.0-RC2 test'"
- "'++3.0.0-RC3 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 @@ -14,6 +14,7 @@ coursier fetch \
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_3.0.0-RC3:$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-RC2", "3.0.0-RC1", "3.0.0-M3", "3.0.0-M2")
def scala3 = List("3.0.0-RC3", "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.11"
val munit = "0.7.23"
val munit = "0.7.25"
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)})}
}
}