Project.file() evaluated inconsistently in subprojects block

Say I create a build with a root project and one subproject, .i.e,

.
├── build.gradle
├── foo
│   └── build.gradle
└── settings.gradle

and the root project contains the following:

subprojects {

    println "In subprojects block"
    println "    ${project}"
    println "    ${projectDir}"
    println "    " + file(".")

    def bar = {
        println "In bar closure in subprojects block"
        println "    ${project}"
        println "    ${projectDir}"
        println "    " + file(".")
    }

    bar()
}

When this is run, the two calls to file() behave differently, whereas the two evaluations of ${projectDir} behave similarly:

$ ./gradlew blah
In subprojects block
    project ':foo'
    /Users/me/gradle-file-test/foo
    /Users/me/gradle-file-test/foo
In bar closure in subprojects block
    project ':foo'
    /Users/me/gradle-file-test/foo
    /Users/me/gradle-file-test              <-- Unexpected
:foo:blah UP-TO-DATE

BUILD SUCCESSFUL

Total time: 0.612 secs

When invoked directly in the subprojects block, file('.') resolves to the :foo's directory, as expected. When invoked via a closure defined in the subprojects block, file('.') resolves instead to the directory of the project where the subprojects block is defined.

Is this a bug or the intended behavior?

I’ll probably go ahead and file a bug, if there are no thoughts here.