Class loses properties after method call

Maybe it’ll make more sense if I show you. I reproduced it. Inspecting backAgain shows that the Identifier value is lost due to the casting.

https://graffitisuite.com/downloads/ms_24512.zip

1 Like

This seems wrong or I’m not getting it. Let me check. :stuck_out_tongue:

Your test project doesn’t seem to work.

Works perfectly on my side.
And is showing the issue.

Working here.

I get the following errors:

Window1.Opening, line 2
Type mismatch error.  Expected class OtherTestClass, but got class TestClass
var otherObj as OtherTestClass = obj

Window1.Opening, line 3
Type mismatch error.  Expected class TestClass, but got class OtherTestClass
var backAgain as TestClass = otherObj

Interesting. When building the project, that’s actually what I expected to run up against, but don’t in 2022r1.1 on macOS. What version of Xojo are you using?

2022r1.1 macOS Big Sur

Huh. I’m on Monterey, M1 Mini. Are you on Intel, maybe?

Either way, what you’re seeing is what I would consider the correct behavior, now just trying to narrow down why both Stefano and I don’t get compiler errors so I can open a Feedback Case for that.

I made changes. And my tests compiles and does wrongdoings in 2020r3.1 too.

But I wanted to make another test and change my base class to inherit from Object and it’s no allowing, it changes back to Rect !

Yeah. Need more data so I can open a case. Does it compile for you, Rick?

@StefanA Are you on Intel or ARM? What version of macOS?

Edit: Nevermind. I see you’re on Windows.

Yes, Windows.

Would this be an ARM build of Windows?

I’m on Monterey 12.4, Intel, Xojo 2022R1.1, and I see the bug, and the app compiles without any errors. (Edit: I compiled both for mac and for Windows)

I agree with others that this shouldn’t work - TestClass and OtherTestClass are not the same type, so you shouldn’t be able to assign one to the other.

1 Like

OK, so it looks like the difference isn’t Intel vs ARM, but possibly some condition where the compiler properly fails on an older version of macOS, but allows the operation on Windows and newer versions of macOS.

No ARM.
x86 64-bit

I’m using a 2019 16" Intel Macbook Pro.

1 Like

Intel 2018 Mini here - Mojave. Xojo 2020 r 1.1

Compiles OK with one warning about unused local variable. Shows the issue when run. Altering “app.Opening” so that the super.Constructor comes first makes no difference.

1 Like

If I change the supers of both classes from Rect to RectShape, or to REALBASIC.Rect, then I get the compile error. Changing back to Rect and it compiles (incorrectly).

Seems like something specifically funky with the Rect class?

2 Likes