Skip to content

Instantly share code, notes, and snippets.

Avatar
🦉

Lukas Rytz lrytz

🦉
View GitHub Profile
View ModuleSerializationProxy.diff
diff --git a/ModuleSerializationProxy.class.asm b/ModuleSerializationProxy.class.asm
index ded4eb8..abdbadf 100644
--- a/ModuleSerializationProxy.class.asm
+++ b/ModuleSerializationProxy.class.asm
@@ -2,13 +2,6 @@
// access flags 0x31
public final class scala/runtime/ModuleSerializationProxy implements java/io/Serializable {
- // access flags 0x8
- static INNERCLASS scala/runtime/ModuleSerializationProxy$1 null null
View warnings.diff
--- unchecked-base.txt 2021-07-12 10:34:54.000000000 +0200
+++ unchecked-pr.txt 2021-07-12 10:34:26.000000000 +0200
@@ -1,9 +1,267 @@
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:269:18: abstract type Output in type pattern scala.collection.mutable.ListBuffer[Output] is unchecked since it is eliminated by erasure
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:269:18: abstract type Output in type pattern scala.collection.mutable.ListBuffer[Output] is unchecked since it is eliminated by erasure
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:269:18: abstract type Output in type pattern scala.collection.mutable.ListBuffer[Output] is unchecked since it is eliminated by erasure
+[akka-http] [warn] /akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala:89:20: abstract type Output in type pattern scala.collection.m
View no-projection.scala
object Scala2 {
type Service[K <: Common.AbstractServiceKey[_]] = K#Protocol // error in 3: "K is not a legal path since it is not a concrete type"
}
// object Scala3 {
// type Service[K <: Common.AbstractServiceKey[_]] = K match {
// case Common.AbstractServiceKey[t] => t
// }
// }
View infer.md
trait ActorRef[-T] {
  def !(msg: T): Unit = ()
}

class Behavior[T]

object Behaviors {
  def receive[T](onMessage: T => Behavior[T]): Behavior[T] = ???
  def same[T]: Behavior[T] = ???
View fetchpr
#!/bin/bash
set -e
[[ $# == 1 ]] || {
echo "usage: $0 <pr-number>"
exit 1
}
pr=$1
View clener.scala
object T {
import scala.util.matching._
object sessionNames {
// All values are configurable by passing e.g. -Dscala.repl.name.read=XXX
final def propOr(name: String): String = propOr(name, "$" + name)
final def propOr(name: String, default: String): String =
sys.props.getOrElse("scala.repl.name." + name, default)
// Prefixes used in repl machinery. Default to $line, $read, etc.
def line = propOr("line")
View SerialVersionUIDClasspath.scala
s12 -Ccom.google.guava:guava:30.1-jre
val ps = Set("scala.collection", "scala.collection.convert", "scala.collection.immutable", "scala.collection.mutable")
val cp = com.google.common.reflect.ClassPath.from(classOf[List[_]].getClassLoader)
import scala.collection.JavaConverters._
val topLevel = ps.flatMap(p => cp.getTopLevelClasses(p).asScala)
val all = topLevel.flatMap(c => {
View wconf.md

Configuring and suppressing warnings in Scala

Scala 2.13.2 and 2.12.13 introduced the -Wconf compiler flag to globally configure reporting of warnings, and the @nowarn annotation to locally suppress them. Having more control over compiler warnings makes them a lot more valuable:

  • In projects where the build log shows a lot of of warnings that are mostly ignored, new helpful warnings can easily go undetected. The new functionality can be used to clean up the build log with manageable efforts and potentially enable fatal warning (-Werror in 2.13, -Xfatal-warnings in 2.12). This has happened for example in Scala compiler and standard library projects in the past few months.
  • Projects that already use fatal warnings get better utilities to work around corner cases where a warning cannot be avoided. This can allow further -Xlint checks to be enabled.

In this post we go through the mechanics of configuring warnigns and also look at the new @nowarn annotation.

Warnings from the Scala compil

@lrytz
lrytz / A.scala
Last active Oct 15, 2020
jsr45 scala
View A.scala
object A {
def main(args: Array[String]): Unit = {
val testVar = "hai"
val res = B.foo(testVar)
println(res)
}
}
@lrytz
lrytz / Test.java
Last active Oct 1, 2020
ForkJoinPool JDK 11+
View Test.java
import java.util.concurrent.*;
public class Test {
static boolean triggerIssue = true;
static ForkJoinPool fjp;
static void hotSleep(int ms) {
long until = System.nanoTime() + ms*1000_000;
while (System.nanoTime() < until) { }