- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
scalac: a profile in courage
The subject is a reference to my wondering whether scalac had the
courage of its convictions with respect to the specification, as given here:
> A special rule concerns parameterless methods. If a paramterless
> method defined as def f: T = ...ordef f =
> ...overrides a method of type ()T′ whichhasan empty parameter list, then f
> is also assumed to have an empty parameter list.
So here was my gut check for scalac:
class A { def f1(): () => Int = () => 5 }
class B extends A {
override def f1 = () => 10
def f2 = () => 10
}
object Test {
def main(args: Array[String]): Unit = {
val b = new B
println(b.f1() + ", " + b.f2())
}
}
Well scalac? Are you all talk or do you REALLY assume f1 has an empty
parameter list?
% scala29 Test
, 10
Oh. Nice job I guess scalac.
Inciting commentary: http://lampsvn.epfl.ch/trac/scala/ticket/4506
Reason I copy to scala-debate: raise your hand if you've ever
implemented a structural type and thought "I'm sure glad that "def foo"
and "def foo()" are treated as distinct signatures, and that this
structural type will be able to cover at most one of those." I'm just
curious.









