mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:01:30 +00:00
912005267d
Change-Id: I46be49b2effec3e38a3dc44cd45cfe736f77fa78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182680 Commit-Queue: Sigmund Cherem <sigmund@google.com> Reviewed-by: Joshua Litt <joshualitt@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com> Reviewed-by: Stephen Adams <sra@google.com>
73 lines
1.4 KiB
Dart
73 lines
1.4 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
_field4() => 4;
|
|
|
|
class Class1 {
|
|
var field1 = 0;
|
|
|
|
@pragma('dart2js:noElision')
|
|
var field2 = 1;
|
|
|
|
var field3 = 2;
|
|
|
|
var field4 = _field4;
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
method1(Class1 c) {
|
|
return c.field1;
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
method2(Class1 c) {
|
|
return c.field2;
|
|
}
|
|
|
|
class Class2 {
|
|
var field3 = 3;
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
method3(c) {
|
|
return c.field3;
|
|
}
|
|
|
|
class Class3 extends Class1 {
|
|
@pragma('dart2js:noInline')
|
|
method4() {
|
|
return super.field1;
|
|
}
|
|
}
|
|
|
|
class Class4 extends Class1 {
|
|
@pragma('dart2js:noInline')
|
|
method5() {
|
|
return super.field4();
|
|
}
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
method6(Class1? c) {
|
|
return c!.field1;
|
|
}
|
|
|
|
@pragma('dart2js:noInline')
|
|
method7(Class1 c) {
|
|
return c.field4();
|
|
}
|
|
|
|
main() {
|
|
Expect.equals(0, method1(new Class1()));
|
|
Expect.equals(1, method2(new Class1()));
|
|
Expect.equals(2, method3(new Class1()));
|
|
Expect.equals(3, method3(new Class2()));
|
|
Expect.equals(0, new Class3().method4());
|
|
Expect.equals(4, new Class4().method5());
|
|
Expect.equals(0, method6(new Class1()));
|
|
Expect.throws(() => method6(null));
|
|
Expect.equals(4, method7(new Class1()));
|
|
}
|