-
-
Notifications
You must be signed in to change notification settings - Fork 662
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow
@:using
with Class and Enum (#11553)
closes #10106
- Loading branch information
Showing
4 changed files
with
123 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
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,57 @@ | ||
package cases; | ||
|
||
class Issue10106 extends DisplayTestCase { | ||
/** | ||
class CExtension { | ||
public static function toS(c: C): String { | ||
return 'c'; | ||
} | ||
public static function fromS(cls: Class<C>, s: String):C { | ||
return new C(); | ||
} | ||
} | ||
@:using(cases.Issue10106.CExtension) | ||
class C { | ||
public function new(){} | ||
} | ||
class Main { | ||
static public function main() { | ||
C.{-1-} | ||
} | ||
} | ||
**/ | ||
function testClass() { | ||
eq(true, hasField(fields(pos(1)), "fromS", "(s : String) -> cases.C")); | ||
} | ||
|
||
/** | ||
class EnExtension { | ||
public static function toS(e:En):String { | ||
return '${e}'; | ||
} | ||
public static function fromS(en:Enum<En>, s:String):En { | ||
return A; | ||
} | ||
} | ||
@:using(cases.Issue10106.EnExtension) | ||
enum En { | ||
A; | ||
B; | ||
} | ||
class Main { | ||
static public function main() { | ||
En.{-1-} | ||
} | ||
} | ||
**/ | ||
function testEnum() { | ||
eq(true, hasField(fields(pos(1)), "fromS", "(s : String) -> cases.En")); | ||
} | ||
} |
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,35 @@ | ||
package unit.issues; | ||
|
||
private class CExtension { | ||
public static function fromS(cls:Class<C>, s:String) { | ||
return new C(s); | ||
} | ||
} | ||
|
||
@:using(unit.issues.Issue10106.CExtension) | ||
private class C { | ||
public final s:String; | ||
|
||
public function new(s:String) { | ||
this.s = s; | ||
} | ||
} | ||
|
||
private class EnExtension { | ||
public static function fromS(en:Enum<En>, st:String):En { | ||
return A; | ||
} | ||
} | ||
|
||
@:using(unit.issues.Issue10106.EnExtension) | ||
private enum En { | ||
A; | ||
B; | ||
} | ||
|
||
class Issue10106 extends Test { | ||
function test() { | ||
eq(A, En.fromS("A")); | ||
eq("foo", C.fromS("foo").s); | ||
} | ||
} |