Groovy Language Specification  
First Draft  
Chapter 5

Conversions and Promotions

The organization of this chapter parallels the chapter on Conversions and Promotions in the Java Language Specification (second edition), which begins in part as follows:
This chapter first describes the seven categories of conversions (§5.1, JLS), including the special conversions to String allowed for the string concatenation operator +. Then the five conversion contexts are described:
  • Assignment conversion (§5.2, §15.26) converts the type of an expression to the type of a specified variable. The conversions permitted for assignment are limited in such a way that assignment conversion never causes an exception.
  • Method invocation conversion (§5.3, §15.9, §15.12) is applied to each argument in a method or constructor invocation and, except in one case, performs the same conversions that assignment conversion does. Method invocation conversion never causes an exception.
  • Casting conversion (§5.5, JLS) converts the type of an expression to a type explicitly specified by a cast operator (§15.16, JLS). It is more inclusive than assignment or method invocation conversion, allowing any specific conversion other than a string conversion, but certain casts to a reference type may cause an exception at run time.
  • String conversion (§5.4, §15.18.1) allows any type to be converted to type String.
  • Numeric promotion (§5.6, JLS) brings the operands of a numeric operator to a common type so that an operation can be performed.

5.1 Kinds of Conversion

(Cf. JLS. §5.1.)

TO DO

5.1.1 Identity Conversions

(Cf. JLS. §5.1.1.)

TO DO

5.1.2 Widening Primitive Conversion

(Cf. JLS. §5.1.2.)

TO DO

5.1.3 Narrowing Primitive Conversions

(Cf. JLS. §5.1.3.)

TO DO

5.1.4 Widening Reference Conversions

(Cf. JLS. §5.1.4.)

TO DO

5.1.5 Narrowing Reference Conversions

(Cf. JLS. §5.1.5.)

TO DO

5.1.6 String Conversions

(Cf. JLS. §5.1.6.)

TO DO

5.1.7 Forbidden Conversions

(Cf. JLS. §5.1.7.)

TO DO

5.1.8 Value Set Conversion

(Cf. JLS. §5.1.8.)

TO DO

5.2 Assignment Conversion

(Cf. JLS. §5.2.)

TO DO

5.3 Method Invocation Conversion

(Cf. JLS. §5.3.)

TO DO

5.4 String Conversion

(Cf. JLS. §5.4.)

TO DO

5.5 Casting Conversion

(Cf. JLS. §5.5.)

TO DO

5.6 Numeric Promotions

(Cf. JLS. §5.6.)

TO DO

5.6.1 Unary Numeric Promotion

(Cf. JLS. §5.6.1.)

TO DO

5.6.2 Binary Numeric Promotion

(Cf. JLS. §5.6.2.)

TO DO


Specification Table of Contents.

The organization of this chapter parallels the chapter on Conversions and Promotions in the Java Language Specification (second edition).

The original of this specification is at http://docs.codehaus.org/display/GroovyJSR.