@@ -2924,19 +2924,24 @@ class Typer extends Namer
2924
2924
(using Context ): Tree =
2925
2925
2926
2926
def selectionProto = SelectionProto (tree.name, mbrProto, compat, privateOK)
2927
- // try an extension method in scope
2928
- try
2929
- val nestedCtx = ctx.fresh.setNewTyperState()
2927
+
2928
+ def tryExtension (using Context ): Tree =
2930
2929
findRef(tree.name, WildcardType , ExtensionMethod , EmptyFlags , qual.srcPos) match
2931
2930
case ref : TermRef =>
2932
- val app = extMethodApply(untpd.ref(ref).withSpan(tree.span), qual, pt)
2933
- if ! nestedCtx.reporter.hasErrors then
2934
- nestedCtx.typerState.commit()
2935
- return app
2936
- for err <- nestedCtx.reporter.allErrors.take(1 ) do
2937
- rememberSearchFailure(qual,
2938
- SearchFailure (app.withType(FailedExtension (app, selectionProto, err.msg))))
2931
+ extMethodApply(untpd.ref(ref).withSpan(tree.span), qual, pt)
2939
2932
case _ =>
2933
+ EmptyTree
2934
+
2935
+ // try an extension method in scope
2936
+ try
2937
+ val nestedCtx = ctx.fresh.setNewTyperState()
2938
+ val app = tryExtension(using nestedCtx)
2939
+ if ! app.isEmpty && ! nestedCtx.reporter.hasErrors then
2940
+ nestedCtx.typerState.commit()
2941
+ return app
2942
+ for err <- nestedCtx.reporter.allErrors.take(1 ) do
2943
+ rememberSearchFailure(qual,
2944
+ SearchFailure (app.withType(FailedExtension (app, selectionProto, err.msg))))
2940
2945
catch case ex : TypeError =>
2941
2946
rememberSearchFailure(qual,
2942
2947
SearchFailure (qual.withType(NestedFailure (ex.toMessage, selectionProto))))
0 commit comments