From 48e795deccc678d650e79925221a308df71d7f75 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 17 May 2018 01:06:52 -0700 Subject: [PATCH] apply_substitution for PolyTypes If I made an error it's likely here... --- schala-lang/src/typechecking.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/schala-lang/src/typechecking.rs b/schala-lang/src/typechecking.rs index c9b31e5..f3cf6cf 100644 --- a/schala-lang/src/typechecking.rs +++ b/schala-lang/src/typechecking.rs @@ -102,7 +102,15 @@ impl PolyType { } fn apply_substitution(&self, s: &Substitution) -> PolyType { - unimplemented!() + let mut map: HashMap, MonoType> = HashMap::new(); + for (name, monotype) in s.0.iter() { + if let None = self.0.get(name) { + map.insert(name.clone(), monotype.clone()); + } + } + let newsub = Substitution(map); + let new = self.1.apply_substitution(&newsub); + PolyType(self.0.clone(), new) } }