
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fix | |
import scala.meta.Defn | |
import scala.meta.Term | |
import scala.meta.transversers.* | |
import scalafix.Patch | |
import scalafix.lint.Diagnostic | |
import scalafix.lint.LintSeverity | |
import scalafix.v1.SyntacticDocument | |
import scalafix.v1.SyntacticRule |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object ScalaRunTimeForScalaJS { | |
def main(a: Array[String]): Unit = { | |
println(replStringOf((1 to 200).toList, 10)) | |
} | |
def replStringOf(arg: Any, maxElements: Int): String = | |
stringOf(arg, maxElements) match { | |
case null => "null toString" | |
case s if s.indexOf('\n') >= 0 => "\n" + s + "\n" | |
case s => s + "\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.wartremover.WartTraverser | |
import org.wartremover.WartUniverse | |
object StringTailInit extends WartTraverser { | |
def apply(u: WartUniverse): u.Traverser = | |
new u.Traverser(this) { | |
import q.reflect.* | |
override def traverseTree(tree: Tree)(owner: Symbol): Unit = { | |
tree match { | |
case Select(Apply(Ident("augmentString"), _ :: Nil), "init" | "tail") => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package example | |
import scala.compiletime.testing.typeCheckErrors | |
object Main { | |
val x1: PosInt = 2 | |
def main(args: Array[String]): Unit = { | |
println(x1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thealp.paripi.shared.warts | |
import org.wartremover.WartTraverser | |
import org.wartremover.WartUniverse | |
object OverrideMod extends WartTraverser { | |
override def apply(u: WartUniverse): u.Traverser = | |
new u.Traverser(this) { | |
import q.reflect.* | |
override def traverseTree(tree: Tree)(owner: Symbol): Unit = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt.* | |
import sbt.Keys.* | |
object CountImplicitKeywordPlugin extends AutoPlugin { | |
override def trigger: PluginTrigger = allRequirements | |
object autoImport { | |
val implicitKeyword = taskKey[Int]("") | |
val allImplicitKeyword = taskKey[Seq[(String, Int)]]("") | |
} | |
import autoImport.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fix | |
import scala.meta._ | |
import scalafix.v1._ | |
class ImplicitClassExtension extends SyntacticRule("ImplicitClassExtension") { | |
val exclude: Seq[String] = Seq( | |
// 書き換えるとoverload衝突する場合や、呼び出しの優先順位変わってエラーになるものなど、 | |
// 下記の条件で除外しきれなかった例外的なものをfile単位で除くためにここに記述 | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.compiletime.ops.int | |
import scala.compiletime.ops.long | |
import scala.compiletime.ops.double | |
type Factorial[A <: Int] = | |
Factorial0[A, 1L] | |
type Factorial0[A <: Int, B <: Long] <: Long = | |
int.<[A, 1] match | |
case true => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.compiletime.ops.int | |
import scala.compiletime.ops.double | |
type F1[A <: Int] <: Double = | |
int.%[A, 2] match | |
case 0 => | |
1d | |
case 1 => | |
-1d |