+sub clear_constraint {
+ my $tc = shift;
+
+ while (1) {
+ if (ref $tc eq 'MooseX::Meta::TypeConstraint::Structured'){
+ for my $t (@{$tc->{type_constraints}}){
+ clear_constraint($t);
+ }
+
+ }
+ if (ref $tc eq 'Moose::Meta::TypeConstraint::Parameterized'){
+ clear_constraint($tc->{type_parameter});
+ }
+ last if ref $tc eq 'HASH';
+ last if ref $tc eq '';
+ if (defined $tc->{_type_constraint}){
+ $tc = $tc->{_type_constraint};
+ }elsif(defined $tc->{__type_constraint}){
+ $tc = $tc->{__type_constraint};
+ }else{
+ last;
+ }
+ }
+}
+
+sub clear_metains {
+ my $ins = shift;
+
+ for my $a (@{$ins->{attributes}}){
+ for my $m (@{$a->{associated_methods}}){
+ $m->{body} = undef;
+ }
+ clear_constraint($a->{isa});
+ }
+}
+
+sub clear_cycles {
+ my $c = shift;
+
+ for my $m (values %{$c->meta->{methods}}){
+ clear_constraint($m->{type_constraint});
+
+ my $ps = $m->{parsed_signature};
+ for my $p (@{$ps->{_positional_params}->{params}}){
+ clear_metains($p->{__MOP__}->{_meta_instance});
+ }
+
+ $m->{body} = undef;
+ }
+ clear_metains($c->meta->{_meta_instance});
+}
+
+