Fix findInterfaceMember when the receiver type is not an InterfaceType.

It is stil permissible to access methods/getters on Object (toString,
==, hashCode, etc.), even if the receiver type is not an
InterfaceType, and we want type inference and kernel annotations to
work correctly.

Change-Id: I311b43c6de31faeefa85bc70636af05c62c4c1fe
Reviewed-on: https://dart-review.googlesource.com/3385
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Paul Berry 2017-09-05 14:07:28 -07:00
parent 719e854ce4
commit 4bdad2194d
4 changed files with 59 additions and 58 deletions

View file

@ -341,16 +341,17 @@ abstract class TypeInferrerImpl extends TypeInferrer {
receiverType = resolveTypeParameter(receiverType);
if (receiverType is InterfaceType) {
var interfaceMember = classHierarchy
.getInterfaceMember(receiverType.classNode, name, setter: setter);
if (!silent && interfaceMember != null) {
instrumentation?.record(Uri.parse(uri), fileOffset, 'target',
new InstrumentationValueForMember(interfaceMember));
}
return interfaceMember;
Class classNode = receiverType is InterfaceType
? receiverType.classNode
: coreTypes.objectClass;
var interfaceMember =
classHierarchy.getInterfaceMember(classNode, name, setter: setter);
if (!silent && interfaceMember != null) {
instrumentation?.record(Uri.parse(uri), fileOffset, 'target',
new InstrumentationValueForMember(interfaceMember));
}
return null;
return interfaceMember;
}
/// Finds a member of [receiverType] called [name], and if it is found,

View file

@ -5,6 +5,6 @@ import "dart:core" as core;
static const field dynamic #errors = const <dynamic>["pkg/front_end/testcases/illegal_named_function_expression.dart:6:11: Error: A function expression can't have a return type.\n var x = void f<T>(T t) {};\n ^", "pkg/front_end/testcases/illegal_named_function_expression.dart:6:16: Error: A function expression can't have a name.\n var x = void f<T>(T t) {};\n ^", "pkg/front_end/testcases/illegal_named_function_expression.dart:8:9: Error: A function expression can't have a return type.\n print(void g<T>(T t) {});\n ^", "pkg/front_end/testcases/illegal_named_function_expression.dart:8:14: Error: A function expression can't have a name.\n print(void g<T>(T t) {});\n ^"]/* from null */;
static method main() → dynamic {
<T extends core::Object>(T) → core::Null x = let final <T extends core::Object>(T) → core::Null f = <T extends core::Object>(T t) → core::Null {} in f;
core::print(x.runtimeType);
core::print(x.{core::Object::runtimeType});
core::print(let final <T extends core::Object>(T) → core::Null g = <T extends core::Object>(T t) → core::Null {} in g);
}

View file

@ -179,30 +179,30 @@ class C extends self::B {
self::use(super.m = 42);
super.{self::A::n} = 42;
self::use(super.{self::A::n} = 42);
super.{self::A::a}.==(null) ? super.{self::A::a} = 42 : null;
self::use(let final dynamic #t36 = super.{self::A::a} in #t36.==(null) ? super.{self::A::a} = 42 : #t36);
super.{self::B::b}.==(null) ? super.{self::A::b} = 42 : null;
self::use(let final dynamic #t37 = super.{self::B::b} in #t37.==(null) ? super.{self::A::b} = 42 : #t37);
super.{self::A::c}.==(null) ? super.{self::B::c} = 42 : null;
self::use(let final dynamic #t38 = super.{self::A::c} in #t38.==(null) ? super.{self::B::c} = 42 : #t38);
super.{self::B::d}.==(null) ? super.{self::A::d} = 42 : null;
self::use(let final dynamic #t39 = super.{self::B::d} in #t39.==(null) ? super.{self::A::d} = 42 : #t39);
super.{self::A::e}.==(null) ? super.e = 42 : null;
self::use(let final dynamic #t40 = super.{self::A::e} in #t40.==(null) ? super.e = 42 : #t40);
super.{self::A::f}.==(null) ? super.f = 42 : null;
self::use(let final dynamic #t41 = super.{self::A::f} in #t41.==(null) ? super.f = 42 : #t41);
super.g.==(null) ? super.{self::A::g} = 42 : null;
self::use(let final dynamic #t42 = super.g in #t42.==(null) ? super.{self::A::g} = 42 : #t42);
super.{self::A::h}.==(null) ? super.{self::A::h} = 42 : null;
self::use(let final dynamic #t43 = super.{self::A::h} in #t43.==(null) ? super.{self::A::h} = 42 : #t43);
super.{self::A::i}.==(null) ? super.{self::B::i} = 42 : null;
self::use(let final dynamic #t44 = super.{self::A::i} in #t44.==(null) ? super.{self::B::i} = 42 : #t44);
let final dynamic #t45 = 87 in super.{self::A::[]}(#t45).==(null) ? let final dynamic #t46 = 42 in let final dynamic #t47 = super.{self::A::[]=}(#t45, #t46) in #t46 : null;
self::use(let final dynamic #t48 = 87 in let final dynamic #t49 = super.{self::A::[]}(#t48) in #t49.==(null) ? let final dynamic #t50 = 42 in let final dynamic #t51 = super.{self::A::[]=}(#t48, #t50) in #t50 : #t49);
super.{self::A::m}.==(null) ? super.m = 42 : null;
self::use(let final dynamic #t52 = super.{self::A::m} in #t52.==(null) ? super.m = 42 : #t52);
super.{self::A::n}.==(null) ? super.{self::A::n} = 42 : null;
self::use(let final dynamic #t53 = super.{self::A::n} in #t53.==(null) ? super.{self::A::n} = 42 : #t53);
super.{self::A::a}.{core::Object::==}(null) ? super.{self::A::a} = 42 : null;
self::use(let final dynamic #t36 = super.{self::A::a} in #t36.{core::Object::==}(null) ? super.{self::A::a} = 42 : #t36);
super.{self::B::b}.{core::Object::==}(null) ? super.{self::A::b} = 42 : null;
self::use(let final dynamic #t37 = super.{self::B::b} in #t37.{core::Object::==}(null) ? super.{self::A::b} = 42 : #t37);
super.{self::A::c}.{core::Object::==}(null) ? super.{self::B::c} = 42 : null;
self::use(let final dynamic #t38 = super.{self::A::c} in #t38.{core::Object::==}(null) ? super.{self::B::c} = 42 : #t38);
super.{self::B::d}.{core::Object::==}(null) ? super.{self::A::d} = 42 : null;
self::use(let final dynamic #t39 = super.{self::B::d} in #t39.{core::Object::==}(null) ? super.{self::A::d} = 42 : #t39);
super.{self::A::e}.{core::Object::==}(null) ? super.e = 42 : null;
self::use(let final dynamic #t40 = super.{self::A::e} in #t40.{core::Object::==}(null) ? super.e = 42 : #t40);
super.{self::A::f}.{core::Object::==}(null) ? super.f = 42 : null;
self::use(let final dynamic #t41 = super.{self::A::f} in #t41.{core::Object::==}(null) ? super.f = 42 : #t41);
super.g.{core::Object::==}(null) ? super.{self::A::g} = 42 : null;
self::use(let final dynamic #t42 = super.g in #t42.{core::Object::==}(null) ? super.{self::A::g} = 42 : #t42);
super.{self::A::h}.{core::Object::==}(null) ? super.{self::A::h} = 42 : null;
self::use(let final dynamic #t43 = super.{self::A::h} in #t43.{core::Object::==}(null) ? super.{self::A::h} = 42 : #t43);
super.{self::A::i}.{core::Object::==}(null) ? super.{self::B::i} = 42 : null;
self::use(let final dynamic #t44 = super.{self::A::i} in #t44.{core::Object::==}(null) ? super.{self::B::i} = 42 : #t44);
let final dynamic #t45 = 87 in super.{self::A::[]}(#t45).{core::Object::==}(null) ? let final dynamic #t46 = 42 in let final dynamic #t47 = super.{self::A::[]=}(#t45, #t46) in #t46 : null;
self::use(let final dynamic #t48 = 87 in let final dynamic #t49 = super.{self::A::[]}(#t48) in #t49.{core::Object::==}(null) ? let final dynamic #t50 = 42 in let final dynamic #t51 = super.{self::A::[]=}(#t48, #t50) in #t50 : #t49);
super.{self::A::m}.{core::Object::==}(null) ? super.m = 42 : null;
self::use(let final dynamic #t52 = super.{self::A::m} in #t52.{core::Object::==}(null) ? super.m = 42 : #t52);
super.{self::A::n}.{core::Object::==}(null) ? super.{self::A::n} = 42 : null;
self::use(let final dynamic #t53 = super.{self::A::n} in #t53.{core::Object::==}(null) ? super.{self::A::n} = 42 : #t53);
super.{self::A::a} = super.{self::A::a}.+(42);
self::use(super.{self::A::a} = super.{self::A::a}.+(42));
super.{self::A::b} = super.{self::B::b}.+(42);
@ -255,7 +255,7 @@ class C extends self::B {
}
static const field dynamic #errors = const <dynamic>["pkg/front_end/testcases/rasta/super.dart:43:5: Error: '+' is not a prefix operator. \n +super;\n ^", "pkg/front_end/testcases/rasta/super.dart:44:9: Error: '+' is not a prefix operator. \n use(+super);\n ^"]/* from null */;
static method use(dynamic x) → dynamic {
if(x.==(new core::DateTime::now().{core::DateTime::millisecondsSinceEpoch}))
if(x.{core::Object::==}(new core::DateTime::now().{core::DateTime::millisecondsSinceEpoch}))
throw "Shouldn't happen";
}
static method main() → dynamic {

View file

@ -165,28 +165,28 @@ class C extends self::B {
self::use(let final dynamic #t31 = 87 in let final dynamic #t32 = 42 in let final dynamic #t33 = super.{self::A::[]=}(#t31, #t32) in #t32);
super.m = 42;
self::use(super.m = 42);
super.{self::A::a}.==(null) ? super.{self::A::a} = 42 : null;
self::use(let final dynamic #t34 = super.{self::A::a} in #t34.==(null) ? super.{self::A::a} = 42 : #t34);
super.{self::B::b}.==(null) ? super.{self::A::b} = 42 : null;
self::use(let final dynamic #t35 = super.{self::B::b} in #t35.==(null) ? super.{self::A::b} = 42 : #t35);
super.{self::A::c}.==(null) ? super.{self::B::c} = 42 : null;
self::use(let final dynamic #t36 = super.{self::A::c} in #t36.==(null) ? super.{self::B::c} = 42 : #t36);
super.{self::B::d}.==(null) ? super.{self::A::d} = 42 : null;
self::use(let final dynamic #t37 = super.{self::B::d} in #t37.==(null) ? super.{self::A::d} = 42 : #t37);
super.{self::A::e}.==(null) ? super.e = 42 : null;
self::use(let final dynamic #t38 = super.{self::A::e} in #t38.==(null) ? super.e = 42 : #t38);
super.{self::A::f}.==(null) ? super.f = 42 : null;
self::use(let final dynamic #t39 = super.{self::A::f} in #t39.==(null) ? super.f = 42 : #t39);
super.g.==(null) ? super.{self::A::g} = 42 : null;
self::use(let final dynamic #t40 = super.g in #t40.==(null) ? super.{self::A::g} = 42 : #t40);
super.{self::A::h}.==(null) ? super.{self::A::h} = 42 : null;
self::use(let final dynamic #t41 = super.{self::A::h} in #t41.==(null) ? super.{self::A::h} = 42 : #t41);
super.{self::A::i}.==(null) ? super.{self::B::i} = 42 : null;
self::use(let final dynamic #t42 = super.{self::A::i} in #t42.==(null) ? super.{self::B::i} = 42 : #t42);
let final dynamic #t43 = 87 in super.{self::A::[]}(#t43).==(null) ? let final dynamic #t44 = 42 in let final dynamic #t45 = super.{self::A::[]=}(#t43, #t44) in #t44 : null;
self::use(let final dynamic #t46 = 87 in let final dynamic #t47 = super.{self::A::[]}(#t46) in #t47.==(null) ? let final dynamic #t48 = 42 in let final dynamic #t49 = super.{self::A::[]=}(#t46, #t48) in #t48 : #t47);
super.{self::A::m}.==(null) ? super.m = 42 : null;
self::use(let final dynamic #t50 = super.{self::A::m} in #t50.==(null) ? super.m = 42 : #t50);
super.{self::A::a}.{core::Object::==}(null) ? super.{self::A::a} = 42 : null;
self::use(let final dynamic #t34 = super.{self::A::a} in #t34.{core::Object::==}(null) ? super.{self::A::a} = 42 : #t34);
super.{self::B::b}.{core::Object::==}(null) ? super.{self::A::b} = 42 : null;
self::use(let final dynamic #t35 = super.{self::B::b} in #t35.{core::Object::==}(null) ? super.{self::A::b} = 42 : #t35);
super.{self::A::c}.{core::Object::==}(null) ? super.{self::B::c} = 42 : null;
self::use(let final dynamic #t36 = super.{self::A::c} in #t36.{core::Object::==}(null) ? super.{self::B::c} = 42 : #t36);
super.{self::B::d}.{core::Object::==}(null) ? super.{self::A::d} = 42 : null;
self::use(let final dynamic #t37 = super.{self::B::d} in #t37.{core::Object::==}(null) ? super.{self::A::d} = 42 : #t37);
super.{self::A::e}.{core::Object::==}(null) ? super.e = 42 : null;
self::use(let final dynamic #t38 = super.{self::A::e} in #t38.{core::Object::==}(null) ? super.e = 42 : #t38);
super.{self::A::f}.{core::Object::==}(null) ? super.f = 42 : null;
self::use(let final dynamic #t39 = super.{self::A::f} in #t39.{core::Object::==}(null) ? super.f = 42 : #t39);
super.g.{core::Object::==}(null) ? super.{self::A::g} = 42 : null;
self::use(let final dynamic #t40 = super.g in #t40.{core::Object::==}(null) ? super.{self::A::g} = 42 : #t40);
super.{self::A::h}.{core::Object::==}(null) ? super.{self::A::h} = 42 : null;
self::use(let final dynamic #t41 = super.{self::A::h} in #t41.{core::Object::==}(null) ? super.{self::A::h} = 42 : #t41);
super.{self::A::i}.{core::Object::==}(null) ? super.{self::B::i} = 42 : null;
self::use(let final dynamic #t42 = super.{self::A::i} in #t42.{core::Object::==}(null) ? super.{self::B::i} = 42 : #t42);
let final dynamic #t43 = 87 in super.{self::A::[]}(#t43).{core::Object::==}(null) ? let final dynamic #t44 = 42 in let final dynamic #t45 = super.{self::A::[]=}(#t43, #t44) in #t44 : null;
self::use(let final dynamic #t46 = 87 in let final dynamic #t47 = super.{self::A::[]}(#t46) in #t47.{core::Object::==}(null) ? let final dynamic #t48 = 42 in let final dynamic #t49 = super.{self::A::[]=}(#t46, #t48) in #t48 : #t47);
super.{self::A::m}.{core::Object::==}(null) ? super.m = 42 : null;
self::use(let final dynamic #t50 = super.{self::A::m} in #t50.{core::Object::==}(null) ? super.m = 42 : #t50);
super.{self::A::a} = super.{self::A::a}.+(42);
self::use(super.{self::A::a} = super.{self::A::a}.+(42));
super.{self::A::b} = super.{self::B::b}.+(42);
@ -234,7 +234,7 @@ class C extends self::B {
}
}
static method use(dynamic x) → dynamic {
if(x.==(new core::DateTime::now().{core::DateTime::millisecondsSinceEpoch}))
if(x.{core::Object::==}(new core::DateTime::now().{core::DateTime::millisecondsSinceEpoch}))
throw "Shouldn't happen";
}
static method main() → dynamic {