Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Treat subsets in MMD as base type + where
  • Loading branch information
sorear committed Jan 10, 2012
1 parent c5f959c commit 4336983
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/CodeGen.cs
Expand Up @@ -4314,6 +4314,12 @@ public class DowncallReceiver : CallReceiver {
subset.initVar = basety.initVar;
return null;
}
public static object type_get_basetype(object[] args) {
return Handle.Wrap(((STable)Handle.Unbox(args[1])).mo.superclasses[0]);
}
public static object type_get_type_var(object[] args) {
return Handle.Wrap(((STable)Handle.Unbox(args[1])).typeVar);
}
public static object type_set_where(object[] args) {
STable subset = (STable)Handle.Unbox(args[1]);
SubInfo where = (SubInfo)Handle.Unbox(args[2]);
Expand Down
8 changes: 7 additions & 1 deletion src/niecza
Expand Up @@ -286,7 +286,13 @@ method parameter($/) {
::Op::GeneralConst.new(value => $tc.ast<value>));
} else {
$/.CURSOR.sorry("Parameter coercion NYI") if $tc.ast<as>;
$/.ast.tclass = $tc.ast<type>;
my $type = $tc.ast<type>;
if $type.kind eq 'subset' {
push ($/.ast.where //= []), self.thunk_sub(
::Op::GeneralConst.new(value => $type.get_type_var));
$type = $type.get_basetype while $type.kind eq 'subset';
}
$/.ast.tclass = $type;
$/.ast.flags +|= $tc.ast<tmode>;
}
}
Expand Down

0 comments on commit 4336983

Please sign in to comment.