Weird: Simple actor does not compile

When trying to compile by dfx deploy A

actor B {

I get

/home/porton/t/test-dfx/src/ type error [M0014], non-static expression in library or module

Why doesn’t this sample compile? Workaround:

actor class B() {

Here is

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

actor class A() {
    public shared func init(): async () {
        // 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.