Skip to content

Changed how class types are searched#14

Merged
Pichers merged 2 commits intomainfrom
cantFindMethodFix
Apr 22, 2025
Merged

Changed how class types are searched#14
Pichers merged 2 commits intomainfrom
cantFindMethodFix

Conversation

@Pichers
Copy link
Collaborator

@Pichers Pichers commented Apr 22, 2025

Description

Changed how class types are searched in the ClassLevelMaps to be coherent with how they are registered.

Example

A Class type would be added by the method VisitCtClass(...) in LatteClassFirstPass as "LinkedList",
but would be searched for by the method visitCtInvocation(...) in LatteTypeChecker as "LinkedList<String>" (for example), leading to a miss.
Was fixed by using .getTypeErasure() on visitCtInvocation(...), simplifying to "LinkedList" in every case

Related Issue

Closes #6

Type of change

  • Bug fix
  • New feature
  • Documentation update
  • Code refactoring

How Has This Been Tested?

App.java was run and the previously known bug was found.
Adding other instances of the same class but with different Types did not affect the correctness of the output.

@Pichers
Copy link
Collaborator Author

Pichers commented Apr 22, 2025

Personally, I couldn't find the adequate method call to fix this bug the other way around, as the already used method seems like it should work.

@alcides
Copy link
Collaborator

alcides commented Apr 22, 2025

My ¥0.02: This solution should fix the problem (for Latte). Generics in Java are optional, so they do not have a real identity.

For Latte this is fine. For LJ this is more troublesome: you might want to specify LinkedList<@refined(“x>0”) Integer>. But I am afraid the syntax won’t work, and it will be inconsistent with the usage of raw types.

@CatarinaGamboa
Copy link
Collaborator

Yeah, I agree, this fixes the problem for now, so we can merge it 🚀
But we should keep this in mind if, later on the road, we need to change it to support those types. Having LinkedList<@refined(“x>0”) Integer> would definitely be interesting in Latte and LiquidJava! But I don't think it is a priority now, so I'll make an issue, and we can think about it later

Copy link
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

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

You can squash and merge @Pichers 🚀

@Pichers Pichers merged commit 99613a7 into main Apr 22, 2025
1 check passed
@Pichers Pichers deleted the cantFindMethodFix branch May 21, 2025 10:14
@Pichers Pichers changed the title Changed how class types are registered Changed how class types are searched for Jun 15, 2025
@Pichers Pichers changed the title Changed how class types are searched for Changed how class types are registered Jun 15, 2025
@Pichers Pichers changed the title Changed how class types are registered Changed how class types are searched Jun 15, 2025
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.

Cannot find method

3 participants