get method
Resolves name the way the interpreter's readers do: bridged GETTER
first, then bound instance METHOD, then name / index on a wrapped
enum.
This is the order visitPropertyAccess, visitPrefixedIdentifier and
the cascade branch use for a bridged member. SCE232 made the primitive
agree with them. It used to be methods-only and threw for a getter.
The order can only matter for a name that is both a getter and a
method, and no bridge may declare one. scd196_member_map_disjointness_test.dart,
in both interpreter trees, fails on any name in two of a class's member
maps. That test is what made the change a no-op for every method name.
visitor is forwarded to the getter adapter, as set forwards it to the
setter. The adapter type allows null, and on 2026-09-29 none of the 824
stdlib getters or the 20 901 Flutter getters read it. Nothing in the
interpreter calls this method either (0 calls across the tom_d4rt suite
of 4 416 tests): it is a primitive for host code.
Implementation
@override
Object? get(String name, [InterpreterVisitor? visitor]) {
final getterAdapter = bridgedClass.findInstanceGetterAdapter(name);
if (getterAdapter != null) {
return getterAdapter(visitor, nativeObject);
}
final methodAdapter = bridgedClass.findInstanceMethodAdapter(name);
if (methodAdapter != null) {
return BridgedMethodCallable(this, methodAdapter, name);
}
// RC-7: a bridged getter can return a native enum value wrapped in a
// BridgedInstance (e.g. `paint.blendMode`), and `.name` / `.index` are then
// asked of the wrapper.
if (nativeObject is Enum) {
switch (name) {
case 'name':
return (nativeObject as Enum).name;
case 'index':
return (nativeObject as Enum).index;
}
}
throw UndefinedMemberD4rtException(
"Undefined property or method '$name' on bridged instance of '${bridgedClass.name}'",
memberName: name,
receiver: this,
);
}