Skip to content

Commit

Permalink
Remove @reifySource unsupported by new Scala version 2.13.12
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaciv committed Oct 11, 2023
1 parent 5aa143a commit a4854c5
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,13 +278,6 @@ final class isAnnotated[T <: StaticAnnotation] extends DirectMetadataParamStrate
*/
final class reifyName(val useRawName: Boolean = false) extends DirectMetadataParamStrategy

/**
* Metadata parameter annotated with this annotation must be of type `SymbolSource` -
* class that holds symbol source information - start & end offsets of symbol definition as well as actual
* source text.
*/
final class reifySource extends DirectMetadataParamStrategy

/**
* Metadata parameter annotated with this annotation must be of type `ParamPosition` or `MethodPosition` -
* a class that holds parameter/method index information - see scaladoc for `ParamPosition` & `MethodPosition`
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ private[commons] trait MacroMetadatas extends MacroSymbols {
final lazy val ReifyAnnotAT: Type = staticType(tq"$MetaPackage.reifyAnnot")
final lazy val IsAnnotatedAT: Type = staticType(tq"$MetaPackage.isAnnotated[_]")
final lazy val ReifyNameAT: Type = staticType(tq"$MetaPackage.reifyName")
final lazy val ReifySourceAT: Type = staticType(tq"$MetaPackage.reifySource")
final lazy val ReifyPositionAT: Type = staticType(tq"$MetaPackage.reifyPosition")
final lazy val ReifyParamListCountAT: Type = staticType(tq"$MetaPackage.reifyParamListCount")
final lazy val ReifyFlagsAT: Type = staticType(tq"$MetaPackage.reifyFlags")
Expand Down Expand Up @@ -157,15 +156,15 @@ private[commons] trait MacroMetadatas extends MacroSymbols {
case t if t <:< InferAT =>
val clue = annot.findArg[String](InferAT.member(TermName("clue")), "")
new ImplicitParam(ownerConstr, paramSym, clue)
case t if t <:< ReifyAnnotAT => new ReifiedAnnotParam(ownerConstr, paramSym)
case t if t <:< ReifyAnnotAT =>
new ReifiedAnnotParam(ownerConstr, paramSym)
case t if t <:< ReifyNameAT =>
val useRawName = annot.findArg[Boolean](ReifyNameAT.member(TermName("useRawName")), false)
new ReifiedNameParam(ownerConstr, paramSym, useRawName)
case t if t <:< ReifySourceAT =>
new ReifiedSourceParam(ownerConstr, paramSym)
case t if t <:< IsAnnotatedAT =>
new IsAnnotatedParam(ownerConstr, paramSym, t.typeArgs.head)
case t => reportProblem(s"metadata param strategy $t is not allowed here")
case t =>
reportProblem(s"metadata param strategy $t is not allowed here")
}

def compositeConstructor(param: CompositeParam): MetadataConstructor
Expand Down Expand Up @@ -344,36 +343,6 @@ private[commons] trait MacroMetadatas extends MacroSymbols {
Ok(q"${if (useRawName) matchedSymbol.rawName else matchedSymbol.real.nameStr}")
}

class ReifiedSourceParam(owner: MetadataConstructor, symbol: Symbol)
extends DirectMetadataParam(owner, symbol) {

if (!(actualType =:= SymbolSourceTpe)) {
reportProblem(s"its type is not SymbolSource")
}

def tryMaterializeFor(matchedSymbol: MatchedSymbol): Res[Tree] = {
val sym = matchedSymbol.real.symbol
sym.pos match {
case NoPosition =>
FailMsg(s"source information not available for ${matchedSymbol.real.description}")
case pos => Ok {
val source = pos.source
val startPos = pos.withPoint(pos.start)
val endPos = pos.withPoint(pos.end)
q"""
$MetaPackage.SymbolSource(
${source.path},
${source.file.name},
$MetaPackage.SourceOffset(${startPos.point}, ${startPos.line}, ${startPos.column}),
$MetaPackage.SourceOffset(${endPos.point}, ${endPos.line}, ${endPos.column}),
${new String(source.content, pos.start, pos.end - pos.start)}
)
"""
}
}
}
}

class ParamPositionParam(owner: MetadataConstructor, symbol: Symbol)
extends DirectMetadataParam(owner, symbol) {

Expand Down
2 changes: 1 addition & 1 deletion project/Commons.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object Commons extends ProjectGroup("commons") {
val circeVersion = "0.14.5" // benchmark only
val upickleVersion = "3.1.2" // benchmark only
val scalajsBenchmarkVersion = "0.10.0"
val slf4jVersion = "2.0.9"
val slf4jVersion = "2.0.9" // test only

// for binary compatibility checking
val previousCompatibleVersions: Set[String] = Set("2.2.4")
Expand Down

0 comments on commit a4854c5

Please sign in to comment.