TreeRef parseIdent() {
return String::create(L.expect(TK_IDENT).text());
}
- TypePtr parseBaseType() {
+ using TypeAndAlias = std::pair<TypePtr, c10::optional<AliasInfo>>;
+ TypeAndAlias parseBaseType() {
static std::unordered_map<std::string, TypePtr> type_map = {
{"Generator", GeneratorType::get()},
{"ScalarType", IntType::get()},
if (text.size() > 0 && islower(text[0])) {
// lower case identifiers that are not otherwise valid types
// are treated as type variables
- return VarType::create(text);
+ return TypeAndAlias(VarType::create(text), parseAliasAnnotation());
}
throw ErrorReport(tok.range) << "unknown type specifier";
}
- return it->second;
+ return TypeAndAlias(it->second, c10::nullopt);
}
// Examples:
// Tensor(a) // Tensor is in set a
value = DynamicType::get();
alias_info = parseAliasAnnotation();
} else {
- value = parseBaseType();
+ auto value_alias = parseBaseType();
+ value = value_alias.first;
+ alias_info = value_alias.second;
}
while (true) {
if (L.cur().kind == '[' && L.lookahead().kind == ']') {
return type->isSubtypeOf(DynamicType::get()) ||
type->kind() == TypeKind::ListType ||
type->kind() == TypeKind::TupleType ||
+ type->kind() == TypeKind::VarType ||
(type->kind() == TypeKind::OptionalType &&
shouldAnnotate(type->cast<OptionalType>()->getElementType()));
}
continue;
}
+ // If this type cannot alias, continue. Can occur with a VarType schema
+ if (!shouldAnnotate(actualValue)) {
+ continue;
+ }
+
// We don't support composite types for alias analysis yet.
JIT_ASSERT(formal->containedTypes().size() == 0);
// TODO neither unions nor wildcards make sense on an input. We should
continue;
}
+ // If this type cannot alias, continue. Can occur with a VarType schema
+ if (!shouldAnnotate(actual)) {
+ continue;
+ }
+
// We don't support composite types for alias analysis yet.
JIT_ASSERT(formal->containedTypes().size() == 0);