Merge pull request #124 from driuzz/issue/sbt-doc-fails-#90

Issue #90, added support for DocDef
This commit is contained in:
Michael Pilquist 2019-01-19 10:15:31 -05:00 committed by GitHub
commit 5cad4c9c58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 9 deletions

4
.gitignore vendored
View File

@ -1,2 +1,4 @@
target
.idea/
.idea
.bloop
.metals

View File

@ -17,7 +17,7 @@ jdk:
- oraclejdk8
script:
- sbt "++${TRAVIS_SCALA_VERSION}!" test mimaReportBinaryIssues
- sbt "++${TRAVIS_SCALA_VERSION}!" test test:doc mimaReportBinaryIssues
before_cache:
# Tricks to avoid unnecessary cache updates

View File

@ -39,6 +39,14 @@ lazy val commonSettings = Seq(
"-language:higherKinds",
"-language:implicitConversions"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
Seq("-Ymacro-annotations")
case _ =>
Nil
}
},
scalacOptions in (Compile, doc) ~= { _ filterNot { o => o == "-Ywarn-unused-import" || o == "-Xfatal-warnings" } },
scalacOptions in (Compile, console) ~= { _ filterNot { o => o == "-Ywarn-unused-import" || o == "-Xfatal-warnings" } },
scalacOptions in (Test, console) := (scalacOptions in (Compile, console)).value,
@ -101,6 +109,7 @@ lazy val commonSettings = Seq(
inquireVersions,
runClean,
runTest,
releaseStepCommandAndRemaining("test:doc"),
setReleaseVersion,
commitReleaseVersion,
tagRelease,
@ -112,17 +121,17 @@ lazy val commonSettings = Seq(
),
wartremoverErrors in (Test, compile) ++= Seq(
Wart.ExplicitImplicitTypes,
Wart.ImplicitConversion)
) ++ Seq(Compile, Test).map{ scope =>
scalacOptions in (scope, compile) := {
Wart.ImplicitConversion),
// Disable scaladoc on 2.13 until RC1 due to https://github.com/scala/bug/issues/11045
sources in (Test, doc) := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v >= 13 =>
(scalacOptions in (scope, compile)).value :+ "-Ymacro-annotations"
Nil
case _ =>
(scalacOptions in (scope, compile)).value
(sources in (Test, doc)).value
}
}
}
)
lazy val root = project.in(file("."))
.settings(commonSettings: _*)

View File

@ -249,9 +249,12 @@ class TypeClassMacros(val c: Context) {
}
def adaptMethods(typeClass: ClassDef, tcInstanceName: TermName, tparamName: Name, proper: Boolean, liftedTypeArgs: List[TypeDef]): List[DefDef] = {
val typeClassMethods = typeClass.impl.children.collect {
import scala.tools.nsc.ast.Trees
def matchMethod: PartialFunction[Tree, DefDef] = {
case m: DefDef if !m.mods.hasFlag(Flag.PRIVATE) && !m.mods.hasFlag(Flag.PROTECTED) => m
case t if t.isInstanceOf[Trees#DocDef] => matchMethod(t.asInstanceOf[Trees#DocDef].definition.asInstanceOf[Tree])
}
val typeClassMethods = typeClass.impl.children.collect(matchMethod)
typeClassMethods.flatMap { method =>
val adapted =
if (proper) adaptMethodForProperType(tcInstanceName, tparamName, method)

View File

@ -10,7 +10,17 @@ import scala.Predef.{ ???, identity }
import scala.collection.immutable.List
import scala.util
/**
* Semigroup description
* @tparam T type T
*/
@typeclass trait Semigroup[T] {
/**
* append description
* @param x param x
* @param y param y
* @return return value
*/
@op("|+|", alias = true)
def append(x: T, y: T): T
def appendCurried(x: T)(y: T): T = append(x, y)