Weird: Simple actor does not compile

When trying to compile by dfx deploy A

actor B {
}

I get

/home/porton/t/test-dfx/src/B.mo:1.1-2.2: type error [M0014], non-static expression in library or module

Why doesn’t this sample compile? Workaround:

actor class B() {
}

Here is A.mo:

import Cycles "mo:base/ExperimentalCycles";
import B "./B";

actor class A() {
    public shared func init(): async () {
        Cycles.add(1000_000_000_000);
        // ignore await B.B();
    }
}

Weird: It is compiled fine by DFX.

The error message appears in MS Code text editor. Why the editor shows a message not appearing in compilation?!

Hm, closing and opening the file again in the editor has solved the problem.

The error appears regularly, when I edit the source file.

The problem disappears, when I close and reopen the source file.