Contracts for Scala

  • Martin Odersky
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6418)


Contracts are partial specifications that can be added to program code. They are checked by compilers or other tools, or, more commonly, by runtime checks. Languages such as Eiffel[8], JML[7], or Spec#[1] support contracts natively. Scala [11] does not. Instead, Scala provides flexible syntax that helps in writing highlevel libraries which can often mimic true language extensions. An interesting question is to what degree this syntactic flexibility supports the embedding of contracts.


Class Invariant Program Synthesis Runtime Check Behavioral Interface Trait Invariant 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Barnett, M., DeLine, R., Fähndrich, M., Jacobs, B., Leino, K.R.M., Schulte, W., Venter, H.S.: The spec# programming system: Challenges and directions. In: Meyer, B., Woodcock, J. (eds.) VSTTE 2005. LNCS, vol. 4171, pp. 144–152. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  2. 2.
    Bengtson, J., Bhargavan, K., Fournet, C., Gordon, A.D., Maffeis, S.: Refinement types for secure implementations. In: CSF 2008: Proceedings of the 2008 21st IEEE Computer Security Foundations Symposium, Washington, DC, USA, pp. 17–32. IEEE Computer Society, Los Alamitos (2008)CrossRefGoogle Scholar
  3. 3.
    Claessen, K., Hughes, J.: Quickcheck: a lightweight tool for random testing of haskell programs. In: ICFP, pp. 268–279 (2000)Google Scholar
  4. 4.
    Flanagan, C.: Hybrid type checking. In: POPL 2006: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 245–256. ACM, New York (2006)CrossRefGoogle Scholar
  5. 5.
    Kawaguchi, M., Rondon, P.M., Jhala, R.: Type-based data structure verification. In: Hind, M., Diwan, A. (eds.) PLDI, pp. 304–315. ACM, New York (2009)CrossRefGoogle Scholar
  6. 6.
    Kuncak, V., Mayer, M., Piskac, R., Suter, P.: Complete functional synthesis. In: Zorn, B.G., Aiken, A. (eds.) PLDI, pp. 316–329. ACM, New York (2010)Google Scholar
  7. 7.
    Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary design of jml: a behavioral interface specification language for java. ACM SIGSOFT Software Engineering Notes 31(3), 1–38 (2006)CrossRefGoogle Scholar
  8. 8.
    Meyer, B.: Eiffel: The Language. Prentice Hall, Hemel Hempstead (1992)zbMATHGoogle Scholar
  9. 9.
    Nielsen, A.B.: Scala compiler phase and plug-in initialization (2008),
  10. 10.
    Nilsson, R.: Scalacheck user guide (2008), Scholar
  11. 11.
    Odersky, M., Spoon, L., Venners, B.: Programming in Scala. Artima (2008)Google Scholar
  12. 12.
    Rondon, P.M., Kawaguchi, M., Jhala, R.: Liquid types. In: Gupta, R., Amarasinghe, S.P. (eds.) PLDI, pp. 159–169. ACM, New York (2008)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2010

Authors and Affiliations

  • Martin Odersky
    • 1
  1. 1.École Polytechnique Fédérale de Lausanne (EPFL)LausanneSwitzerland

Personalised recommendations