forked from HaxeFoundation/haxe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add missing recursion when checking abstract casts
closes HaxeFoundation#11676
- Loading branch information
Showing
4 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
class Main { | ||
static function main() { | ||
var comp = new AComponent([1, 2, 3]); | ||
trace(comp.doSomething()); | ||
} | ||
} | ||
|
||
interface Component<T> { | ||
function doSomething():T; | ||
} | ||
|
||
@:forward | ||
@:multiType | ||
abstract AComponent<T>(Component<T>) { | ||
public function new(value:T); | ||
|
||
@:to public static inline function toInt(t:Component<Int>, value:Int):IntComponent { | ||
return new IntComponent(value); | ||
} | ||
|
||
@:to public static inline function toIntArray(t:Component<Array<Int>>, value:Array<Int>):ArrayComponent<Int> { | ||
return new ArrayComponent(value); | ||
} | ||
} | ||
|
||
@:generic | ||
@:remove | ||
class ArrayComponent<T> implements Component<Array<T>> { | ||
final value:Array<T>; | ||
|
||
public function new(value:Array<T>) { | ||
this.value = value; | ||
var x = []; | ||
for (i in 0...value.length) { | ||
var y = new AComponent(this.value[i]).doSomething(); | ||
x.push(y); | ||
} | ||
} | ||
|
||
public function doSomething():Array<T> { | ||
return this.value; | ||
} | ||
} | ||
|
||
class IntComponent implements Component<Int> { | ||
final value:Int; | ||
|
||
public function new(value:Int) { | ||
this.value = value; | ||
} | ||
|
||
public function doSomething():Int { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-m Main | ||
--interp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Main.hx:4: [1,2,3] |