c191551fac
TEST=Covered by existing tests. Change-Id: Ied8be1874164e68e0a3a48e1b2f9a33310071381 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183009 Commit-Queue: Dmitry Stefantsov <dmitryas@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
92 lines
4.5 KiB
Plaintext
92 lines
4.5 KiB
Plaintext
library;
|
|
//
|
|
// 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() {}
|
|
// ^^^^^^^^^^^
|
|
//
|
|
// 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* {}
|
|
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} is core::Function*);
|
|
value = self::Extension|get#noSuchMethod("");
|
|
self::Extension|set#hashCode("", 42);
|
|
self::expect(true, "".{core::Object::runtimeType} is core::Type*);
|
|
self::expect(true, self::Extension|get#runtimeType("") is core::Function*);
|
|
value = self::Extension|runtimeType("");
|
|
self::expect(true, "".{core::String::==}(""));
|
|
self::expect("Foo", self::Extension|toString());
|
|
}
|
|
static method errors() → dynamic {
|
|
core::int* value;
|
|
value = let final Never* #t1 = 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} as{TypeError} 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;
|
|
^^^^^^^^";
|
|
value = let final Never* #t2 = 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} as{TypeError} core::int*;
|
|
}
|
|
static method expect(dynamic expected, dynamic actual) → dynamic {
|
|
if(!expected.{core::Object::==}(actual)) {
|
|
throw "Mismatch: expected=${expected}, actual=${actual}";
|
|
}
|
|
}
|