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

isError for a non-existing type returns false #107

Closed
yigit opened this issue Oct 3, 2020 · 5 comments
Closed

isError for a non-existing type returns false #107

yigit opened this issue Oct 3, 2020 · 5 comments
Assignees
Labels
bug Something isn't working P1 major features or blocking bugs
Milestone

Comments

@yigit
Copy link
Collaborator

yigit commented Oct 3, 2020

Given the following java source:

                package foo.bar;
                public class Baz extends IDontExist {
                }

If I run:

resolver.requireClass("foo.bar.Baz").superTypes.first().resolve()?.isError

this returns false instead of true.
KSP version: 1.4.0-dev-experimental-20200914

@yigit
Copy link
Collaborator Author

yigit commented Oct 3, 2020

similarly, for the following input:

public class Baz {
                    NotExistingType badField;
}

the type of badField's isError also returns false.

@neetopia neetopia self-assigned this Oct 4, 2020
@neetopia neetopia added the bug Something isn't working label Oct 4, 2020
@neetopia
Copy link
Collaborator

neetopia commented Oct 4, 2020

#108 has a tentative fix to this.

@ting-yuan ting-yuan added this to the 2020Q4 milestone Oct 9, 2020
@ting-yuan ting-yuan added the P1 major features or blocking bugs label Oct 9, 2020
@neetopia neetopia closed this as completed Oct 9, 2020
@yigit
Copy link
Collaborator Author

yigit commented Dec 8, 2020

i'm not sure if this is fixed, I'm still seeing the same error with the 20201120 version but CL got in on Oct 9 so should've been fixed?

This is my test input:

package foo.bar;
public class Baz {
    NotExistingType badField;
}

the type of badField returns false from isError.

@neetopia neetopia reopened this Dec 8, 2020
@yigit
Copy link
Collaborator Author

yigit commented Dec 9, 2020

actually i think this is happening because i internally call asMemberOf when resolving fields and I can observe that calling asMemberOf from an error type loses the isError property.
Seems like it is a different bug after all though.

Should we change asMemberOf to bail out immediately if type is an error type?

copybara-service bot pushed a commit to androidx/androidx that referenced this issue Dec 12, 2020
This CL fixes two issues:
* isSameType in KSP was not working as Room expects for platform types.
We still want it to consider nullability for kotlin types but for types
coming from Java (or .class w/ nullability), we use flexible equality
the same way kotlin does.
We may eventually change how isSameType works as it is not always clear
whether it expects exact equality with nullability or without
nullability.

* We were losing error types by eagerly calling `asMemberOf` which loses
that information. google/ksp#107
To workaround it, we don't call asMemberOf if the type resolution
returns an error type.

I've also updated KspTypeTests to use the XProcessing classes to ensure
they go through the same expected path (which revelaed the asMemberOf
bug). They are still not running w/ KAPT because some things like
wildcard handling changes. I'll do that in a followup.

Bug: 160322705
Bug: 175246617
Test: XTypeTest, KspTypeTest
Change-Id: Ibd241456e4f402e5bc2b9002511ff59b7fab08e2
@ting-yuan ting-yuan modified the milestones: 2020Q4, 2021Q1 Jan 9, 2021
@ting-yuan ting-yuan modified the milestones: 1.0.0-beta, 1.0.0 Mar 22, 2021
@neetopia
Copy link
Collaborator

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