manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.43k stars 125 forks source link

Instanceof Not working with in general #382

Closed NextdoorPsycho closed 2 years ago

NextdoorPsycho commented 2 years ago

Describe the bug What im trying to do is create an instanced variable based on a functional check ie: if (e.getEntity() instanceof Player p ) {} As soon as I type the "p" it just locks up manfold and bricks my IDE while im on that page. While here, I noticed this: https://github.com/manifold-systems/manifold/issues/378 and feel its related

To Reproduce Steps to reproduce the behavior: In My case I was making a generic Instance check, @EventHandler public void on(EntityDamageEvent e) { if (e.getEntity() instanceof org.bukkit.entity.Player p && !e.getCause().equals(EntityDamageEvent.DamageCause.STARVATION) && hasAdaptation(p)) { addPotionStacks(p, PotionEffectType.HUNGER, 5 + getLevel(p), 100, true); addPotionStacks(p, PotionEffectType.INVISIBILITY, 1, 50 * getLevel(p), true); } } Obviously the use cases are different but I think this is a general non-structural issue (or im just slow and ignorant on the subject, just trying to be a good boi and report my problems)

Expected behavior Not lock the IDE when declaring an instanceof Variable

Desktop (please complete the following information):

Additional context Ill be watching this, let me know if you need anything from me, Here is the project as an example: https://github.com/VolmitSoftware/Adapt/blob/main/src/main/java/com/volmit/adapt/content/adaptation/hunter/HunterRegen.java That's AN instance not the only, all the instanced variables are like this Stack trace Please include a stack trace if applicable https://pastebin.com/0MueRuw1

gscaparrotti commented 2 years ago

I don't think that the issue is related to the one I experienced with istanceof, but rather with the Pattern Matching feature introduced with JEP 305.

I also experienced the same issue trying to use this feature and got the same error with the same stack trace.

The problem is not there when instanceof is used the classic way.

EDIT: I don't know for sure, but the problem may have started after updating IntelliJ to Build #IU-222.3739.54

NextdoorPsycho commented 2 years ago

I don't think that the issue is related to the one I experienced with istanceof, but rather with the Pattern Matching feature introduced with JEP 305.

I also experienced the same issue trying to use this feature and got the same error with the same stack trace.

The problem is not there when instanceof is used the classic way.

EDIT: I don't know for sure, but the problem may have started after updating IntelliJ to Build #IU-222.3739.54

I did not even think about that, yea same

rsmckinney commented 2 years ago

Fixed with IJ plugin release 2022.1.21 available from JetBrains Marketplace within 48 hours.