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

KE2: Start working on KtTypes #18031

Open
wants to merge 2 commits into
base: ke2
Choose a base branch
from
Open

KE2: Start working on KtTypes #18031

wants to merge 2 commits into from

Conversation

igfoo
Copy link
Contributor

@igfoo igfoo commented Nov 19, 2024

This adds the beginning of KtType extraction.

The main change is in the dbscheme relations, which now look like:

/**
 * `id` is the Kotlin type for the non-nullable class type `classid`.
 */
kt_class_types(
  unique int id: @kt_class_type,
  int classid: @reftype ref
)

/**
 * `id` is the Kotlin type that is the same as `kttypeid`, but is nullable.
 */
kt_nullable_types(
  unique int id: @kt_nullable_type,
  int kttypeid: @kt_type ref
)

/**
 * `id` is the Kotlin type that is the alias called `name` of `kttypeid`.
 * That is, it has been defined by `typealias name = kttypeid`.
 */
kt_type_alias(
  unique int id: @kt_type_alias,
  string name: string ref,
  int kttypeid: @kt_type ref
)

and useType now produces these.

This broke the KE1 build, which for now I've just fixed with TODO() calls; I think it makes sense to fix this properly later, once we are confident that this is the right way to go.

fakeKotlinType is now gone; we should make proper Kotlin types in cases where we used to use it.

val classId = addClassLabel(c.symbol as KaClassSymbol)
val javaResult = TypeResult(classId /* , TODO, TODO */)
val kotlinTypeId =
tw.getLabelFor<DbKt_class_type>("@\"kt_class{$classId}\"") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: We typically have a ; separator between parts of the label. So I think this should be "@\"kt_class;{$classId}\""

val kotlinResult = TypeResult(fakeKotlinType() /* , "TODO", "TODO" */)
val classId = addClassLabel(c.symbol as KaClassSymbol)
val javaResult = TypeResult(classId /* , TODO, TODO */)
val kotlinTypeId =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct? Shouldn't we check the nullability of the KaClassType?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the nullability belongs in useType, but it looks like that I got so focused on working out what the dbscheme tables should look like that I didn't add it. I'll add a commit for that.

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

Successfully merging this pull request may close these issues.

2 participants