diff options
| author | Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> | 2023-08-15 15:24:18 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-15 15:24:18 -0400 |
| commit | 3d7552582bb4d4e330b1e90bcdced046cebd140c (patch) | |
| tree | fb1d3a91dbc3d423217cf4d897b033ce5700e64f /source | |
| parent | 00bd481e001e8c0b8008eaff5a38fa37963e6f99 (diff) | |
Fix bug with overload resolution under nested generics (#3107)
* Add test for generic param inference bug for nested generics
* Change description & simplify test
* Add expected file
* Check parent decl before unifying type parameters
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-check-constraint.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source/slang/slang-check-constraint.cpp b/source/slang/slang-check-constraint.cpp index d66bf35cc..e7eccfaec 100644 --- a/source/slang/slang-check-constraint.cpp +++ b/source/slang/slang-check-constraint.cpp @@ -705,14 +705,16 @@ namespace Slang auto fstDeclRef = fstDeclRefType->getDeclRef(); if (auto typeParamDecl = as<GenericTypeParamDecl>(fstDeclRef.getDecl())) - return TryUnifyTypeParam(constraints, typeParamDecl, snd); + if (typeParamDecl->parentDecl == constraints.genericDecl) + return TryUnifyTypeParam(constraints, typeParamDecl, snd); if (auto sndDeclRefType = as<DeclRefType>(snd)) { auto sndDeclRef = sndDeclRefType->getDeclRef(); if (auto typeParamDecl = as<GenericTypeParamDecl>(sndDeclRef.getDecl())) - return TryUnifyTypeParam(constraints, typeParamDecl, fst); + if (typeParamDecl->parentDecl == constraints.genericDecl) + return TryUnifyTypeParam(constraints, typeParamDecl, fst); // can't be unified if they refer to different declarations. if (fstDeclRef.getDecl() != sndDeclRef.getDecl()) return false; @@ -816,7 +818,7 @@ namespace Slang if (auto typeParamDecl = as<GenericTypeParamDecl>(fstDeclRef.getDecl())) { - if(typeParamDecl->parentDecl == constraints.genericDecl ) + if(typeParamDecl->parentDecl == constraints.genericDecl) return TryUnifyTypeParam(constraints, typeParamDecl, snd); } } @@ -827,7 +829,7 @@ namespace Slang if (auto typeParamDecl = as<GenericTypeParamDecl>(sndDeclRef.getDecl())) { - if(typeParamDecl->parentDecl == constraints.genericDecl ) + if(typeParamDecl->parentDecl == constraints.genericDecl) return TryUnifyTypeParam(constraints, typeParamDecl, fst); } } |
