SourceSets not updated when queried

EDIT: Found out what was wrong, srcDir will add a source directory, not set it.
It works as expected with:

main {

In my opinion srcDir is a rather terrible name for that method, it should be called addSrcDir.
The half second saved in typing add is lost a thousand times over by this kind of subtle ambiguity.
I would certainly deprecate srcDir


Changes made to sourceSets are not visible:

plugins {
    id 'scala'
sourceSets {
    main {
        scala.srcDir 'whatever'

task debug << {
debug.dependsOn scaladoc

//why I need that info, not actually part of the issue:
scaladoc.scalaDocOptions.additionalParameters =
            ["-sourcepath "+sourceSets.main.scala.getSrcDirs().iterator().next().absolutePath,

running debug will print:
but it should print:

What is causing this? Is sourceSets not part of the initialization phase?

Is source sourceSets not a local variable, i.e. is srcDir ‘whatever’ not modifying sourceSets
itself but rather some other local object?

In any case, I am filing this as a bug because it does not seem like expected behavior.