diff options
| author | Yong He <yonghe@outlook.com> | 2025-02-27 10:32:14 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-27 10:32:14 -0800 |
| commit | 6cf15f4ea1fe044d8227440dcc30ac712334568e (patch) | |
| tree | 668f3ef00fd0b144dd3221ee4ab8d344397649d8 /source/slang/slang-check-overload.cpp | |
| parent | 2ebf9555a54c00f45b1cd0bdd7f6c163120bb845 (diff) | |
Allow `.member` syntax on vector and scalars. (#6424)
* Allow `.member` syntax on vector and scalars.
* Fix.
* fix.
* Fix.
* update comment.
* Fix tests.
* Fix warning.
* Add more tests.
Diffstat (limited to 'source/slang/slang-check-overload.cpp')
| -rw-r--r-- | source/slang/slang-check-overload.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/source/slang/slang-check-overload.cpp b/source/slang/slang-check-overload.cpp index 5e55eb70f..21fc21df6 100644 --- a/source/slang/slang-check-overload.cpp +++ b/source/slang/slang-check-overload.cpp @@ -1316,15 +1316,17 @@ int SemanticsVisitor::CompareLookupResultItems( // Add a special case for constructors, where we prefer the one that is not synthesized, if (auto leftCtor = as<ConstructorDecl>(left.declRef.getDecl())) { - auto rightCtor = as<ConstructorDecl>(right.declRef.getDecl()); - bool leftIsSynthesized = - leftCtor->containsFlavor(ConstructorDecl::ConstructorFlavor::SynthesizedDefault); - bool rightIsSynthesized = - rightCtor->containsFlavor(ConstructorDecl::ConstructorFlavor::SynthesizedDefault); - - if (leftIsSynthesized != rightIsSynthesized) + if (auto rightCtor = as<ConstructorDecl>(right.declRef.getDecl())) { - return int(leftIsSynthesized) - int(rightIsSynthesized); + bool leftIsSynthesized = leftCtor->containsFlavor( + ConstructorDecl::ConstructorFlavor::SynthesizedDefault); + bool rightIsSynthesized = rightCtor->containsFlavor( + ConstructorDecl::ConstructorFlavor::SynthesizedDefault); + + if (leftIsSynthesized != rightIsSynthesized) + { + return int(leftIsSynthesized) - int(rightIsSynthesized); + } } } |
