-
-
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.
[typer] do not apply abstract field casts on static extensions
closes #5924
- Loading branch information
Showing
10 changed files
with
115 additions
and
19 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
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,47 @@ | ||
package cases; | ||
|
||
class StaticExtension extends DisplayTestCase { | ||
/** | ||
using cases.StaticExtension.MyStaticExtension; | ||
class Something { | ||
static function test() { | ||
var map = ["a" => 1]; | ||
map.{-1-} | ||
} | ||
} | ||
class MyStaticExtension { | ||
static public function doSomething(sm:haxe.ds.StringMap<Int>):Void { } | ||
static public function doSomethingElse(sm:Map<String, Int>):Void { } | ||
} | ||
**/ | ||
function test1() { | ||
var fields = fields(pos(1)); | ||
eq(true, hasField(fields, "doSomething", "Void -> Void")); | ||
eq(true, hasField(fields, "doSomethingElse", "Void -> Void")); | ||
} | ||
|
||
/** | ||
using cases.StaticExtension.MyStaticExtension; | ||
class Something { | ||
static function test() { | ||
var map = new haxe.ds.StringMap(); | ||
map.{-1-} | ||
} | ||
} | ||
class MyStaticExtension { | ||
static public function doSomething(sm:haxe.ds.StringMap<Int>):Void { } | ||
static public function doSomethingElse(sm:Map<String, Int>):Void { } | ||
} | ||
**/ | ||
function test2() { | ||
var fields = fields(pos(1)); | ||
eq(true, hasField(fields, "doSomething", "Void -> Void")); | ||
eq(true, hasField(fields, "doSomethingElse", "Void -> Void")); | ||
} | ||
} |
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,21 @@ | ||
using Main; | ||
|
||
class Main { | ||
static function main() { | ||
0.bar(); | ||
} | ||
|
||
static function bar(f:Foo) | ||
f.bar(); | ||
} | ||
|
||
abstract Foo(String) { | ||
|
||
inline function new(v) this = v; | ||
|
||
@:from static function ofInt(i:Int) | ||
return new Foo('$i'); | ||
|
||
public function bar() {}; | ||
public function baz() {}; | ||
} |
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 @@ | ||
-main 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:5: characters 9-14 : Int has no field bar |
This file was deleted.
Oops, something went wrong.
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,24 @@ | ||
package unit.issues; | ||
|
||
using unit.issues.Issue7142; | ||
|
||
class Issue7142 extends unit.Test { | ||
function test() { | ||
var map = ["test" => 1]; | ||
var smap = new haxe.ds.StringMap(); | ||
smap.set("test", 1); | ||
|
||
eq(1, map.doSomething()); | ||
eq(1, smap.doSomething()); | ||
eq(1, map.doSomethingElse()); | ||
eq(1, smap.doSomethingElse()); | ||
} | ||
|
||
static function doSomething(sm:haxe.ds.StringMap<Int>) { | ||
return sm.get("test"); | ||
} | ||
|
||
static function doSomethingElse(sm:Map<String, Int>) { | ||
return sm.get("test"); | ||
} | ||
} |