mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Don't record the declared type of nominal type decls within the module file.
Instead, compute the type just after we load the nominal type declaration. This centralizes the type-computation code better as well. Swift SVN r7454
This commit is contained in:
@@ -626,9 +626,14 @@ NominalType *NominalType::get(NominalTypeDecl *D, Type Parent, const ASTContext
|
||||
return StructType::get(cast<StructDecl>(D), Parent, C);
|
||||
case DeclKind::Class:
|
||||
return ClassType::get(cast<ClassDecl>(D), Parent, C);
|
||||
case DeclKind::Protocol:
|
||||
case DeclKind::Protocol: {
|
||||
assert(!Parent && "Protocols cannot have parents");
|
||||
return ProtocolType::get(cast<ProtocolDecl>(D), C);
|
||||
auto proto = cast<ProtocolDecl>(D);
|
||||
if (!proto->hasType())
|
||||
proto->computeType();
|
||||
|
||||
return proto->getDeclaredType()->castTo<ProtocolType>();
|
||||
}
|
||||
|
||||
default:
|
||||
llvm_unreachable("Not a nominal declaration!");
|
||||
@@ -879,14 +884,6 @@ OptionalType *OptionalType::get(Type base, const ASTContext &C) {
|
||||
return entry = new (C, arena) OptionalType(base, hasTypeVariable);
|
||||
}
|
||||
|
||||
ProtocolType *ProtocolType::get(ProtocolDecl *D, const ASTContext &C) {
|
||||
// If the declaration already has a type, return that.
|
||||
if (D->hasType())
|
||||
return D->getDeclaredType()->castTo<ProtocolType>();
|
||||
|
||||
return new (C, AllocationArena::Permanent) ProtocolType(D, C);
|
||||
}
|
||||
|
||||
ProtocolType::ProtocolType(ProtocolDecl *TheDecl, const ASTContext &Ctx)
|
||||
: NominalType(TypeKind::Protocol, &Ctx, TheDecl, /*Parent=*/Type(),
|
||||
/*HasTypeVariable=*/false) { }
|
||||
|
||||
Reference in New Issue
Block a user