AST: Assert in getInterfaceType() if no interface type is set

All decls except for ParamDecls must now have an interface type.
This commit is contained in:
Slava Pestov
2016-11-25 01:33:50 -05:00
parent 6cbb494ad2
commit e74d24687b

View File

@@ -1675,19 +1675,11 @@ Type ValueDecl::getInterfaceType() const {
if (!hasType())
return Type();
assert(!isa<AbstractFunctionDecl>(this) &&
"functions should have an interface type");
// FIXME: ParamDecls are funky and don't always have an interface type
if (isa<ParamDecl>(this))
return getType();
// If the type involves a type variable, don't cache it.
auto type = getType();
assert((type.isNull() || !type->is<PolymorphicFunctionType>())
&& "decl has polymorphic function type but no interface type");
if (type->hasTypeVariable())
return type;
InterfaceTy = type;
return InterfaceTy;
llvm_unreachable("decl has context type but no interface type");
}
void ValueDecl::setInterfaceType(Type type) {