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

Error type does not show as error #371

Closed
yigit opened this issue Apr 1, 2021 · 4 comments
Closed

Error type does not show as error #371

yigit opened this issue Apr 1, 2021 · 4 comments
Assignees
Labels
bug Something isn't working P1 major features or blocking bugs
Milestone

Comments

@yigit
Copy link
Collaborator

yigit commented Apr 1, 2021

Hit this issue while converting a room test to also run with KSP.
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:room/compiler/src/test/kotlin/androidx/room/processor/PojoProcessorTest.kt;l=477?q=PojoProcessorTest

package foo.bar;
import androidx.room.*;
import java.util.*;
public class MyPojo {
  int id;
  @Relation(parentColumn = "id", entityColumn = "uid")
  public List<User> user;
}

When I resolve the type of user via asMemberOf (MyPojo) and then get the type argument type (from List), its isError check returns false instead of true.

When I debug, the ksType is (User..User?) and its declaration.descriptor is instance of NotFoundClasses$MockClassDescriptor but somehow KSP is missing it.

We probably need to expand this check:
https://github.com/google/ksp/blob/master/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/java/KSTypeReferenceJavaImpl.kt#L98

to always check the declaration?

I'll try to followup with a repro in KSP test infra.

@yigit
Copy link
Collaborator Author

yigit commented Apr 1, 2021

Also, this looks like very similar to:
#107 , might even be the same issue.

Appearantly, we did work around it in room.
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:room/compiler-processing/src/main/java/androidx/room/compiler/processing/ksp/KSAsMemberOf.kt;l=35?q=KSAsMemberOf

I might be able to expand that to also check type arguments but we should eventually fix this in KSP.

@yigit
Copy link
Collaborator Author

yigit commented Apr 1, 2021

oh actually, in this particular codepath, we may not be running through as Member of, i need to check in more detail.

copybara-service bot pushed a commit to androidx/androidx that referenced this issue Apr 3, 2021
This CL moves PojoProcessorTest to xprocessing.

There are two differences with JavaAP.
Error detection for primitives do not work in KSP since all
types in KSP have a type element (a.k.a. no primitives).
Technically, we could check if their typename is primitive
but they already fail for lack of constructor so I changed
their errors instead in the test.

Also, there is an existing bug in KSP where it loses KSType.isError
information in some cases. Changed the expected error for that test
for now.

google/ksp#371

Bug: 160322705
Test: PojoProcessorTest
Change-Id: I4a102bf9a6e5e749711783ac55955284d4d0b5fb
@ting-yuan ting-yuan added bug Something isn't working P1 major features or blocking bugs labels Apr 14, 2021
@ting-yuan ting-yuan added this to the 1.0.0 milestone Apr 14, 2021
@neetopia
Copy link
Contributor

neetopia commented Aug 28, 2021

can you give me more detail on this? I tried to call asMemberOf against a normal type on a typePair: Pair<BaseTypeArg2, NonExist> and it is returning isError=true for the second type argument in the return result of asMemberOf. Is my understanding of the issue here correctly?

@neetopia
Copy link
Contributor

neetopia commented Sep 3, 2021

fixed in #607

@neetopia neetopia closed this as completed Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 major features or blocking bugs
Projects
None yet
Development

No branches or pull requests

3 participants