mirror of
https://github.com/typelevel/simulacrum.git
synced 2024-11-29 01:24:09 +03:00
Merge pull request #124 from driuzz/issue/sbt-doc-fails-#90
Issue #90, added support for DocDef
This commit is contained in:
commit
5cad4c9c58
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
target
|
||||
.idea/
|
||||
.idea
|
||||
.bloop
|
||||
.metals
|
||||
|
@ -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
|
||||
|
21
build.sbt
21
build.sbt
@ -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: _*)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user