library test;
import self as self;
import "dart:core" as core;

class C<E extends core::Object* = dynamic> extends core::Object {
  synthetic constructor •() → self::C<self::C::E*>*
    : super core::Object::•()
    ;
  method barA([(self::C::E*, self::C::E*) →* core::int* cmp = #C1]) → void {
    self::foo<self::C::E*>(this, let final (self::C::E*, self::C::E*) →* core::int* #t1 = cmp in #t1.{core::Object::==}(null) ?{(self::C::E*, self::C::E*) →* core::int*} #C2 : #t1);
  }
  method barB([(self::C::E*, self::C::E*) →* core::int* cmp = #C1]) → void {
    self::foo<self::C::E*>(this, let final (self::C::E*, self::C::E*) →* core::int* #t2 = cmp in #t2.{core::Object::==}(null) ?{(self::C::E*, self::C::E*) →* core::int*} #C2 : #t2);
  }
  method barC([(self::C::E*, self::C::E*) →* core::int* cmp = #C1]) → void {
    (self::C::E*, self::C::E*) →* core::int* v = #C2;
    self::foo<self::C::E*>(this, let final (self::C::E*, self::C::E*) →* core::int* #t3 = cmp in #t3.{core::Object::==}(null) ?{(self::C::E*, self::C::E*) →* core::int*} v : #t3);
  }
  method barD([(self::C::E*, self::C::E*) →* core::int* cmp = #C1]) → void {
    self::foo<self::C::E*>(this, let final (self::C::E*, self::C::E*) →* core::int* #t4 = cmp in #t4.{core::Object::==}(null) ?{(self::C::E*, self::C::E*) →* core::int*} #C2 : #t4);
  }
  method barE([(self::C::E*, self::C::E*) →* core::int* cmp = #C1]) → void {
    self::foo<self::C::E*>(this, cmp.{core::Object::==}(null) ?{(self::C::E*, self::C::E*) →* core::int*} #C2 : cmp);
  }
  method barF([(self::C::E*, self::C::E*) →* core::int* cmp = #C1]) → void {
    self::foo<self::C::E*>(this, !cmp.{core::Object::==}(null) ?{(self::C::E*, self::C::E*) →* core::int*} cmp : #C2);
  }
  static method _default(dynamic a, dynamic b) → core::int* {
    return 1.{core::int::unary-}();
  }
  abstract member-signature get _identityHashCode() → core::int*;
  abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*;
  abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*;
  abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*;
  abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*;
  abstract member-signature operator ==(dynamic other) → core::bool*;
  abstract member-signature get hashCode() → core::int*;
  abstract member-signature method toString() → core::String*;
  abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic;
  abstract member-signature get runtimeType() → core::Type*;
}
static method foo<E extends core::Object* = dynamic>(self::C<self::foo::E*>* c, (self::foo::E*, self::foo::E*) →* core::int* cmp) → void {}
static method main() → dynamic {}

constants  {
  #C1 = null
  #C2 = tearoff self::C::_default
}
