blob: 16cf6c9aea1d1cc16008d60f53445d6f26049a1a [file] [log] [blame]
library /*isNonNullableByDefault*/;
import self as self;
import "dart:core" as core;
class A extends core::Object {
synthetic constructor •() self::A
: super core::Object::•()
;
method foo() dynamic
return 23;
}
extension B on self::A? {
method foo = self::B|foo;
tearoff foo = self::B|get#foo;
method bar = self::B|bar;
tearoff bar = self::B|get#bar;
}
extension C on self::A {
method bar = self::C|bar;
tearoff bar = self::C|get#bar;
}
extension D on () →? core::int {
method call = self::D|call;
tearoff call = self::D|get#call;
}
static method B|foo(lowered final self::A? #this) → dynamic
return 42;
static method B|get#foo(lowered final self::A? #this) → () → dynamic
return () dynamic => self::B|foo(#this);
static method B|bar(lowered final self::A? #this) → dynamic
return 87;
static method B|get#bar(lowered final self::A? #this) → () → dynamic
return () dynamic => self::B|bar(#this);
static method C|bar(lowered final self::A #this) → dynamic
return 123;
static method C|get#bar(lowered final self::A #this) → () → dynamic
return () dynamic => self::C|bar(#this);
static method D|call(lowered final () →? core::int #this) → core::int
return 76;
static method D|get#call(lowered final () →? core::int #this) → () → core::int
return () core::int => self::D|call(#this);
static method main() dynamic {
self::testA(new self::A::•());
self::testFunction(() core::int => 53);
}
static method testA(self::A? a) dynamic {
self::expect(23, let final self::A? #t1 = a in #t1 == null ?{dynamic} null : #t1{self::A}.{self::A::foo}(){() → dynamic});
self::expect(42, self::B|foo(a));
self::expect(123, let final self::A? #t2 = a in #t2 == null ?{dynamic} null : self::C|bar(#t2{self::A}));
self::expect(87, self::B|bar(a));
}
static method testFunction(() →? core::int f) dynamic {
self::expect(53, let final () →? core::int #t3 = f in #t3 == null ?{core::int?} null : #t3{() → core::int}(){() → core::int});
self::expect(76, self::D|call(f));
}
static method expect(dynamic expected, dynamic actual) dynamic {
if(!(expected =={core::Object::==}{(core::Object) core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}