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

Check The Robert Issue #9417

Closed
Simn opened this issue May 14, 2020 · 5 comments
Closed

Check The Robert Issue #9417

Simn opened this issue May 14, 2020 · 5 comments
Assignees

Comments

@Simn
Copy link
Member

Simn commented May 14, 2020

So I don't forget: There's a potential problem with access on something that tries really hard to not look like Dynamic picking up non-Dynamic static extensions.

@Simn Simn self-assigned this May 14, 2020
@nadako
Copy link
Member

nadako commented May 14, 2020

using Main.Ext;

abstract D(Dynamic) to Dynamic {}

class Ext {
	public static function round(f:Float) {}
}

class Main {
	static function main() {
		var d:D = null;
		d.round();
	}
}

@nadako
Copy link
Member

nadako commented May 14, 2020

(replacing to Dynamic with a @:to Dynamic method will prevent this BTW)

@Simn
Copy link
Member Author

Simn commented May 15, 2020

That makes it a variant of #5924 and the question Kevin asked in the last comment there becomes relevant.

Now I'm somewhat worried about breaking this (for to Dynamic in particular), but it's hard to tell if anyone intentionally relied on this behavior.

@RealyUniqueName RealyUniqueName added this to the Backlog milestone May 15, 2020
@Simn Simn closed this as completed in 6bd67f8 May 16, 2020
@vonagam
Copy link
Member

vonagam commented Jul 5, 2020

This change forbid not only dynamic to anything, but other types of implicit casts one might consider non-dangerous.

Examples (connected to #9652):

using Lambda;
using Main.ParentTools;

abstract Foo<T>(T) from T to T {}

class Parent { public function new() {} }

class Child extends Parent {}

class ParentTools { public static function tool(that: Parent) {} }

class Main {
  public static function main() {
    var parentFoo: Foo<Parent> = new Parent();
    parentFoo.tool();

    var childFoo: Foo<Child> = new Child();
    childFoo.tool(); // error

    var arrayFoo: Foo<Array<Int>> = new Array<Int>();
    arrayFoo.count(); // error
  }
}

So now to Array<Int> isn't enough for Lambda extensions to be picked up, and to Child is not enough for ParentTools (and in the example Foo can't work around this, as he doesn't know anything about T).

Question: is this intended result of the change or just an unplanned consequence?

@RealyUniqueName
Copy link
Member

@Simn ?

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 a pull request may close this issue.

4 participants