Files
swift-mirror/lib/Sema/CSSimplify.cpp
Slava Pestov 75bef7ca20 Sema: Fudge backward compatibility for init special declname
In Swift 4, constructors had the same name as properties,
methods and enum cases named `init`. This meant that you
could use constructor syntax to call such a member, which
caused some confusing behavior.

Recently I added a special declname for `init` so that
constructors have unique names distinct from any name you
can spell, and "foo.init" syntax would look for a member
with the special name rather than one named `init`.

Unfortunately people actually had code where they defined
members named `init` and then use them via normal member
lookup syntax, like this:

enum E {
  case `init`
}

let e: E = E.init

So to maintain backward compatibility, hack member lookup
to also find members named `init` when looking up the special
declname for constructors.

The workaround is only enabled in Swift 4 and 4.2 mode;
in Swift 5 mode you are expected to write "foo.`init`" to access
non-constructor members named `init`.

Fixes <rdar://problem/38682258>.
2018-06-14 20:41:27 -07:00

200 KiB