[info] Benchmark Mode Cnt Score Error Units
[info] Main.hasTypeVariable thrpt 10 0.051 ± 0.002 ops/s
[info] Main.lowLevelReflection thrpt 10 0.361 ± 0.010 ops/s
[info] Main.noTypeVariable thrpt 10 0.223 ± 0.004 ops/s
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.meta._ | |
import scalafix.v1._ | |
class ThenReturn extends SyntacticRule("ThenReturn") { | |
val exclude = Seq("") | |
override def fix(implicit doc: SyntacticDocument): Patch = { | |
doc.input match { | |
case f: Input.VirtualFile if exclude.exists(f.path.contains) => | |
Patch.empty | |
case _ => |
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 com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport._ | |
import com.typesafe.sbt.web.SbtWeb.autoImport._ | |
import play.twirl.sbt.Import.TwirlKeys | |
import sbt.Keys._ | |
import sbt._ | |
import sbtprojectmatrix.ProjectMatrixPlugin | |
import sbtprojectmatrix.ProjectMatrixPlugin.autoImport.projectMatrixBaseDirectory | |
object PlayLayoutProjectMatrixPlugin extends AutoPlugin { | |
override def requires = play.sbt.PlayWeb && ProjectMatrixPlugin |
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
$ scala -Xprint:typer -e "for { a <- Option(2) ; b <- Option(a) } yield b" | |
[[syntax trees at end of typer]] // scalacmd15102494186904250690.scala | |
package <empty> { | |
object Main extends scala.AnyRef { | |
def <init>(): Main.type = { | |
Main.super.<init>(); | |
() | |
}; | |
def main(args: Array[String]): Unit = { | |
final class $anon extends scala.AnyRef { |
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 org.wartremover.WartTraverser | |
import org.wartremover.WartUniverse | |
object DisableDoobieReadInstance 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 scala.quoted.* | |
object Foo { | |
inline def f[A](inline x: A): List[(String, String)] = ${ impl('x) } | |
def impl[A](using q: Quotes)(x: Expr[A]): Expr[List[(String, String)]] = { | |
import q.reflect.* | |
x.asTerm match { | |
case Inlined(_, _, Block(_, Match(_, i :: Nil))) => | |
i match { |
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
TaskKey[Seq[String]]("allMainClassNames") := Def.taskDyn { | |
buildStructure.value.units | |
.apply(Keys.thisProjectRef.value.build) | |
.defined | |
.values | |
.toList | |
.map { p => | |
LocalProject(p.id) / Compile / discoveredMainClasses | |
} | |
.join |
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 scodec.bits.* | |
import scodec.codecs.* | |
object Main { | |
val iterations = 1000000000 | |
val str = "Hello World!" |
- 6.543094 Null
- 5.654039 MapUnit
- 4.128198 SeqApply
- 1.990676 StringPlusAny
- 1.58011 AutoUnboxing
- 1.447845 IterableOps
- 1.424732 PlatformDefault
- 1.257947 Equals
- 1.251545 Overloading
- 0.813279 RedundantIsInstanceOf
- ImplicitParameter 1.065469
- Overloading 0.510683
- Null 0.334346
- AutoUnboxing 0.280608
- ListAppend 0.24645
- IterableOps 0.130154
- SortFilter 0.107256
- Recursion 0.102776
- Any 0.100167
- AsInstanceOf 0.060164
NewerOlder