|
Scala example source code file (spec-t3896.scala)
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 println(runtime.BoxesRunTime.integerBoxCount) } } Other Scala examples (source code examples)Here is a short list of links related to this Scala spec-t3896.scala source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 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.