blob: fdbcb96f1a648010ece040e1a530a88a7ac69640 [file] [log] [blame]
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/value_class/super_type.dart:19:22: Error: No named parameter with the name 'numberOfLegs'.
// Cat firstCat = Cat(numberOfLegs: 4, numberOfWhiskers: 10);
// ^^^^^^^^^^^^
// pkg/front_end/testcases/value_class/super_type.dart:13:7: Context: The class 'Cat' has a constructor that takes no arguments.
// class Cat implements Animal {
// ^
//
// pkg/front_end/testcases/value_class/super_type.dart:20:23: Error: No named parameter with the name 'numberOfLegs'.
// Cat secondCat = Cat(numberOfLegs: 4, numberOfWhiskers: 10);
// ^^^^^^^^^^^^
// pkg/front_end/testcases/value_class/super_type.dart:13:7: Context: The class 'Cat' has a constructor that takes no arguments.
// class Cat implements Animal {
// ^
//
// pkg/front_end/testcases/value_class/super_type.dart:21:22: Error: No named parameter with the name 'numberOfLegs'.
// Cat thirdCat = Cat(numberOfLegs: 4, numberOfWhiskers: 0);
// ^^^^^^^^^^^^
// pkg/front_end/testcases/value_class/super_type.dart:13:7: Context: The class 'Cat' has a constructor that takes no arguments.
// class Cat implements Animal {
// ^
//
// pkg/front_end/testcases/value_class/super_type.dart:9:13: Error: Final field 'numberOfLegs' is not initialized.
// Try to initialize the field in the declaration or in every constructor.
// final int numberOfLegs;
// ^^^^^^^^^^^^
//
// pkg/front_end/testcases/value_class/super_type.dart:14:13: Error: Final field 'numberOfLegs' is not initialized.
// Try to initialize the field in the declaration or in every constructor.
// final int numberOfLegs;
// ^^^^^^^^^^^^
//
// pkg/front_end/testcases/value_class/super_type.dart:15:13: Error: Final field 'numberOfWhiskers' is not initialized.
// Try to initialize the field in the declaration or in every constructor.
// final int numberOfWhiskers;
// ^^^^^^^^^^^^^^^^
//
import self as self;
import "dart:core" as core;
class Animal extends core::Object {
final field core::int numberOfLegs = null;
synthetic constructor •({required core::int numberOfLegs}) self::Animal
: self::Animal::numberOfLegs = numberOfLegs, super core::Object::•()
;
}
class Cat extends core::Object implements self::Animal {
final field core::int numberOfLegs = null;
final field core::int numberOfWhiskers = null;
synthetic constructor •({required core::int numberOfLegs, required core::int numberOfWhiskers}) self::Cat
: self::Cat::numberOfLegs = numberOfLegs, self::Cat::numberOfWhiskers = numberOfWhiskers, super core::Object::•()
;
}
static const field core::String valueClass = #C1;
static method main() dynamic {
self::Cat firstCat = invalid-expression "pkg/front_end/testcases/value_class/super_type.dart:19:22: Error: No named parameter with the name 'numberOfLegs'.
Cat firstCat = Cat(numberOfLegs: 4, numberOfWhiskers: 10);
^^^^^^^^^^^^";
self::Cat secondCat = invalid-expression "pkg/front_end/testcases/value_class/super_type.dart:20:23: Error: No named parameter with the name 'numberOfLegs'.
Cat secondCat = Cat(numberOfLegs: 4, numberOfWhiskers: 10);
^^^^^^^^^^^^";
self::Cat thirdCat = invalid-expression "pkg/front_end/testcases/value_class/super_type.dart:21:22: Error: No named parameter with the name 'numberOfLegs'.
Cat thirdCat = Cat(numberOfLegs: 4, numberOfWhiskers: 0);
^^^^^^^^^^^^";
self::expect(true, firstCat.{core::Object::==}(secondCat));
self::expect(false, firstCat.{core::Object::==}(thirdCat));
self::expect(true, firstCat.{core::Object::hashCode}.{core::num::==}(secondCat.{core::Object::hashCode}));
self::expect(false, firstCat.{core::Object::hashCode}.{core::num::==}(thirdCat.{core::Object::hashCode}));
}
static method expect(dynamic expected, dynamic actual, [dynamic expectNull = #C2]) → dynamic {
if(expectNull as{TypeError,ForDynamic,ForNonNullableByDefault} core::bool) {
expected = null;
}
if(!expected.{core::Object::==}(actual)) {
throw "Mismatch: expected=${expected}, actual=${actual}";
}
}
constants {
#C1 = "valueClass"
#C2 = false
}