Skip to content

Instantly share code, notes, and snippets.

View paulp's full-sized avatar
🤫

Paul Phillips paulp

🤫
  • CAZ, Inc.
  • Cascadia Autonomous Zone
View GitHub Profile
/**
* Process an Expression type node reflectively; must return a JExpression.
*/
protected JExpression dispProcessExpression(Expression x) {
/*
* Note that we always prefer a JDT-computed constant value to the actual
* written expression. (Let's hope JDT is always right.) This means we
* don't have to write processExpression methods for the numerous JDT
* literal nodes because they ALWAYS have a constant value.
*/
trait PatternNodes { self: transform.ExplicitOuter =>
import global._
import symtab.Flags
final def DBG(x: => String) = if (settings.debug.value) Console.println(x)
final def getDummies(i: Int): List[Tree] = List.make(i, EmptyTree)
def makeBind(vs:List[Symbol], pat:Tree): Tree =
if (vs eq Nil) pat else Bind(vs.head, makeBind(vs.tail, pat)) setType pat.tpe
object b {
trait Ops[T] {
def +(y: T): T
def ^(y: Int): T
}
implicit def intops(x: Int) = new Ops[Int] {
def +(y: Int) = x + y
def ^(y: Int) = Math.pow(x, y).toInt
}
** match **
[[syntax trees at end of typer]]// Scala source: orig1.scala
package <empty> {
@scala.this.serializable case abstract class Base extends lang.this.Object with scala.this.ScalaObject with scala.this.Product {
<method> def this(): <empty>.this.Base = {
Base.super.this();
()
};
override <method> def $tag(): scala.this.Int = 2063089;
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<head>
<title>Scala Ubiquity Commands</title>
</head>
<body>
<p>This xhtml source contains commands for executing scala code.
Its corresponding feed is <a href="sscala.html">here</a>.</p>
<script src="fake-infrastructure.js"></script>
scala> object T {
| def main(args : Array[String]) {
| val example = "example" η
| ()
| }
| }
<console>:6: error: value η is not a member of java.lang.String
val example = "example" η
^
[paulp@jon tmp]$ scalac p.scala
p.scala:3: error: value ? is not a member of java.lang.String
val example = "example" ?
^
one error found
[paulp@jon tmp]$ JAVA_OPTS="-Dfile.encoding=UTF-8" scalac p.scala
p.scala:3: error: value η is not a member of java.lang.String
val example = "example" η
^
one error found
sealed abstract class weak_<:<[-From, +To] extends (From => To)
implicit val weakByteChar = new weak_<:<[Byte, Char] { def apply(x: Byte): Char = x.toChar }
implicit val weakByteShort = new weak_<:<[Byte, Short] { def apply(x: Byte): Short = x.toShort }
implicit val weakByteInt = new weak_<:<[Byte, Int] { def apply(x: Byte): Int = x.toInt }
implicit val weakByteLong = new weak_<:<[Byte, Long] { def apply(x: Byte): Long = x.toLong }
implicit val weakByteFloat = new weak_<:<[Byte, Float] { def apply(x: Byte): Float = x.toFloat }
implicit val weakByteDouble = new weak_<:<[Byte, Double] { def apply(x: Byte): Double = x.toDouble }
implicit val weakShortInt = new weak_<:<[Short, Int] { def apply(x: Short): Int = x.toInt }
implicit val weakShortLong = new weak_<:<[Short, Long] { def apply(x: Short): Long = x.toLong }
implicit val weakShortFloat = new weak_<:<[Short, Float] { def apply(x: Short): Float = x.toFloat }
diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala
index 3b05a58..73ddb01 100644
--- a/src/library/scala/reflect/ClassManifest.scala
+++ b/src/library/scala/reflect/ClassManifest.scala
@@ -72,6 +72,10 @@ trait ClassManifest[T] extends OptManifest[T] with Equals {
def >:>(that: ClassManifest[_]): Boolean =
that <:< this
+ /** Tests for weak conformance.
+ */
// The comments show everything I type:
// ccc<tab>
class Class(arguments) {
override def hashCode = 0 arguments
override def equals(other: Any) = Class.unapply(this) == Class.unapply(other)
override def canEqual(other: Any) = other.isInstanceOf[Class]
}