@@ -1794,7 +1794,7 @@ namespace Slang
1794
1794
// `requiredMemberDeclRef` is a required member of
1795
1795
// the interface.
1796
1796
RefPtr<Decl> findWitnessForInterfaceRequirement (
1797
- DeclRef<AggTypeDecl > typeDeclRef,
1797
+ DeclRef<AggTypeDeclBase > typeDeclRef,
1798
1798
InheritanceDecl* inheritanceDecl,
1799
1799
DeclRef<InterfaceDecl> interfaceDeclRef,
1800
1800
DeclRef<Decl> requiredMemberDeclRef,
@@ -1833,22 +1833,20 @@ namespace Slang
1833
1833
1834
1834
// Make sure that by-name lookup is possible.
1835
1835
buildMemberDictionary (typeDeclRef.getDecl ());
1836
-
1837
- Decl* firstMemberOfName = nullptr ;
1838
- typeDeclRef.getDecl ()->memberDictionary .TryGetValue (name, firstMemberOfName);
1839
-
1840
- if (!firstMemberOfName)
1836
+ auto lookupResult = lookUpLocal (getSession (), this , name, typeDeclRef);
1837
+
1838
+ if (!lookupResult.isValid ())
1841
1839
{
1842
1840
getSink ()->diagnose (inheritanceDecl, Diagnostics::typeDoesntImplementInterfaceRequirement, typeDeclRef, requiredMemberDeclRef);
1843
1841
return nullptr ;
1844
1842
}
1845
1843
1846
1844
// Iterate over the members and look for one that matches
1847
1845
// the expected signature for the requirement.
1848
- for (auto memberDecl = firstMemberOfName; memberDecl; memberDecl = memberDecl-> nextInContainerWithSameName )
1846
+ for (auto member : lookupResult )
1849
1847
{
1850
- if (doesMemberSatisfyRequirement (DeclRef<Decl>(memberDecl, typeDeclRef. substitutions ) , requiredMemberDeclRef, requirementWitness))
1851
- return memberDecl ;
1848
+ if (doesMemberSatisfyRequirement (member. declRef , requiredMemberDeclRef, requirementWitness))
1849
+ return member. declRef . getDecl () ;
1852
1850
}
1853
1851
1854
1852
// No suitable member found, although there were candidates.
@@ -1867,7 +1865,7 @@ namespace Slang
1867
1865
// (via the given `inheritanceDecl`) actually provides
1868
1866
// members to satisfy all the requirements in the interface.
1869
1867
bool checkInterfaceConformance (
1870
- DeclRef<AggTypeDecl > typeDeclRef,
1868
+ DeclRef<AggTypeDeclBase > typeDeclRef,
1871
1869
InheritanceDecl* inheritanceDecl,
1872
1870
DeclRef<InterfaceDecl> interfaceDeclRef)
1873
1871
{
@@ -1925,7 +1923,7 @@ namespace Slang
1925
1923
}
1926
1924
1927
1925
bool checkConformanceToType (
1928
- DeclRef<AggTypeDecl > typeDeclRef,
1926
+ DeclRef<AggTypeDeclBase > typeDeclRef,
1929
1927
InheritanceDecl* inheritanceDecl,
1930
1928
Type* baseType)
1931
1929
{
@@ -1953,7 +1951,7 @@ namespace Slang
1953
1951
// `inheritanceDecl` actually does what it needs to
1954
1952
// for that inheritance to be valid.
1955
1953
bool checkConformance (
1956
- DeclRef<AggTypeDecl > typeDecl,
1954
+ DeclRef<AggTypeDeclBase > typeDecl,
1957
1955
InheritanceDecl* inheritanceDecl)
1958
1956
{
1959
1957
// Look at the type being inherited from, and validate
@@ -1963,10 +1961,10 @@ namespace Slang
1963
1961
}
1964
1962
1965
1963
bool checkConformance (
1966
- AggTypeDecl * typeDecl,
1964
+ AggTypeDeclBase * typeDecl,
1967
1965
InheritanceDecl* inheritanceDecl)
1968
1966
{
1969
- return checkConformance (DeclRef<AggTypeDecl >(typeDecl, SubstitutionSet ()), inheritanceDecl);
1967
+ return checkConformance (DeclRef<AggTypeDeclBase >(typeDecl, SubstitutionSet ()), inheritanceDecl);
1970
1968
}
1971
1969
1972
1970
void visitAggTypeDecl (AggTypeDecl* decl)
@@ -3479,10 +3477,11 @@ namespace Slang
3479
3477
3480
3478
// TODO: need to check that the target type names a declaration...
3481
3479
3480
+ DeclRef<AggTypeDecl> aggTypeDeclRef;
3482
3481
if (auto targetDeclRefType = decl->targetType ->As <DeclRefType>())
3483
3482
{
3484
3483
// Attach our extension to that type as a candidate...
3485
- if (auto aggTypeDeclRef = targetDeclRefType->declRef .As <AggTypeDecl>())
3484
+ if (aggTypeDeclRef = targetDeclRefType->declRef .As <AggTypeDecl>())
3486
3485
{
3487
3486
auto aggTypeDecl = aggTypeDeclRef.getDecl ();
3488
3487
decl->nextCandidateExtension = aggTypeDecl->candidateExtensions ;
@@ -3516,6 +3515,14 @@ namespace Slang
3516
3515
EnsureDecl (m);
3517
3516
}
3518
3517
3518
+ if (aggTypeDeclRef)
3519
+ {
3520
+ for (auto inheritanceDecl : decl->getMembersOfType <InheritanceDecl>())
3521
+ {
3522
+ checkConformance (aggTypeDeclRef.getDecl (), inheritanceDecl);
3523
+ }
3524
+ }
3525
+
3519
3526
decl->SetCheckState (DeclCheckState::Checked);
3520
3527
}
3521
3528
@@ -3802,7 +3809,7 @@ namespace Slang
3802
3809
3803
3810
if ( auto aggTypeDeclRef = declRef.As <AggTypeDecl>() )
3804
3811
{
3805
- for ( auto inheritanceDeclRef : getMembersOfType <InheritanceDecl>(aggTypeDeclRef))
3812
+ for ( auto inheritanceDeclRef : getMembersOfTypeWithExt <InheritanceDecl>(aggTypeDeclRef))
3806
3813
{
3807
3814
EnsureDecl (inheritanceDeclRef.getDecl ());
3808
3815
0 commit comments