@@ -1076,8 +1076,12 @@ namespace Slang
1076
1076
{
1077
1077
// The user is asking for us to actually perform the conversion,
1078
1078
// so we need to generate an appropriate expression here.
1079
-
1080
- throw " foo bar baz" ;
1079
+
1080
+ // YONGH: I am confused why we are not hitting this case before
1081
+ // throw "foo bar baz";
1082
+ // YONGH: temporary work around, may need to create the actual
1083
+ // invocation expr to the constructor call
1084
+ *outToExpr = fromExpr;
1081
1085
}
1082
1086
1083
1087
return true ;
@@ -1794,7 +1798,7 @@ namespace Slang
1794
1798
// `requiredMemberDeclRef` is a required member of
1795
1799
// the interface.
1796
1800
RefPtr<Decl> findWitnessForInterfaceRequirement (
1797
- DeclRef<AggTypeDecl > typeDeclRef,
1801
+ DeclRef<AggTypeDeclBase > typeDeclRef,
1798
1802
InheritanceDecl* inheritanceDecl,
1799
1803
DeclRef<InterfaceDecl> interfaceDeclRef,
1800
1804
DeclRef<Decl> requiredMemberDeclRef,
@@ -1833,24 +1837,22 @@ namespace Slang
1833
1837
1834
1838
// Make sure that by-name lookup is possible.
1835
1839
buildMemberDictionary (typeDeclRef.getDecl ());
1836
-
1837
- Decl* firstMemberOfName = nullptr ;
1838
- typeDeclRef.getDecl ()->memberDictionary .TryGetValue (name, firstMemberOfName);
1839
-
1840
- if (!firstMemberOfName)
1840
+ auto lookupResult = lookUpLocal (getSession (), this , name, typeDeclRef);
1841
+
1842
+ if (!lookupResult.isValid ())
1841
1843
{
1842
1844
getSink ()->diagnose (inheritanceDecl, Diagnostics::typeDoesntImplementInterfaceRequirement, typeDeclRef, requiredMemberDeclRef);
1843
1845
return nullptr ;
1844
1846
}
1845
1847
1846
1848
// Iterate over the members and look for one that matches
1847
1849
// the expected signature for the requirement.
1848
- for (auto memberDecl = firstMemberOfName; memberDecl; memberDecl = memberDecl-> nextInContainerWithSameName )
1850
+ for (auto member : lookupResult )
1849
1851
{
1850
- if (doesMemberSatisfyRequirement (DeclRef<Decl>(memberDecl, typeDeclRef. substitutions ) , requiredMemberDeclRef, requirementWitness))
1851
- return memberDecl ;
1852
+ if (doesMemberSatisfyRequirement (member. declRef , requiredMemberDeclRef, requirementWitness))
1853
+ return member. declRef . getDecl () ;
1852
1854
}
1853
-
1855
+
1854
1856
// No suitable member found, although there were candidates.
1855
1857
//
1856
1858
// TODO: Eventually we might want something akin to the current
@@ -1867,7 +1869,7 @@ namespace Slang
1867
1869
// (via the given `inheritanceDecl`) actually provides
1868
1870
// members to satisfy all the requirements in the interface.
1869
1871
bool checkInterfaceConformance (
1870
- DeclRef<AggTypeDecl > typeDeclRef,
1872
+ DeclRef<AggTypeDeclBase > typeDeclRef,
1871
1873
InheritanceDecl* inheritanceDecl,
1872
1874
DeclRef<InterfaceDecl> interfaceDeclRef)
1873
1875
{
@@ -1925,7 +1927,7 @@ namespace Slang
1925
1927
}
1926
1928
1927
1929
bool checkConformanceToType (
1928
- DeclRef<AggTypeDecl > typeDeclRef,
1930
+ DeclRef<AggTypeDeclBase > typeDeclRef,
1929
1931
InheritanceDecl* inheritanceDecl,
1930
1932
Type* baseType)
1931
1933
{
@@ -1953,7 +1955,7 @@ namespace Slang
1953
1955
// `inheritanceDecl` actually does what it needs to
1954
1956
// for that inheritance to be valid.
1955
1957
bool checkConformance (
1956
- DeclRef<AggTypeDecl > typeDecl,
1958
+ DeclRef<AggTypeDeclBase > typeDecl,
1957
1959
InheritanceDecl* inheritanceDecl)
1958
1960
{
1959
1961
// Look at the type being inherited from, and validate
@@ -1963,10 +1965,10 @@ namespace Slang
1963
1965
}
1964
1966
1965
1967
bool checkConformance (
1966
- AggTypeDecl * typeDecl,
1968
+ AggTypeDeclBase * typeDecl,
1967
1969
InheritanceDecl* inheritanceDecl)
1968
1970
{
1969
- return checkConformance (DeclRef<AggTypeDecl >(typeDecl, SubstitutionSet ()), inheritanceDecl);
1971
+ return checkConformance (DeclRef<AggTypeDeclBase >(typeDecl, SubstitutionSet ()), inheritanceDecl);
1970
1972
}
1971
1973
1972
1974
void visitAggTypeDecl (AggTypeDecl* decl)
@@ -3479,10 +3481,11 @@ namespace Slang
3479
3481
3480
3482
// TODO: need to check that the target type names a declaration...
3481
3483
3484
+ DeclRef<AggTypeDecl> aggTypeDeclRef;
3482
3485
if (auto targetDeclRefType = decl->targetType ->As <DeclRefType>())
3483
3486
{
3484
3487
// Attach our extension to that type as a candidate...
3485
- if (auto aggTypeDeclRef = targetDeclRefType->declRef .As <AggTypeDecl>())
3488
+ if (aggTypeDeclRef = targetDeclRefType->declRef .As <AggTypeDecl>())
3486
3489
{
3487
3490
auto aggTypeDecl = aggTypeDeclRef.getDecl ();
3488
3491
decl->nextCandidateExtension = aggTypeDecl->candidateExtensions ;
@@ -3516,6 +3519,14 @@ namespace Slang
3516
3519
EnsureDecl (m);
3517
3520
}
3518
3521
3522
+ if (aggTypeDeclRef)
3523
+ {
3524
+ for (auto inheritanceDecl : decl->getMembersOfType <InheritanceDecl>())
3525
+ {
3526
+ checkConformance (aggTypeDeclRef.getDecl (), inheritanceDecl);
3527
+ }
3528
+ }
3529
+
3519
3530
decl->SetCheckState (DeclCheckState::Checked);
3520
3531
}
3521
3532
@@ -3802,7 +3813,7 @@ namespace Slang
3802
3813
3803
3814
if ( auto aggTypeDeclRef = declRef.As <AggTypeDecl>() )
3804
3815
{
3805
- for ( auto inheritanceDeclRef : getMembersOfType <InheritanceDecl>(aggTypeDeclRef))
3816
+ for ( auto inheritanceDeclRef : getMembersOfTypeWithExt <InheritanceDecl>(aggTypeDeclRef))
3806
3817
{
3807
3818
EnsureDecl (inheritanceDeclRef.getDecl ());
3808
3819
0 commit comments