Don't copy decorations twice when rebuilding a type. (#1835)

In `TypeManager::RebuildType`, the base cases call `Clone`, which will
copy the decorations for the type.  After that it breaks out of the
switch statement and copies the decorations again.

This has not causes any real problems yet because none of those types
are allowed to have decorations.  However to make the code more robust
it is best to not copy twice because it should be empty.

This way if a new base type or decoration is added that changes this
rule the code will be correct.
This commit is contained in:
Steven Perron 2018-08-14 11:26:14 -04:00 committed by GitHub
parent 8cb949ad34
commit bf24d9b4ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -448,7 +448,8 @@ Type* TypeManager::RebuildType(const Type& type) {
#define DefineNoSubtypeCase(kind) \
case Type::k##kind: \
rebuilt_ty.reset(type.Clone().release()); \
break;
return type_pool_.insert(std::move(rebuilt_ty)).first->get();
DefineNoSubtypeCase(Void);
DefineNoSubtypeCase(Bool);
DefineNoSubtypeCase(Integer);