Added the concept of subtypes ...

... which `try` now uses to avoid some problems with inner types
This commit is contained in:
Mark
2023-10-24 09:31:49 +02:00
parent ea95a16c30
commit 5e20f92849
13 changed files with 111 additions and 13 deletions

View File

@@ -28,7 +28,7 @@ impl Config {
}
let arg_type = &t.0[0];
let functions = &t.0[1];
for arg_type in arg_type.types.iter() {
for arg_type in arg_type.subtypes_type().types.iter() {
let arg_type = Type::newm(vec![arg_type.clone()]);
// possibilities for the tuple (f1, f2, f3, ..., fn)
for ft in functions.types.iter() {

View File

@@ -83,7 +83,7 @@ impl Config {
#[derive(Clone, Debug)]
pub struct RunCommandError(String);
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct RunCommandErrorT;
impl MersData for RunCommandError {
fn is_eq(&self, other: &dyn MersData) -> bool {
@@ -116,6 +116,9 @@ impl MersType for RunCommandErrorT {
fn is_included_in_single(&self, target: &dyn MersType) -> bool {
self.is_same_type_as(target)
}
fn subtypes(&self, acc: &mut Type) {
acc.add(Arc::new(self.clone()));
}
fn as_any(&self) -> &dyn std::any::Any {
self
}

View File

@@ -247,6 +247,10 @@ impl MersType for IterT {
false
}
}
fn subtypes(&self, acc: &mut Type) {
// NOTE: This might not be good enough
acc.add(Arc::new(self.clone()));
}
fn as_any(&self) -> &dyn std::any::Any {
self
}

View File

@@ -201,6 +201,11 @@ impl MersType for ListT {
fn is_included_in_single(&self, target: &dyn MersType) -> bool {
self.is_same_type_as(target)
}
fn subtypes(&self, acc: &mut Type) {
for t in self.0.subtypes_type().types {
acc.add(Arc::new(Self(Type::newm(vec![t]))));
}
}
fn as_any(&self) -> &dyn std::any::Any {
self
}

View File

@@ -127,6 +127,11 @@ impl MersType for ThreadT {
false
}
}
fn subtypes(&self, acc: &mut Type) {
for t in self.0.subtypes_type().types {
acc.add(Arc::new(Self(Type::newm(vec![t]))));
}
}
fn as_any(&self) -> &dyn std::any::Any {
self
}