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-lower-to-ir.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-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 45efca2d9..2271e750e 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -8242,6 +8242,16 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { subType = DeclRefType::create(context->astBuilder, makeDeclRef(parentDecl)); } + bool isGenericExtension = false; + // Test if we are in a generic extension context + if (parentDecl->parentDecl) + { + auto genDecl = as<GenericDecl>(parentDecl->parentDecl); + if (genDecl) + { + isGenericExtension = true; + } + } // What is the super-type that we have declared we inherit from? Type* superType = inheritanceDecl->base.type; @@ -8304,14 +8314,17 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> { // Construct the mangled name for the witness table, which depends // on the type that is conforming, and the type that it conforms to. - // - // TODO: This approach doesn't really make sense for generic `extension` - // conformances. - auto mangledName = getMangledNameForConformanceWitness( - context->astBuilder, - subType, - superType, - irSubType->getOp()); + String mangledName; + if (isGenericExtension) + { + mangledName = + getMangledNameForConformanceWitness(context->astBuilder, parentDecl, superType); + } + else + { + mangledName = + getMangledNameForConformanceWitness(context->astBuilder, subType, superType); + } // TODO(JS): // Should the mangled name take part in obfuscation if enabled? |
