Bug in Copy.expand() with closures

I think there is a bug in the Copy.expand() method, demonstrated with the following build script:

task testExpand << {
    def names = [ 'Pippo', 'Pluto' ]
    print "${ w -> names.each { name -> w << "{ $name }" } }"
}

task testCopy(type: Copy) {
    from file('Test.txt')
    into "${buildDir}"
    expand('names': [ 'Pippo', 'Pluto' ] )
}

The Test.txt file contains the same string passed to the print method in testExpand:

${ w -> names.each { name -> w << "{ $name }" } }

The output from testExpand is as expected

{ Pippo }{ Pluto }

While from testCopy I get the following error:

Caused by: groovy.lang.GroovyRuntimeException: Failed to parse template script (your template may contain an error or be trying to use expressions not currently supported): startup failed:
SimpleTemplateScript1.groovy: 1: expecting ‘}’, found ‘’ @ line 1, column 65.
name -> w << “{ $name }” } }""");