True if this structure has any non-generated ctor method (Klass`Klass). Ctor methods always live in the same module as the class (parser registers them together), so we look up by name hash via functionsByName / genericsByName. The `classParent == this` identity check defends against same-named classes in other modules bleeding in through generic instantiation.
| 297 | // The `classParent == this` identity check defends against same-named classes |
| 298 | // in other modules bleeding in through generic instantiation. |
| 299 | bool Structure::hasUserConstructor() const { |
| 300 | if ( !module ) return false; |
| 301 | string ctorName = name + "`" + name; |
| 302 | uint64_t hName = hash64z(ctorName.c_str()); |
| 303 | if ( auto kv = module->functionsByName.find(hName) ) { |
| 304 | for ( auto * fn : kv->second ) { |
| 305 | if ( !fn->generated && fn->classParent == this ) return true; |
| 306 | } |
| 307 | } |
| 308 | if ( auto kv = module->genericsByName.find(hName) ) { |
| 309 | for ( auto * fn : kv->second ) { |
| 310 | if ( !fn->generated && fn->classParent == this ) return true; |
| 311 | } |
| 312 | } |
| 313 | return false; |
| 314 | } |
| 315 | |
| 316 | // True if this structure has a non-generated 0-arg-callable ctor (no args, or |
| 317 | // all args default-initialized). Used by the synth-derived-ctor gate to verify |
no test coverage detected