Code inside #if

I just encountered a failing Release build due to a preprocessor switch (the DEBUG-variant was fine, the #else path had an error).
I'm sure that there was a time where the compiler would detect errors even if they won't be compiled into the binary, and it's a feature I considered to be quite useful.
Does anyone know when and why swiftc switched to the C-style behavior of completely ignoring code that was deactivated using #if directives?

I'm not sure the compiler has ever thoroughly checked "disabled" code. Consider for example, that some modules may be missing.

However, the compiler continues to check the syntax:

struct Foo {
    #if DEBUG
    bar // Compiler error: Expected declaration

    func f() {
        #if DEBUG
        bar // No compiler error
1 Like

Most likely true... I guess the stripping happened (and happens) after the tokenizer did its job:
The build failed because the involved types didn't have the required features, and swiftc still complains about code that can never be valid Swift.

It's a little bit surprising when some errors are detected, and others not - but considering that compilers normally work with separate stages, the behavior makes sense (and although my cases have been trivial, full checks could be very expensive in other scenarios).