@@ -979,9 +979,18 @@ static Type resolveTypeDecl(TypeDecl *typeDecl, SourceLoc loc,
979
979
auto &diags = ctx.Diags ;
980
980
auto lazyResolver = ctx.getLazyResolver ();
981
981
982
+ Type type = Type ();
983
+
984
+ // Use only the structural type of an alias decl in structural mode
985
+ auto aliasDecl = dyn_cast<TypeAliasDecl>(typeDecl);
986
+ if (resolution.getStage () == TypeResolutionStage::Structural &&
987
+ aliasDecl && !aliasDecl->getGenericParams () &&
988
+ !aliasDecl->getUnderlyingTypeLoc ().wasValidated ()) {
989
+ type = aliasDecl->getStructuralType ();
990
+
982
991
// Don't validate nominal type declarations during extension binding.
983
- if (!options.is (TypeResolverContext::ExtensionBinding) ||
984
- !isa<NominalTypeDecl>(typeDecl)) {
992
+ } else if (!options.is (TypeResolverContext::ExtensionBinding) ||
993
+ !isa<NominalTypeDecl>(typeDecl)) {
985
994
// Validate the declaration.
986
995
if (lazyResolver)
987
996
lazyResolver->resolveDeclSignature (typeDecl);
@@ -998,9 +1007,10 @@ static Type resolveTypeDecl(TypeDecl *typeDecl, SourceLoc loc,
998
1007
999
1008
// Resolve the type declaration to a specific type. How this occurs
1000
1009
// depends on the current context and where the type was found.
1001
- Type type =
1002
- TypeChecker::resolveTypeInContext (typeDecl, foundDC, resolution, options,
1003
- generic);
1010
+ if (!type)
1011
+ type =
1012
+ TypeChecker::resolveTypeInContext (typeDecl, foundDC, resolution,
1013
+ options, generic);
1004
1014
1005
1015
if (type->is <UnboundGenericType>() && !generic &&
1006
1016
!options.is (TypeResolverContext::TypeAliasDecl) &&
0 commit comments