diff options
| author | Ronan <ro.cailleau@gmail.com> | 2025-05-09 21:34:08 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-09 12:34:08 -0700 |
| commit | dbf05f8dca79d7bb166038652d968554d486c9fd (patch) | |
| tree | 432a19bebdfd0c1062c5e062542eae4e7880f79d /source/slang/slang-mangle.cpp | |
| parent | 5e5c08dc5ddf7989faf2f9f8ad76e260ba6385d7 (diff) | |
Fixed name mangling of generic extensions (#6671)
* Fixed name mangling of generic extensions
* Added tests for generic extensions linking.
- Disabled bugs/gh-6331.slang since it now triggers an assertion error revealed by the new version of the mangler.
* Re-enabled test gh-6331 (fixed by a5efbb1b775afb2f6b29b37d39947c41744bb005)
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-mangle.cpp')
| -rw-r--r-- | source/slang/slang-mangle.cpp | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/source/slang/slang-mangle.cpp b/source/slang/slang-mangle.cpp index aa30eef9d..f08ffd75d 100644 --- a/source/slang/slang-mangle.cpp +++ b/source/slang/slang-mangle.cpp @@ -391,6 +391,7 @@ void emitVal(ManglingContext* context, Val* val) void emitQualifiedName(ManglingContext* context, DeclRef<Decl> declRef, bool includeModuleName) { + bool ignoreName = false; if (!includeModuleName) { if (as<ModuleDecl>(declRef)) @@ -445,19 +446,6 @@ void emitQualifiedName(ManglingContext* context, DeclRef<Decl> declRef, bool inc return; } - // Inheritance declarations don't have meaningful names, - // and so we should emit them based on the type - // that is doing the inheriting. - if (auto inheritanceDeclRef = declRef.as<TypeConstraintDecl>()) - { - emit(context, "I"); - emitType(context, getSup(context->astBuilder, inheritanceDeclRef)); - return; - } - - // Similarly, an extension doesn't have a name worth - // emitting, and we should base things on its target - // type instead. if (auto extensionDeclRef = declRef.as<ExtensionDecl>()) { // TODO: as a special case, an "unconditional" extension @@ -471,7 +459,25 @@ void emitQualifiedName(ManglingContext* context, DeclRef<Decl> declRef, bool inc emit(context, "I"); emitType(context, getSup(context->astBuilder, inheritanceDecl)); } - return; + // A non generic extension doesn't have a name worth + // emitting, and we should base things on its target + // type instead. + if (parentGenericDeclRef) + { + ignoreName = true; + } + } + // Inheritance declarations don't have meaningful names, + // and so we should emit them based on the type + // that is doing the inheriting. + else if (auto inheritanceDeclRef = declRef.as<TypeConstraintDecl>()) + { + emit(context, "I"); + emitType(context, getSup(context->astBuilder, inheritanceDeclRef)); + if (parentGenericDeclRef) + { + ignoreName = true; + } } // TODO: we should special case GenericTypeParamDecl and GenericValueParamDecl nodes @@ -480,7 +486,10 @@ void emitQualifiedName(ManglingContext* context, DeclRef<Decl> declRef, bool inc // For each generic parameter, we should assign it a unique ID (i, j), where i is the // nesting level of the generic, and j is the sequential order of the parameter within // its generic parent, and use this 2D ID to refer to such a parameter. - emitName(context, declRef.getName()); + if (!ignoreName) + { + emitName(context, declRef.getName()); + } // Special case: accessors need some way to distinguish themselves // so that a getter/setter/ref-er don't all compile to the same name. |
