Correct instantiation of delayed opaques

I didn't realize that delayed instantiation of aliases instantiates
their real var, not the whole alias type. So prior to this, we were
wrapping all opaques in a structural `Alias(..)`. Which is okay from a
typechecking perspective because Aliases are transparent, but is
wasteful.
This commit is contained in:
Ayaz Hafiz 2022-05-07 16:46:37 -04:00 committed by ayazhafiz
parent a47dc711f3
commit 154b17d9f0

View file

@ -17,8 +17,8 @@ use roc_types::subs::{
};
use roc_types::types::Type::{self, *};
use roc_types::types::{
gather_fields_unsorted_iter, AliasCommon, AliasKind, Category, ErrorType, LambdaSet,
OptAbleType, OptAbleVar, PatternCategory, Reason, TypeExtension,
gather_fields_unsorted_iter, AliasCommon, AliasKind, Category, ErrorType, OptAbleType,
OptAbleVar, PatternCategory, Reason, TypeExtension,
};
use roc_unify::unify::{unify, Mode, Unified::*};
@ -327,9 +327,6 @@ impl Aliases {
}
let old_type_variables = delayed_variables.type_variables(&mut self.variables);
#[allow(clippy::needless_collect)] // otherwise we borrow self.variables immutably twice
let variable_opt_abilities: Vec<_> =
old_type_variables.iter().map(|ov| ov.opt_ability).collect();
let new_type_variables = &subs.variables[alias_variables.type_variables().indices()];
for (old, new) in old_type_variables.iter_mut().zip(new_type_variables) {