Skip to content

Commit 5181f90

Browse files
authored
Merge pull request #457 from tgodzik/update-3.0.0-RC1
Add support for Scala 3.0.0-RC1
2 parents 977d6c8 + 02c8f2f commit 5181f90

File tree

6 files changed

+47
-14
lines changed

6 files changed

+47
-14
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030
- "'++2.11.12 test'"
3131
- "'++2.12.13 test' scripted"
3232
- "'++2.13.4 test'"
33-
- "'++3.0.0-M2 test'"
3433
- "'++3.0.0-M3 test'"
34+
- "'++3.0.0-RC1 test'"
3535
steps:
3636
- uses: actions/checkout@v2
3737
- uses: olafurpg/setup-scala@v10

bin/test-release.sh

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ coursier fetch \
1212
org.scalameta:mdoc_2.13:$version \
1313
org.scalameta:mdoc_3.0.0-M2:$version \
1414
org.scalameta:mdoc_3.0.0-M3:$version \
15+
org.scalameta:mdoc_3.0.0-RC1:$version \
1516
org.scalameta:mdoc-js_2.11:$version \
1617
org.scalameta:mdoc-js_2.12.12:$version \
1718
org.scalameta:mdoc-js_2.12:$version \

build.sbt

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ def scala212 = "2.12.13"
55
def scala212Legacy = "2.12.12"
66
def scala211 = "2.11.12"
77
def scala213 = "2.13.4"
8-
def scala3 = List("3.0.0-M3", "3.0.0-M2")
8+
def scala3 = List("3.0.0-RC1", "3.0.0-M3", "3.0.0-M2")
99

1010
def scalajs = "1.3.0"
1111
def scalajsBinaryVersion = "1"
@@ -113,7 +113,7 @@ lazy val sharedSettings = List(
113113

114114
val V = new {
115115
val scalameta = "4.4.7"
116-
val munit = "0.7.21"
116+
val munit = "0.7.22"
117117
val coursier = "1.0.2"
118118
val scalacheck = "1.15.2"
119119
}

mdoc/src/main/scala-3/mdoc/internal/markdown/SectionInput.scala

+1-11
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,8 @@ case class SectionInput(input : Input, mod : Modifier, context : MContext){
4242
def show(tree : Tree, currentIdent : Int) = {
4343
val str = tree.sourcePos(using ctx).start
4444
val end = tree.sourcePos(using ctx).end
45-
// workaround should be removed once support for 0.26.0 is dropped
46-
val prefix = if (BuildInfo.scalaBinaryVersion == "0.26")
47-
tree match {
48-
case ext: ExtMethods if ext.tparams.nonEmpty =>
49-
"extension ["
50-
case _: ExtMethods =>
51-
"extension ("
52-
case _ => ""
53-
}
54-
else ""
5545
val realIdent = " " * (currentIdent - wrapIdent.size)
56-
prefix + sourceCode.substring(str, end).replace("\n", "\n" + realIdent)
46+
sourceCode.substring(str, end).replace("\n", "\n" + realIdent)
5747
}
5848
def text = source.show(using driver.currentCtx)
5949
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package mdoc.internal.pprint
2+
3+
import scala.language.implicitConversions
4+
import scala.quoted._
5+
import scala.quoted.runtime.impl.printers.SyntaxHighlight
6+
7+
trait TPrint[T]{
8+
def render: String
9+
}
10+
11+
object TPrint {
12+
inline given default[T]: TPrint[T] = ${ TypePrinter.typeString[T] }
13+
}
14+
15+
object TypePrinter{
16+
17+
def typeString[T](using ctx: Quotes, tpe: Type[T]): Expr[TPrint[T]] = {
18+
import ctx.reflect._
19+
20+
val valueType = TypeTree.of[T](using tpe).tpe.show(using Printer.TypeReprShortCode)
21+
22+
'{ new TPrint[T]{ def render: String = ${ Expr(valueType) } } }
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package mdoc.internal.sourcecode
2+
3+
import scala.language.implicitConversions
4+
import scala.quoted._
5+
6+
trait StatementMacro {
7+
inline implicit def generate[T](v: => T): SourceStatement[T] = ${ Macros.text('v) }
8+
inline def apply[T](v: => T): SourceStatement[T] = ${ Macros.text('v) }
9+
}
10+
11+
object Macros{
12+
13+
def text[T: Type](v: Expr[T])(using ctx: Quotes): Expr[SourceStatement[T]] = {
14+
import ctx.reflect.{_, given}
15+
val txt = v.asTerm.pos.sourceCode.getOrElse("")
16+
'{SourceStatement[T]($v, ${Expr(txt)})}
17+
}
18+
}

0 commit comments

Comments
 (0)