mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
remove HostExposedAlias
This commit is contained in:
parent
e6e1a13670
commit
5d3c7a9363
3 changed files with 13 additions and 310 deletions
|
@ -398,11 +398,6 @@ pub enum TypeTag {
|
|||
shared: Index<AliasShared>,
|
||||
actual: Index<TypeTag>,
|
||||
},
|
||||
HostExposedAlias {
|
||||
shared: Index<AliasShared>,
|
||||
actual_type: Index<TypeTag>,
|
||||
actual_variable: Variable,
|
||||
},
|
||||
|
||||
Apply {
|
||||
symbol: Symbol,
|
||||
|
@ -998,41 +993,6 @@ impl Types {
|
|||
self.set_type_tag(index, tag, type_arguments_slice)
|
||||
}
|
||||
|
||||
Type::HostExposedAlias {
|
||||
name,
|
||||
type_arguments,
|
||||
lambda_set_variables,
|
||||
actual_var,
|
||||
actual,
|
||||
} => {
|
||||
let type_arguments_slice = self.from_old_type_slice(type_arguments.iter());
|
||||
|
||||
let lambda_set_slice = {
|
||||
let slice = self.reserve_type_tags(lambda_set_variables.len());
|
||||
|
||||
for (index, argument) in slice.into_iter().zip(lambda_set_variables) {
|
||||
self.from_old_type_at(index, &argument.0);
|
||||
}
|
||||
|
||||
Slice::new(slice.start() as _, slice.len() as _)
|
||||
};
|
||||
|
||||
let alias_shared = AliasShared {
|
||||
symbol: *name,
|
||||
type_argument_abilities: Slice::default(),
|
||||
type_argument_regions: Slice::default(),
|
||||
lambda_set_variables: lambda_set_slice,
|
||||
infer_ext_in_output_variables: Slice::default(),
|
||||
};
|
||||
|
||||
let tag = TypeTag::HostExposedAlias {
|
||||
shared: Index::push_new(&mut self.aliases, alias_shared),
|
||||
actual_type: self.from_old_type(actual),
|
||||
actual_variable: *actual_var,
|
||||
};
|
||||
|
||||
self.set_type_tag(index, tag, type_arguments_slice)
|
||||
}
|
||||
Type::Variable(var) => {
|
||||
self.set_type_tag(index, TypeTag::Variable(*var), Slice::default())
|
||||
}
|
||||
|
@ -1217,27 +1177,6 @@ impl Types {
|
|||
new_type_arguments,
|
||||
)
|
||||
}
|
||||
HostExposedAlias {
|
||||
shared,
|
||||
actual_type,
|
||||
actual_variable,
|
||||
} => {
|
||||
let type_arguments = self.get_type_arguments(typ);
|
||||
|
||||
let new_type_arguments = defer_slice!(type_arguments);
|
||||
let new_shared = do_shared!(shared);
|
||||
let new_actual_type = defer!(actual_type);
|
||||
let new_actual_variable = subst!(actual_variable);
|
||||
|
||||
(
|
||||
HostExposedAlias {
|
||||
shared: new_shared,
|
||||
actual_type: new_actual_type,
|
||||
actual_variable: new_actual_variable,
|
||||
},
|
||||
new_type_arguments,
|
||||
)
|
||||
}
|
||||
Apply {
|
||||
symbol,
|
||||
type_argument_regions,
|
||||
|
@ -1432,12 +1371,7 @@ mod debug_types {
|
|||
maybe_paren!(Free, p, alias(types, f, tag, shared))
|
||||
}
|
||||
TypeTag::StructuralAlias { shared, actual }
|
||||
| TypeTag::OpaqueAlias { shared, actual }
|
||||
| TypeTag::HostExposedAlias {
|
||||
shared,
|
||||
actual_type: actual,
|
||||
actual_variable: _,
|
||||
} => maybe_paren!(
|
||||
| TypeTag::OpaqueAlias { shared, actual } => maybe_paren!(
|
||||
Free,
|
||||
p,
|
||||
alias(types, f, tag, shared)
|
||||
|
@ -1743,13 +1677,6 @@ pub enum Type {
|
|||
actual: Box<Type>,
|
||||
kind: AliasKind,
|
||||
},
|
||||
HostExposedAlias {
|
||||
name: Symbol,
|
||||
type_arguments: Vec<Type>,
|
||||
lambda_set_variables: Vec<LambdaSet>,
|
||||
actual_var: Variable,
|
||||
actual: Box<Type>,
|
||||
},
|
||||
RecursiveTagUnion(Variable, Vec<(TagName, Vec<Type>)>, TypeExtension),
|
||||
/// Applying a type to some arguments (e.g. Dict.Dict String Int)
|
||||
Apply(Symbol, Vec<Loc<Type>>, Region),
|
||||
|
@ -1836,19 +1763,6 @@ impl Clone for Type {
|
|||
actual: actual.clone(),
|
||||
kind: *kind,
|
||||
},
|
||||
Self::HostExposedAlias {
|
||||
name,
|
||||
type_arguments,
|
||||
lambda_set_variables,
|
||||
actual_var,
|
||||
actual,
|
||||
} => Self::HostExposedAlias {
|
||||
name: *name,
|
||||
type_arguments: type_arguments.clone(),
|
||||
lambda_set_variables: lambda_set_variables.clone(),
|
||||
actual_var: *actual_var,
|
||||
actual: actual.clone(),
|
||||
},
|
||||
Self::RecursiveTagUnion(arg0, arg1, arg2) => {
|
||||
Self::RecursiveTagUnion(*arg0, arg1.clone(), arg2.clone())
|
||||
}
|
||||
|
@ -2054,22 +1968,6 @@ impl fmt::Debug for Type {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
Type::HostExposedAlias {
|
||||
name,
|
||||
type_arguments: arguments,
|
||||
..
|
||||
} => {
|
||||
write!(f, "HostExposedAlias {name:?}")?;
|
||||
|
||||
for arg in arguments {
|
||||
write!(f, " {arg:?}")?;
|
||||
}
|
||||
|
||||
// Sometimes it's useful to see the expansion of the alias
|
||||
// write!(f, "[ but actually {:?} ]", _actual)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Type::Record(fields, ext) => {
|
||||
write!(f, "{{")?;
|
||||
|
||||
|
@ -2384,22 +2282,6 @@ impl Type {
|
|||
|
||||
stack.push(actual);
|
||||
}
|
||||
HostExposedAlias {
|
||||
type_arguments,
|
||||
lambda_set_variables,
|
||||
actual: actual_type,
|
||||
..
|
||||
} => {
|
||||
for value in type_arguments.iter_mut() {
|
||||
stack.push(value);
|
||||
}
|
||||
|
||||
for lambda_set in lambda_set_variables.iter_mut() {
|
||||
stack.push(lambda_set.as_inner_mut());
|
||||
}
|
||||
|
||||
stack.push(actual_type);
|
||||
}
|
||||
Apply(_, args, _) => {
|
||||
stack.extend(args.iter_mut().map(|t| &mut t.value));
|
||||
}
|
||||
|
@ -2522,22 +2404,6 @@ impl Type {
|
|||
|
||||
stack.push(actual);
|
||||
}
|
||||
HostExposedAlias {
|
||||
type_arguments,
|
||||
lambda_set_variables,
|
||||
actual: actual_type,
|
||||
..
|
||||
} => {
|
||||
for value in type_arguments.iter_mut() {
|
||||
stack.push(value);
|
||||
}
|
||||
|
||||
for lambda_set in lambda_set_variables.iter_mut() {
|
||||
stack.push(lambda_set.as_inner_mut());
|
||||
}
|
||||
|
||||
stack.push(actual_type);
|
||||
}
|
||||
Apply(_, args, _) => {
|
||||
stack.extend(args.iter_mut().map(|t| &mut t.value));
|
||||
}
|
||||
|
@ -2640,10 +2506,6 @@ impl Type {
|
|||
}
|
||||
alias_actual.substitute_alias(rep_symbol, rep_args, actual)
|
||||
}
|
||||
HostExposedAlias {
|
||||
actual: actual_type,
|
||||
..
|
||||
} => actual_type.substitute_alias(rep_symbol, rep_args, actual),
|
||||
Apply(symbol, args, region) if *symbol == rep_symbol => {
|
||||
if args.len() == rep_args.len()
|
||||
&& args
|
||||
|
@ -2727,9 +2589,6 @@ impl Type {
|
|||
actual: actual_type,
|
||||
..
|
||||
} => alias_symbol == &rep_symbol || actual_type.contains_symbol(rep_symbol),
|
||||
HostExposedAlias { name, actual, .. } => {
|
||||
name == &rep_symbol || actual.contains_symbol(rep_symbol)
|
||||
}
|
||||
Apply(symbol, _, _) if *symbol == rep_symbol => true,
|
||||
Apply(_, args, _) => args.iter().any(|arg| arg.value.contains_symbol(rep_symbol)),
|
||||
RangedNumber(_) => false,
|
||||
|
@ -2793,7 +2652,6 @@ impl Type {
|
|||
actual: actual_type,
|
||||
..
|
||||
} => actual_type.contains_variable(rep_variable),
|
||||
HostExposedAlias { actual, .. } => actual.contains_variable(rep_variable),
|
||||
Apply(_, args, _) => args
|
||||
.iter()
|
||||
.any(|arg| arg.value.contains_variable(rep_variable)),
|
||||
|
@ -2996,22 +2854,6 @@ fn instantiate_aliases<'a, F>(
|
|||
.iter_mut()
|
||||
.for_each(|t| instantiate_aliases(&mut t.value.typ, region, aliases, ctx));
|
||||
}
|
||||
HostExposedAlias {
|
||||
type_arguments: type_args,
|
||||
lambda_set_variables,
|
||||
actual: actual_type,
|
||||
..
|
||||
} => {
|
||||
for arg in type_args {
|
||||
instantiate_aliases(arg, region, aliases, ctx);
|
||||
}
|
||||
|
||||
for arg in lambda_set_variables {
|
||||
arg.instantiate_aliases(region, aliases, ctx);
|
||||
}
|
||||
|
||||
instantiate_aliases(&mut *actual_type, region, aliases, ctx);
|
||||
}
|
||||
Alias {
|
||||
type_arguments: type_args,
|
||||
lambda_set_variables,
|
||||
|
@ -3170,12 +3012,6 @@ fn symbols_help(initial: &Type) -> Vec<Symbol> {
|
|||
output.push(*alias_symbol);
|
||||
stack.push(actual_type);
|
||||
}
|
||||
HostExposedAlias { name, actual, .. } => {
|
||||
// because the type parameters are inlined in the actual type, we don't need to look
|
||||
// at the type parameters here
|
||||
output.push(*name);
|
||||
stack.push(actual);
|
||||
}
|
||||
Apply(symbol, args, _) => {
|
||||
output.push(*symbol);
|
||||
stack.extend(args.iter().map(|t| &t.value));
|
||||
|
@ -3301,16 +3137,6 @@ fn variables_help(tipe: &Type, accum: &mut ImSet<Variable>) {
|
|||
}
|
||||
variables_help(actual, accum);
|
||||
}
|
||||
HostExposedAlias {
|
||||
type_arguments: arguments,
|
||||
actual,
|
||||
..
|
||||
} => {
|
||||
for arg in arguments {
|
||||
variables_help(arg, accum);
|
||||
}
|
||||
variables_help(actual, accum);
|
||||
}
|
||||
RangedNumber(_) => {}
|
||||
Apply(_, args, _) => {
|
||||
for x in args {
|
||||
|
@ -3453,16 +3279,6 @@ fn variables_help_detailed(tipe: &Type, accum: &mut VariableDetail) {
|
|||
}
|
||||
variables_help_detailed(actual, accum);
|
||||
}
|
||||
HostExposedAlias {
|
||||
type_arguments: arguments,
|
||||
actual,
|
||||
..
|
||||
} => {
|
||||
for arg in arguments {
|
||||
variables_help_detailed(arg, accum);
|
||||
}
|
||||
variables_help_detailed(actual, accum);
|
||||
}
|
||||
RangedNumber(_) => {}
|
||||
Apply(_, args, _) => {
|
||||
for x in args {
|
||||
|
@ -4653,20 +4469,6 @@ fn instantiate_lambda_sets_as_unspecialized(
|
|||
stack.push(actual);
|
||||
stack.extend(type_arguments.iter_mut().rev().map(|t| &mut t.typ));
|
||||
}
|
||||
Type::HostExposedAlias {
|
||||
name: _,
|
||||
type_arguments,
|
||||
lambda_set_variables,
|
||||
actual_var: _,
|
||||
actual,
|
||||
} => {
|
||||
for lambda_set in lambda_set_variables.iter_mut() {
|
||||
debug_assert!(matches!(lambda_set.0, Type::Variable(_)));
|
||||
lambda_set.0 = new_uls();
|
||||
}
|
||||
stack.push(actual);
|
||||
stack.extend(type_arguments.iter_mut().rev());
|
||||
}
|
||||
Type::Apply(_sym, args, _region) => {
|
||||
stack.extend(args.iter_mut().rev().map(|t| &mut t.value));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue