blob: e88f4fa414b44886787d281299eb7030bbedccde [file] [log] [blame]
library;
//
// Problems in library:
//
// pkg/front_end/testcases/extension_types/issue52119.dart:15:30: Error: Expected a representation type.
// extension type Bar<T>._(this.i) {
// ^
//
// pkg/front_end/testcases/extension_types/issue52119.dart:15:30: Error: Primary constructors in extension types can't use initializing formals.
// Try removing `this.` from the formal parameter.
// extension type Bar<T>._(this.i) {
// ^
//
// pkg/front_end/testcases/extension_types/issue52119.dart:12:26: Error: Couldn't find constructor 'Foo.unresolved'.
// Foo.erroneous() : this.unresolved(); // Error
// ^^^^^^^^^^
//
// pkg/front_end/testcases/extension_types/issue52119.dart:12:3: Error: Final field 'i' is not initialized by this constructor.
// Try to initialize the field using an initializing formal or a field initializer.
// Foo.erroneous() : this.unresolved(); // Error
// ^^^^^^^^^
// pkg/front_end/testcases/extension_types/issue52119.dart:5:26: Context: 'i' is defined here.
// extension type Foo._(int i) {
// ^
//
import self as self;
import "dart:core" as core;
extension type Foo(core::int i) {
abstract extension-type-member representation-field get i() core::int;
constructor _ = self::Foo|constructor#_;
constructor tearoff _ = self::Foo|constructor#_#_#tearOff;
constructor = self::Foo|constructor#;
constructor tearoff = self::Foo|constructor#_#new#tearOff;
constructor redirectNamed1 = self::Foo|constructor#redirectNamed1;
constructor tearoff redirectNamed1 = self::Foo|constructor#_#redirectNamed1#tearOff;
constructor redirectNamed2 = self::Foo|constructor#redirectNamed2;
constructor tearoff redirectNamed2 = self::Foo|constructor#_#redirectNamed2#tearOff;
constructor named = self::Foo|constructor#named;
constructor tearoff named = self::Foo|constructor#_#named#tearOff;
constructor erroneous = self::Foo|constructor#erroneous;
constructor tearoff erroneous = self::Foo|constructor#_#erroneous#tearOff;
}
extension type Bar<T extends core::Object? = dynamic>(invalid-type i) {
abstract extension-type-member representation-field get i() invalid-type;
constructor _ = self::Bar|constructor#_;
constructor tearoff _ = self::Bar|constructor#_#_#tearOff;
constructor = self::Bar|constructor#;
constructor tearoff = self::Bar|constructor#_#new#tearOff;
}
static extension-type-member method Foo|constructor#_(core::int i) → self::Foo% /* erasure=core::int, declared=! */ {
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = i;
return #this;
}
static extension-type-member method Foo|constructor#_#_#tearOff(core::int i) → self::Foo% /* erasure=core::int, declared=! */
return self::Foo|constructor#_(i);
static extension-type-member method Foo|constructor#(core::int i) → self::Foo% /* erasure=core::int, declared=! */ {
lowered final self::Foo% /* erasure=core::int, declared=! */ #this;
#this = self::Foo|constructor#_(i.{core::num::+}(2){(core::num) → core::int});
return #this;
}
static extension-type-member method Foo|constructor#_#new#tearOff(core::int i) → self::Foo% /* erasure=core::int, declared=! */
return self::Foo|constructor#(i);
static extension-type-member method Foo|constructor#redirectNamed1(core::int a, core::int b) → self::Foo% /* erasure=core::int, declared=! */ {
lowered final self::Foo% /* erasure=core::int, declared=! */ #this;
#this = self::Foo|constructor#named(a, subtract: b);
return #this;
}
static extension-type-member method Foo|constructor#_#redirectNamed1#tearOff(core::int a, core::int b) → self::Foo% /* erasure=core::int, declared=! */
return self::Foo|constructor#redirectNamed1(a, b);
static extension-type-member method Foo|constructor#redirectNamed2(core::int a, core::int b) → self::Foo% /* erasure=core::int, declared=! */ {
lowered final self::Foo% /* erasure=core::int, declared=! */ #this;
final core::int #t1 = b;
#this = self::Foo|constructor#named(a, subtract: #t1);
return #this;
}
static extension-type-member method Foo|constructor#_#redirectNamed2#tearOff(core::int a, core::int b) → self::Foo% /* erasure=core::int, declared=! */
return self::Foo|constructor#redirectNamed2(a, b);
static extension-type-member method Foo|constructor#named(core::int value, {required core::int subtract}) → self::Foo% /* erasure=core::int, declared=! */ {
lowered final self::Foo% /* erasure=core::int, declared=! */ #this = value.{core::num::-}(subtract){(core::num) → core::int};
return #this;
}
static extension-type-member method Foo|constructor#_#named#tearOff(core::int value, {required core::int subtract}) → self::Foo% /* erasure=core::int, declared=! */
return self::Foo|constructor#named(value, subtract: subtract);
static extension-type-member method Foo|constructor#erroneous() → self::Foo% /* erasure=core::int, declared=! */ {
lowered final self::Foo% /* erasure=core::int, declared=! */ #this;
final dynamic #t2 = invalid-expression "pkg/front_end/testcases/extension_types/issue52119.dart:12:26: Error: Couldn't find constructor 'Foo.unresolved'.
Foo.erroneous() : this.unresolved(); // Error
^^^^^^^^^^";
return #this;
}
static extension-type-member method Foo|constructor#_#erroneous#tearOff() → self::Foo% /* erasure=core::int, declared=! */
return self::Foo|constructor#erroneous();
static extension-type-member method Bar|constructor#_<T extends core::Object? = dynamic>(invalid-type i) → self::Bar<self::Bar|constructor#_::T%>% /* erasure=invalid-type, declared=! */ {
lowered final self::Bar<self::Bar|constructor#_::T%>% /* erasure=invalid-type, declared=! */ #this = i;
return #this;
}
static extension-type-member method Bar|constructor#_#_#tearOff<T extends core::Object? = dynamic>(invalid-type i) → self::Bar<self::Bar|constructor#_#_#tearOff::T%>% /* erasure=invalid-type, declared=! */
return self::Bar|constructor#_<self::Bar|constructor#_#_#tearOff::T%>(i);
static extension-type-member method Bar|constructor#<T extends core::Object? = dynamic>(self::Bar|constructor#::T% i) → self::Bar<self::Bar|constructor#::T%>% /* erasure=invalid-type, declared=! */ {
lowered final self::Bar<self::Bar|constructor#::T%>% /* erasure=invalid-type, declared=! */ #this;
#this = self::Bar|constructor#_<self::Bar|constructor#::T%>(i);
return #this;
}
static extension-type-member method Bar|constructor#_#new#tearOff<T extends core::Object? = dynamic>(self::Bar|constructor#_#new#tearOff::T% i) → self::Bar<self::Bar|constructor#_#new#tearOff::T%>% /* erasure=invalid-type, declared=! */
return self::Bar|constructor#<self::Bar|constructor#_#new#tearOff::T%>(i);
static method main() → dynamic {
self::expect(44, self::Foo|constructor#(42) as{Unchecked} core::int);
self::expect(42, self::Foo|constructor#_(42) as{Unchecked} core::int);
self::expect(3, self::Foo|constructor#redirectNamed1(5, 2) as{Unchecked} core::int);
self::expect(5, self::Foo|constructor#redirectNamed2(7, 2) as{Unchecked} core::int);
self::expect(5, self::Bar|constructor#<core::int>(5) as{Unchecked} invalid-type);
self::expect("foo", self::Bar|constructor#<core::String>("foo") as{Unchecked} invalid-type);
self::expect(5, self::Bar|constructor#_<dynamic>(5) as{Unchecked} invalid-type);
self::expect("foo", self::Bar|constructor#_<dynamic>("foo") as{Unchecked} invalid-type);
}
static method expect(dynamic expected, dynamic actual) → dynamic {
if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual))
throw "Expected ${expected}, actual ${actual}";
}