Skip to content

Fix throwing on asMemberOf on Intersection Override functions - #3077

Open
vadymsavchenko-lyft wants to merge 1 commit into
google:mainfrom
vadymsavchenko-lyft:vsavchenko/fix-throwing-on-intersection-override
Open

Fix throwing on asMemberOf on Intersection Override functions#3077
vadymsavchenko-lyft wants to merge 1 commit into
google:mainfrom
vadymsavchenko-lyft:vsavchenko/fix-throwing-on-intersection-override

Conversation

@vadymsavchenko-lyft

Copy link
Copy Markdown

Fix asMemberOf throwing on intersection-override members

When an interface inherits the same member from two supertypes nested in different classes, KSP2 attributed that member to the receiver's enclosing class instead of the real super-interface.
asMemberOf's subtype check then failed and threw.

  class A { interface M { fun f(): String } }
  class B { interface M { fun f(): String } }
  class Box {
      interface Both : A.M, B.M   // intersection override of f()
  }
  // resolver.asMemberOf(Both.f, Both)  ->  used to throw IllegalArgumentException

Fix: resolve the declaring class via intersectionOverriddenSymbols/fakeOverrideOriginal before the subtype check. Adds a regression case to asMemberOf golden tests.

@google-cla

google-cla Bot commented Jul 24, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@jaschdoc

jaschdoc commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Hi @vadymsavchenko-lyft, thank you for the PR! Please ping me when you have signed the CLA. Also, please split this PR in two, one with the test (in a new test file and processor) and one with a fix. See https://github.com/google/ksp/blob/main/CONTRIBUTING.md for more information. I couldn't find an issue for this, so unless there already is an existing one, please also open a new issue describing the bug. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants