openrewrite / openrewrite/rewrite

Unable to detect type of chain method invocation

Open
#4,775 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
3.7k
Forks
571
Avg merge
13h 12m
Merged PRs (30d)
261

Description

What version of OpenRewrite are you using?

I am using

  • OpenRewrite v8.41.1

What is the smallest, simplest way to reproduce the problem?

For ObjectClassA.methodX().methodY()

  • methodX() return ObjectClassA
  • methodY() doesn't exist in ClassB

After changing ObjectClassA to ObjectClassB, OpenRewrite can't detect the methodType of methodY() (the pattern should be ClassB methodY()

I suppose the issue is related to line 462
image

Here the code snippet you may need in my case (from httpclient4 to httpclient5):

HttpClientBuilder.create()
        .setDefaultRequestConfig(config)
        .setSSLSocketFactory(sslSocketFactory)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the type-attribution logic around the referenced line 462 and reproduce the chained invocation using ObjectClassA/ObjectClassB and the HttpClientBuilder example. Trace why methodY() lacks a methodType after the receiver changes; done means the invocation is attributed as ClassB methodY().

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.