@@ -4318,74 +4318,8 @@ OpaqueTypeArchetypeType::get(OpaqueTypeDecl *Decl, unsigned ordinal,
4318
4318
}
4319
4319
}
4320
4320
4321
- // Create a new opaque archetype.
4322
- // It lives in an environment in which the interface generic arguments of the
4323
- // decl have all been same-type-bound to the arguments from our substitution
4324
- // map.
4325
- SmallVector<Requirement, 2 > newRequirements;
4326
-
4327
- // TODO: The proper thing to do to build the environment in which the opaque
4328
- // type's archetype exists would be to take the generic signature of the
4329
- // decl, feed it into a GenericSignatureBuilder, then add same-type
4330
- // constraints into the builder to bind the outer generic parameters
4331
- // to their substituted types provided by \c Substitutions. However,
4332
- // this is problematic for interface types. In a situation like this:
4333
- //
4334
- // __opaque_type Foo<t_0_0: P>: Q // internal signature <t_0_0: P, t_1_0: Q>
4335
- //
4336
- // func bar<t_0_0, t_0_1, t_0_2: P>() -> Foo<t_0_2>
4337
- //
4338
- // we'd want to feed the GSB constraints to form:
4339
- //
4340
- // <t_0_0: P, t_1_0: Q where t_0_0 == t_0_2>
4341
- //
4342
- // even though t_0_2 isn't *in* the generic signature being built; it
4343
- // represents a type
4344
- // bound elsewhere from some other generic context. If we knew the generic
4345
- // environment `t_0_2` came from, then maybe we could map it into that context,
4346
- // but currently we have no way to know that with certainty.
4347
- //
4348
- // Because opaque types are currently limited so that they only have immediate
4349
- // protocol constraints, and therefore don't interact with the outer generic
4350
- // parameters at all, we can get away without adding these constraints for now.
4351
- // Adding where clauses would break this hack.
4352
- #if DO_IT_CORRECTLY
4353
- // Same-type-constrain the arguments in the outer signature to their
4354
- // replacements in the substitution map.
4355
- if (auto outerSig = Decl->getGenericSignature ()) {
4356
- for (auto outerParam : outerSig.getGenericParams ()) {
4357
- auto boundType = Type (outerParam).subst (Substitutions);
4358
- newRequirements.push_back (
4359
- Requirement (RequirementKind::SameType, Type (outerParam), boundType));
4360
- }
4361
- }
4362
- #else
4363
- // Assert that there are no same type constraints on the opaque type or its
4364
- // associated types.
4365
- //
4366
- // This should not be possible until we add where clause support, with the
4367
- // exception of generic base class constraints (handled below).
4368
- (void )newRequirements;
4369
- # ifndef NDEBUG
4370
- for (auto req :
4371
- Decl->getOpaqueInterfaceGenericSignature ().getRequirements ()) {
4372
- auto reqBase = req.getFirstType ()->getRootGenericParam ();
4373
- if (reqBase->isEqual (opaqueParamType)) {
4374
- assert (req.getKind () != RequirementKind::SameType
4375
- && " supporting where clauses on opaque types requires correctly "
4376
- " setting up the generic environment for "
4377
- " OpaqueTypeArchetypeTypes; see comment above" );
4378
- }
4379
- }
4380
- # endif
4381
- #endif
4382
- auto signature = buildGenericSignature (
4383
- ctx,
4384
- Decl->getOpaqueInterfaceGenericSignature (),
4385
- /* genericParams=*/ { },
4386
- std::move (newRequirements));
4387
-
4388
- auto reqs = signature->getLocalRequirements (opaqueParamType);
4321
+ auto reqs = Decl->getOpaqueInterfaceGenericSignature ()
4322
+ ->getLocalRequirements (opaqueParamType);
4389
4323
auto superclass = reqs.superclass ;
4390
4324
#if !DO_IT_CORRECTLY
4391
4325
// Ad-hoc substitute the generic parameters of the superclass.
@@ -4406,12 +4340,6 @@ OpaqueTypeArchetypeType::get(OpaqueTypeDecl *Decl, unsigned ordinal,
4406
4340
OpaqueTypeArchetypeType (Decl, Substitutions, properties, opaqueParamType,
4407
4341
reqs.protos , superclass, reqs.layout );
4408
4342
4409
- // Create a generic environment and bind the opaque archetype to the
4410
- // opaque interface type from the decl's signature.
4411
- auto *env = GenericEnvironment::getIncomplete (signature);
4412
- env->addMapping (GenericParamKey (opaqueParamType), newOpaque);
4413
- newOpaque->Environment = env;
4414
-
4415
4343
// Look up the insertion point in the folding set again in case something
4416
4344
// invalidated it above.
4417
4345
{
0 commit comments