@@ -7348,24 +7348,39 @@ void SILFunction::verifySILUndefMap() const {
73487348 }
73497349}
73507350
7351+ CanType SILProperty::getBaseType () const {
7352+ auto *decl = getDecl ();
7353+ auto *dc = decl->getInnermostDeclContext ();
7354+
7355+ // TODO: base type for global descriptors
7356+ auto sig = dc->getGenericSignatureOfContext ();
7357+ auto baseTy =
7358+ dc->getInnermostTypeContext ()->getSelfInterfaceType ()->getReducedType (
7359+ sig);
7360+ if (decl->isStatic ())
7361+ baseTy = CanMetatypeType::get (baseTy);
7362+
7363+ if (sig) {
7364+ auto env = dc->getGenericEnvironmentOfContext ();
7365+ baseTy = env->mapTypeIntoContext (baseTy)->getCanonicalType ();
7366+ }
7367+
7368+ return baseTy;
7369+ }
7370+
73517371// / Verify that a property descriptor follows invariants.
73527372void SILProperty::verify (const SILModule &M) const {
73537373 if (!verificationEnabled (M))
73547374 return ;
73557375
73567376 auto *decl = getDecl ();
7357- auto *dc = decl->getInnermostDeclContext ();
7358-
7359- // TODO: base type for global/static descriptors
7360- auto sig = dc->getGenericSignatureOfContext ();
7361- auto baseTy = dc->getInnermostTypeContext ()->getSelfInterfaceType ()
7362- ->getReducedType (sig);
7377+ auto sig = decl->getInnermostDeclContext ()->getGenericSignatureOfContext ();
73637378 auto leafTy = decl->getValueInterfaceType ()->getReducedType (sig);
73647379 SubstitutionMap subs;
73657380 if (sig) {
7366- auto env = dc->getGenericEnvironmentOfContext ();
7381+ auto env =
7382+ decl->getInnermostDeclContext ()->getGenericEnvironmentOfContext ();
73677383 subs = env->getForwardingSubstitutionMap ();
7368- baseTy = env->mapTypeIntoContext (baseTy)->getCanonicalType ();
73697384 leafTy = env->mapTypeIntoContext (leafTy)->getCanonicalType ();
73707385 }
73717386 bool hasIndices = false ;
@@ -7386,6 +7401,7 @@ void SILProperty::verify(const SILModule &M) const {
73867401 auto typeExpansionContext =
73877402 TypeExpansionContext::noOpaqueTypeArchetypesSubstitution (
73887403 ResilienceExpansion::Maximal);
7404+ auto baseTy = getBaseType ();
73897405 verifyKeyPathComponent (const_cast <SILModule&>(M),
73907406 typeExpansionContext,
73917407 getSerializedKind (),
0 commit comments