98a9adf696
Prior to this CL the return type of any constructor function was always void. According to the specification §9.3 the return type of a constructor function ought to be its enclosing class. Change-Id: I70d76cc354b7f118ce96bf4954daf7fe535eb7be Reviewed-on: https://dart-review.googlesource.com/76160 Commit-Queue: Daniel Hillerström <hillerstrom@google.com> Reviewed-by: Peter von der Ahé <ahe@google.com>
32 lines
832 B
Plaintext
32 lines
832 B
Plaintext
library;
|
|
import self as self;
|
|
import "dart:core" as core;
|
|
|
|
class A extends core::Object {
|
|
final field core::int x;
|
|
final field core::int y;
|
|
constructor •(core::int y) → self::A
|
|
: self::A::y = y, self::A::x = 42, super core::Object::•()
|
|
;
|
|
method method() → dynamic {
|
|
core::print("A.method x: ${this.{self::A::x}} y: ${this.{self::A::y}}");
|
|
core::print(this);
|
|
core::print(this.{core::Object::runtimeType});
|
|
}
|
|
}
|
|
class B extends self::A {
|
|
constructor •(dynamic x) → self::B
|
|
: super self::A::•(x)
|
|
;
|
|
method method() → dynamic {
|
|
core::print("B.method x: ${this.{self::A::x}} y: ${this.{self::A::y}}");
|
|
super.{self::A::method}();
|
|
}
|
|
}
|
|
static method main() → dynamic {
|
|
self::A a = new self::A::•(87);
|
|
self::B b = new self::B::•(117);
|
|
a.method();
|
|
b.method();
|
|
}
|