blob: ec46c285d2f9de170e0ffe6d68ee4862a654c2a3 [file] [log] [blame]
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:6:11: Error: This extension member conflicts with Object member 'noSuchMethod'.
// int get noSuchMethod => 42;
// ^^^^^^^^^^^^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:8:7: Error: This extension member conflicts with Object member 'runtimeType'.
// int runtimeType() => 0;
// ^^^^^^^^^^^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:9:12: Error: This extension member conflicts with Object member '=='.
// operator ==(other) => false;
// ^^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:10:17: Error: This extension member conflicts with Object member 'toString'.
// static String toString() => 'Foo';
// ^^^^^^^^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:7:12: Error: This extension member conflicts with Object member 'hashCode'.
// void set hashCode(int value) {}
// ^^^^^^^^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:27:14: Error: A value of type 'dynamic Function(Invocation)' can't be assigned to a variable of type 'int'.
// - 'Invocation' is from 'dart:core'.
// value = "".noSuchMethod;
// ^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:28:6: Error: The setter 'hashCode' isn't defined for the class 'String'.
// Try correcting the name to the name of an existing setter, or defining a setter or field named 'hashCode'.
// "".hashCode = 42;
// ^^^^^^^^
//
// pkg/front_end/testcases/extensions/conflict_with_object.dart:29:14: Error: A value of type 'Type' can't be assigned to a variable of type 'int'.
// - 'Type' is from 'dart:core'.
// value = "".runtimeType;
// ^
//
import self as self;
import "dart:core" as core;
extension Extension on core::String {
get noSuchMethod = self::Extension|get#noSuchMethod;
method runtimeType = self::Extension|runtimeType;
tearoff runtimeType = self::Extension|get#runtimeType;
operator == = self::Extension|==;
static method toString = self::Extension|toString;
set hashCode = self::Extension|set#hashCode;
}
static method Extension|get#noSuchMethod(lowered final core::String #this) → core::int
return 42;
static method Extension|set#hashCode(lowered final core::String #this, core::int value) → void {}
static method Extension|runtimeType(lowered final core::String #this) → core::int
return 0;
static method Extension|get#runtimeType(lowered final core::String #this) → () → core::int
return () core::int => self::Extension|runtimeType(#this);
static method Extension|==(lowered final core::String #this, dynamic other) → dynamic
return false;
static method Extension|toString() core::String
return "Foo";
static method main() dynamic {
core::int value;
self::expect(true, "".{core::Object::noSuchMethod}{(core::Invocation) dynamic} is{ForNonNullableByDefault} core::Function);
value = self::Extension|get#noSuchMethod("");
self::Extension|set#hashCode("", 42);
self::expect(true, "".{core::Object::runtimeType}{core::Type} is{ForNonNullableByDefault} core::Type);
self::expect(true, self::Extension|get#runtimeType("") is{ForNonNullableByDefault} core::Function);
value = self::Extension|runtimeType("");
self::expect(true, "" =={core::String::==}{(core::Object) core::bool} "");
self::expect("Foo", self::Extension|toString());
}
static method errors() dynamic {
core::int value;
value = invalid-expression "pkg/front_end/testcases/extensions/conflict_with_object.dart:27:14: Error: A value of type 'dynamic Function(Invocation)' can't be assigned to a variable of type 'int'.
- 'Invocation' is from 'dart:core'.
value = \"\".noSuchMethod;
^" in "".{core::Object::noSuchMethod}{(core::Invocation) dynamic} as{TypeError,ForNonNullableByDefault} core::int;
invalid-expression "pkg/front_end/testcases/extensions/conflict_with_object.dart:28:6: Error: The setter 'hashCode' isn't defined for the class 'String'.
Try correcting the name to the name of an existing setter, or defining a setter or field named 'hashCode'.
\"\".hashCode = 42;
^^^^^^^^" in ""{<unresolved>}.hashCode = 42;
value = invalid-expression "pkg/front_end/testcases/extensions/conflict_with_object.dart:29:14: Error: A value of type 'Type' can't be assigned to a variable of type 'int'.
- 'Type' is from 'dart:core'.
value = \"\".runtimeType;
^" in "".{core::Object::runtimeType}{core::Type} as{TypeError,ForNonNullableByDefault} core::int;
}
static method expect(dynamic expected, dynamic actual) dynamic {
if(!(expected =={core::Object::==}{(core::Object) core::bool} actual)) {
throw "Mismatch: expected=${expected}, actual=${actual}";
}
}