groovy

Default method parameters

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-JSR-6
  • Fix Version/s: 1.5.2
  • Labels:
    None
  • Environment:
    Win XP, JDK1.5.0_06, JSR-06
  • Number of attachments :
    0

Description

A method declarator in an interface may include one or more default parameters.
These defaults should apply to only the parameters at the end of the parameter list.
JSR-06 permits them to appear anywhere.

Question: Do defaults in interfaces make sense? Could a class implementing the interface
offer a different default value? This leads to ambiguity.

Activity

Hide
blackdrag blackdrag added a comment -

offering a different default value is possible. But default args shouldn't be allowed in interfaces. It should generate non-abstract instance methods, which is not alllowed to do in an interface. So default args musn't be allowed for interfaces if the method is not static

Show
blackdrag blackdrag added a comment - offering a different default value is possible. But default args shouldn't be allowed in interfaces. It should generate non-abstract instance methods, which is not alllowed to do in an interface. So default args musn't be allowed for interfaces if the method is not static
Hide
Andres Almiray added a comment -

1.1-final-SNAPSHOT still allows the following

interface Foo {
   def doit( String param = "Groovy", int o )
}

def foo = { p -> p } as Foo
Show
Andres Almiray added a comment - 1.1-final-SNAPSHOT still allows the following
interface Foo {
   def doit( String param = "Groovy", int o )
}

def foo = { p -> p } as Foo
Hide
Paul King added a comment -

Now gives an error message

Show
Paul King added a comment - Now gives an error message

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: