home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (spec-t3896.scala)

This example Scala source code file (spec-t3896.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

array, atomic, atomic, atomicboolean, atomicboolean, boolean, boolean, r, t, t, test, unit

The Scala spec-t3896.scala source code

// see ticket #3896. Tests interaction between overloading, specialization and default params
trait Atomic[@specialized(Boolean) T] {
  def x: T
  // crash depends on the overloading: if second method is "g", no crash.
  def f(fn: T => T): Boolean = f(fn(x))
  def f[R](a: T, b: R = true) = b
class AtomicBoolean(val x: Boolean) extends Atomic[Boolean]

object Test {
  def main(args: Array[String]): Unit = {
    val e = new AtomicBoolean(false)
    val x = e.f( (a : Boolean) => !a ) // ok
    println( e.f( (a : Boolean) => !a ) toString ) // ok
    println( e.f( (a : Boolean) => !a) ) // compiler crash

Other Scala examples (source code examples)

Here is a short list of links related to this Scala spec-t3896.scala source code file:

my book on functional programming


new blog posts


Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.