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

Compiler: Type checks not performed on super calls #770

Open
Adolio opened this issue Sep 20, 2024 · 4 comments
Open

Compiler: Type checks not performed on super calls #770

Adolio opened this issue Sep 20, 2024 · 4 comments

Comments

@Adolio
Copy link

Adolio commented Sep 20, 2024

Hi @joshtynjala,

I just noticed that the compiler is not performing type checks for super calls in constructors.

Having this would prevent runtime errors by detecting issues at compilation time.

The following code compiles fine but fails at runtime:

package
{
	public class SuperTypeCheckTest
	{
		public function SuperTypeCheckTest()
		{
			new B();
		}
	}
}

import flash.geom.Point;

class A
{
	public function A(point:Point)
	{

	}
}

class B extends A
{
	public function B()
	{
		super(42); // TypeError: Error #1034: Type Coercion failed: cannot convert 42 to flash.geom.Point.
	}
}

Best,
Aurélien

@Adolio Adolio changed the title Compiler: Calls to super doesn't perform type check Compiler: Type checks not performed on super calls Sep 20, 2024
@joshtynjala
Copy link
Member

I can reproduce this issue. Additionally, calls to other super method are also missing type checks.

override public function a(point:Point):void {
	super.a(42);
}

@joshtynjala
Copy link
Member

Interestingly, the ASC 2.0 compiler in the AIR SDK doesn't seem to perform type checks on super calls either. That's a bug that Harman should fix too. The Flex SDK compiler checks all super class properly, though.

@Adolio
Copy link
Author

Adolio commented Oct 10, 2024

Thanks, I just reported it here: airsdk/Adobe-Runtime-Support#3513

@joshtynjala
Copy link
Member

apache/royale-compiler@9ff701d
apache/royale-compiler@0f2660e

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

No branches or pull requests

2 participants