Skip to content

Instantly share code, notes, and snippets.

🦉

Lukas Rytz lrytz

View GitHub Profile
View JFunction0$mcV$sp
// class version 52.0 (52)
// access flags 0x601
// signature Ljava/lang/Object;Lscala/Function0<Ljava/lang/Object;>;Ljava/io/Serializable;
// declaration: scala/runtime/java8/JFunction0$mcV$sp extends scala.Function0<java.lang.Object>, java.io.Serializable
public abstract interface scala/runtime/java8/JFunction0$mcV$sp implements scala/Function0 java/io/Serializable {
// compiled from: JFunction0$mcV$sp.scala
@Ljava/lang/FunctionalInterface;()
View asc.scala
import annotation.unchecked.uncheckedVariance
trait Bldr[-A, +To] { self =>
def result(): To
}
trait ItFact[+CC[_]] {
def from[A](source: It[A]): CC[A]
def newBuilder[A]: Bldr[A, CC[A]]
}
View missingOverride.scala
import annotation.unchecked.uncheckedVariance
trait Bldr[-A, +To] { self =>
def result(): To
def mapResult[NTo](f: To => NTo): Bldr[A, NTo] = new Bldr[A, NTo] {
def result(): NTo = f(self.result())
}
}
trait ItFact[+CC[_]] {
View Colls.scala
import annotation.unchecked.uncheckedVariance
trait Bldr[-A, +To] { self =>
def result(): To
def mapResult[NTo](f: To => NTo): Bldr[A, NTo] = new Bldr[A, NTo] {
def result(): NTo = f(self.result())
}
}
trait ItFact[+CC[_]] {
def from[A](source: It[A]): CC[A]
View Test.scala
import annotation.unchecked.uncheckedVariance
trait Builder[-A, +To]
trait IterableFactory[+CC[_]] {
def from[A](source: It[A]): CC[A]
def newBuilder[A]: Builder[A, CC[A]]
}
trait ItOps[+A, +CC[_], +C] {
protected type IterableCC[X] = CC[X] @uncheckedVariance
View Stepper.scala
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
@lrytz
lrytz / Test.scala
Created Dec 7, 2018
Ensure stepper / stream / accumulator / array conversions don't box
View Test.scala
import com.google.monitoring.runtime.instrumentation.AllocationRecorder
import com.google.monitoring.runtime.instrumentation.Sampler
import scala.collection.convert._
import scala.collection.JavaConverters._
// download java-allocation-instrumenter-3.2.0.jar from here:
// http://repo1.maven.org/maven2/com/google/code/java-allocation-instrumenter/java-allocation-instrumenter/3.2.0/
// compile and run with
View Test.scala
package scala.collection.immutable
import scala.collection.{IterableOnce, Iterator}
class LazyListLazinessTest {
import LazyListLazinessTest._
def assertEquals(a: Int, b: Int): Unit = ()
/* op laziness tests */
View optimizer.md

The Scala 2.12/2.13 Inliner and Optimizer

tl;dr.

  • Don't inline from your dependencies when publishing a library, it breaks binary compatibility. Use -opt-inline-from:my.package.** to only inline from packages within your library.
  • When compiling with the inliner enabled, ensure that the run-time classpath is exactly the same as the compile-time classpath.
  • Don't enable the optimizer for development: it breaks sbt's incremental compilation, and it makes the compiler slower. Only enable it for testing, on CI and to build releases.
  • The @inline annotation only has an effect if the inliner is enabled. It tells the inliner to always try to inline the annotated method or callsite.
  • Without the @inline annotation, the inliner generally inlines higher-order methods and forwarder methods. The main goal is to eliminate megamorphic callsites due to functions passed as argument, and to eliminate value boxing. Other optimizations are delegated to the JVM.
You can’t perform that action at this time.