Skip to content

Instantly share code, notes, and snippets.

@harrah
harrah / DeadlockAvoided.scala
Created February 5, 2013 14:09
Demonstrates "Resource deadlock avoided" exception on a file lock when there is no deadlock.
import java.io._
object A
{
/*
* Starts two concurrent threads that acquire file locks in a timed manner.
* Arguments:
* initialDelayA(ms) lockTimeA(ms) lockFileA initialDelayB(ms) lockTimeB(ms) lockFileB
*
* Example usage: demonstrates "Resource deadlock avoided" when there is no actual deadlock.
@harrah
harrah / gist:3866442
Created October 10, 2012 15:42
archive Google Code wiki to HTML, replace old wiki with links to archive
import org.jsoup._
import java.io.{File, FileWriter}
/*
libraryDependencies += "org.jsoup" % "jsoup" % "1.7.1"
scalaVersion := "2.10.0-M7"
*/
object Main {
val WikiSuffix = ".wiki"
val HtmlSuffix = ".html"
*** not compiled or checked, just for the idea ***
import sbt._
import Keys._
object MyBuild extends Build
{
... wiring into project not shown, see FullConfiguration for where to put `defaults` ...
val protocExePath = SettingKey[File]("protoc-exe-path")
You'll need 0.9.x set up (probably best to track 0.9 branch at this point):
https://github.com/harrah/xsbt/tree/0.9
$ git clone git://github.com/jorgeortiz85/rogue.git
$ cd rogue/
$ git checkout xsbt
$ xsbt
> compile
...
import sbt._
import xsbti.api._
class Single(info: ProjectInfo) extends DefaultProject(info)
{
lazy val allDefs = compile map { _.apis.internal.flatMap(_._2.definitions) }
lazy val modules = allDefs map {
_.collect { case c: ClassLike if c.definitionType == DefinitionType.Module => c.name }
}
}
import sbt._
import std._
class TaskTest extends SingleProject
{
lazy val hello: Task[Unit] =
task { println("Hi!") }
lazy val three: Task[Int] =
task { 3 }
import scala.collection.JavaConversions._
object A
{
def main(args: Array[String]) =
{
import X._
val list: java.util.List[GR] = new java.util.ArrayList[GR]
list.add(new GR)
println( list.map(_._1) )
Index: src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala
===================================================================
--- src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala (revision 22171)
+++ src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala (working copy)
@@ -890,7 +890,7 @@
&& !m.hasFlag(Flags.CASE | Flags.PRIVATE | Flags.PROTECTED | Flags.DEFERRED | Flags.SPECIALIZED)
&& !m.isConstructor
&& !m.isStaticMember
- && !(m.owner == definitions.AnyClass)
+ && !(m.owner == definitions.AnyClass || definitions.AbstractFunctionClass.contains(m.owner))
Index: src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala
===================================================================
--- src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala (revision 22206)
+++ src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala (working copy)
@@ -218,6 +218,8 @@
modifyName(x)("scala." + _)
else if (x.isTypeParameterOrSkolem)
explainName(x)
+ else if (x.nameString.forall(!_.isLetterOrDigit) && !isAlreadyAltered(x)) // symbol-only names are normally printed without prefixes
+ modifyName(x)(_ => " " + x.fullName)
//HList implementation not shown
// usual definition of ~>
// =~= is similar to =:= but for ~>
import MList._
sealed trait MList[+M[_]] {
// For converting MList[Id] to an HList
// This is useful because type inference doesn't work well with Id