This page is no longer maintained — Please continue to the home page at

scalac: a profile in courage

No replies
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

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:

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

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland