Skip to content

Commit c20a361

Browse files
Update mlir/include/mlir/Transforms/DialectConversion.h
Co-authored-by: Markus Böck <[email protected]>
1 parent e343021 commit c20a361

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mlir/include/mlir/Transforms/DialectConversion.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,19 @@ class TypeConverter {
434434
// This is a 1:N target materialization. Return the produces values
435435
// directly.
436436
result = callback(builder, resultTypes, inputs, loc, originalType);
437-
} else {
437+
} else if constexpr (std::is_assignable<Type, T>::value) {
438438
// This is a 1:1 target materialization. Invoke it only if the result
439439
// type class of the callback matches the requested result type.
440440
if (T derivedType = dyn_cast<T>(resultTypes.front())) {
441441
// 1:1 materializations produce single values, but we store 1:N
442442
// target materialization functions in the type converter. Wrap the
443443
// result value in a SmallVector<Value>.
444-
std::optional<Value> val =
445-
callback(builder, derivedType, inputs, loc, originalType);
446-
if (val.has_value() && *val)
447-
result.push_back(*val);
444+
Value val = callback(builder, derivedType, inputs, loc, originalType);
445+
if (val)
446+
result.push_back(val);
448447
}
448+
} else {
449+
static_assert(false, "T must be a Type or a TypeRange");
449450
}
450451
return result;
451452
};

0 commit comments

Comments
 (0)