21
21
import org .truffleruby .language .arguments .RubyArguments ;
22
22
import org .truffleruby .language .dispatch .DispatchConfiguration ;
23
23
import org .truffleruby .language .objects .MetaClassNode ;
24
- import org .truffleruby .utils .Utils ;
25
24
26
25
import com .oracle .truffle .api .CompilerAsserts ;
27
26
import com .oracle .truffle .api .TruffleLanguage ;
33
32
import com .oracle .truffle .api .frame .Frame ;
34
33
import com .oracle .truffle .api .frame .FrameInstance .FrameAccess ;
35
34
import com .oracle .truffle .api .frame .VirtualFrame ;
36
- import com .oracle .truffle .api .profiles .BranchProfile ;
37
35
import com .oracle .truffle .api .profiles .ConditionProfile ;
38
36
39
37
/** Caches {@link ModuleOperations#lookupMethodCached(RubyModule, String, DeclarationContext)} on an actual instance. */
@@ -85,7 +83,7 @@ protected InternalMethod lookupMethodUncached(
85
83
@ Cached MetaClassNode metaClassNode ,
86
84
@ Cached ConditionProfile noCallerMethodProfile ,
87
85
@ Cached ConditionProfile isSendProfile ,
88
- @ Cached BranchProfile foreignProfile ,
86
+ @ Cached ConditionProfile foreignProfile ,
89
87
@ Cached ConditionProfile noPrependedModulesProfile ,
90
88
@ Cached ConditionProfile onMetaClassProfile ,
91
89
@ Cached ConditionProfile hasRefinementsProfile ,
@@ -98,9 +96,8 @@ protected InternalMethod lookupMethodUncached(
98
96
99
97
// Actual lookup
100
98
101
- if (metaClass == context .getCoreLibrary ().truffleInteropForeignClass ) {
102
- foreignProfile .enter ();
103
- throw Utils .unsupportedOperation ("method lookup not supported on foreign objects" );
99
+ if (foreignProfile .profile (metaClass == context .getCoreLibrary ().truffleInteropForeignClass )) {
100
+ return null ;
104
101
}
105
102
106
103
final DeclarationContext declarationContext = RubyArguments .tryGetDeclarationContext (frame );
@@ -163,7 +160,7 @@ protected static MethodLookupResult lookupCached(RubyContext context, Frame call
163
160
CompilerAsserts .neverPartOfCompilation ("slow-path method lookup should not be compiled" );
164
161
165
162
if (metaClass == context .getCoreLibrary ().truffleInteropForeignClass ) {
166
- throw new UnsupportedOperationException ( "method lookup not supported on foreign objects" );
163
+ return new MethodLookupResult ( null );
167
164
}
168
165
169
166
final DeclarationContext declarationContext = RubyArguments .tryGetDeclarationContext (callingFrame );
0 commit comments