Skip to content

Instantly share code, notes, and snippets.

# only keep nodes in scala.collection and immediate parents that aren't scala.ScalaObject, java.lang.Object, or scala.Product
gvpr 'E[index(tail.label, "scala.collection.") > -1 && index(head.label, "scala.ScalaObject") == -1
&& index(head.label, "java.lang.Object") == -1 && index(head.label, "scala.Product") == -1] {}' library_inherit.dot |
# discard nodes without edges
gvpr 'N[degree > 0] {} E{}' |
# make classes blue and objects red and shorten some names
sed -e 's/label="class /color=blue label="/' \
-e 's/label="object /color=red label="/' \
-e 's/label="scala.collection./label="c./' \
-e 's/label="c.immutable./label="c.immut./' \
import sbt._
class PrivateConfigurations(info: ProjectInfo) extends DefaultProject(info)
{
// define a custom configuration that will not get published
val compileOnly = config("compileOnly") hide
// add all dependencies in that configuration to the compile classpath
override def compileClasspath = super.compileClasspath +++ managedClasspath(compileOnly)
// in comments, the syntax:
// [A](B => C)
// represents a quantified function literal parameterized by type A
object Z
{
// The main type, a quantified function object
trait Q[M[_], N[_]] { def apply[C](m: M[C]): N[C] }
// Helper Types
import scala.xml._
import transform._
object Test {
// utility method for a simple interface to the transform package
def transform(xml: Node)(f: Node => Seq[Node]) = {
val rule = new RewriteRule { override def transform(n: Node) = f(n) }
val transformer = new RuleTransformer(rule)
transformer transform xml
}
Proposal: Default compiler/interpreter classpath in a managed environment
The compiler uses a default classpath of 'java.class.path'. Because many
applications do not use custom class loaders, this default is often sufficient
and no classpath configuration is required. This is because all jars- the
application and its dependencies, including the Scala compiler and library- are
in 'java.class.path' and the class loader for the application is the same as
that for Scala.
However, it does not work in more complicated setups, including various managed
trait ~>[A[_], B[_]] { def apply[T](a: A[T]): B[T] }
object Test {
def x[A[_],B[_]](f: A ~> B) = f
import Param._
val f = x { (p: Param[Option,List]) => p.ret( p.in.toList ) }
val a: List[Int] = f( Some(3) )
val b: List[String] = f( Some("aa") )
//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
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)
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))
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) )