Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modifier for "fun interface" #393

Closed
elihart opened this issue Apr 19, 2021 · 0 comments · Fixed by #406
Closed

Add modifier for "fun interface" #393

elihart opened this issue Apr 19, 2021 · 0 comments · Fixed by #406
Labels
api API changes may be involved P1 major features or blocking bugs
Milestone

Comments

@elihart
Copy link

elihart commented Apr 19, 2021

Support the language feature "function SAM interfaces" - https://kotlinlang.org/docs/fun-interfaces.html

As far as I can tell com.google.devtools.ksp.symbol.Modifier doesn't have an entry for this and there is currently no way to check this on an KSClassDeclaration.

It seems like this would be fairly straightforward to do?

  1. Add fun entry to Modifier enum
  2. Update KSClassDeclarationDescriptorImpl.modifiers to check ClassDescriptor.isFun
  3. Update utils.kt modifierMap
@ting-yuan ting-yuan added api API changes may be involved P1 major features or blocking bugs labels Apr 19, 2021
@ting-yuan ting-yuan added this to the 1.0.0-beta milestone Apr 19, 2021
copybara-service bot pushed a commit to androidx/androidx that referenced this issue May 18, 2021
## Proposed Changes
Adds an interface function to get element kdoc. Implements this for javac, and uses null for KSP until google/ksp#392 is fixed

Also surfaces more XTypeElement information, such as whether the type is a data class, a fun interface, a companion object, etc.

I implemented everything exposed in kotlin class metadata that seemed reasonable in order to future proof it a bit.

I was not able to implement fun interface checking for KSP since it is not yet surfaced in KSP - google/ksp#393

## Testing

Test: Added cases to XTypeElementTest.modifiers

Note, I wasn't able to test the `expect` modifier. First I had to add support for custom compiler arguments so I could enable multiplatform via `"-Xmulti-platform"` but to get the test sources to compile I had to include a `actual` implementation as well, and since both the expected and actual implementations were in the same sources it seems the processor only picks up the actual. Omitting "actual" implementation doesn't work as compilation fails with "no actual implementation found in module", and I'm not sure how to have the compiler processing testing work with multiple module sources. The implementation of the "expect" modifier is very simple so I'm not sure how important the test is.

## Issues Fixed

Fixes: https://issuetracker.google.com/issues/185672887

This is an imported pull request from #164.

Resolves #164
Github-Pr-Head-Sha: 0bcd0af
GitOrigin-RevId: 04f408a
Change-Id: Ifcf6b7aac73643866034e4bb2e95df81ee997b72
copybara-service bot pushed a commit to androidx/androidx that referenced this issue May 21, 2021
Update XProcessing to take advantage of the new ORIGIN types:
google/ksp#375

Added support for doc comments in KSP
google/ksp#392

Added support for fun interfaces in KSP
google/ksp#393

Removed custom KCT workaround with the update to KCT 1.4.0

With this update we also get access to the containing class declaration
for compiled top level kotlin functions. That change is more complicated
so added a bug for that as a followup: b/188822146.

We also now have access to a type mapper between java and kotlin classes
but it is not working as we expect so will skip that update for now.
Specifically, it does not support primitives and it also maps java
classes to their immutable counterparts (e.g. java.util.List to
kotlin.collections.List instead of MutableList)

Last but not least, also updated incremental processing test to specify
room version explicitly instead of +. It becomes a problem in playground
where androidx.snapshot repository has a higher version value (SNAPSHOT)
then local publish task.

Bug: 160322705
Bug: 188822146
Test: room tests
Change-Id: I0bc03621bc0727fc94fba58c7c4e2cdbb254424d
olonho pushed a commit to JetBrains/compose-multiplatform-core that referenced this issue May 25, 2021
## Proposed Changes
Adds an interface function to get element kdoc. Implements this for javac, and uses null for KSP until google/ksp#392 is fixed

Also surfaces more XTypeElement information, such as whether the type is a data class, a fun interface, a companion object, etc.

I implemented everything exposed in kotlin class metadata that seemed reasonable in order to future proof it a bit.

I was not able to implement fun interface checking for KSP since it is not yet surfaced in KSP - google/ksp#393

## Testing

Test: Added cases to XTypeElementTest.modifiers

Note, I wasn't able to test the `expect` modifier. First I had to add support for custom compiler arguments so I could enable multiplatform via `"-Xmulti-platform"` but to get the test sources to compile I had to include a `actual` implementation as well, and since both the expected and actual implementations were in the same sources it seems the processor only picks up the actual. Omitting "actual" implementation doesn't work as compilation fails with "no actual implementation found in module", and I'm not sure how to have the compiler processing testing work with multiple module sources. The implementation of the "expect" modifier is very simple so I'm not sure how important the test is.

## Issues Fixed

Fixes: https://issuetracker.google.com/issues/185672887

This is an imported pull request from androidx#164.

Resolves #164
Github-Pr-Head-Sha: 0bcd0af
GitOrigin-RevId: 04f408a
Change-Id: Ifcf6b7aac73643866034e4bb2e95df81ee997b72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api API changes may be involved P1 major features or blocking bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants