Guest User

Untitled

a guest
Jul 1st, 2013
354
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Just add -inline to the asc2 arguments to see this break.
  2. //
  3.  
  4. // A decompiler reveals the bug.
  5.  
  6. public static function getNameByKey(value:int):string{ var _local2 = value; while (_local2._key === (_local2 = StaticMember)) { return ("It works as expected"); }; return (("Broken: " + value)); }
  7.  
  8. package
  9. {
  10.     import flash.display.Sprite;
  11.     import flash.text.TextField;
  12.     import flash.text.TextFieldAutoSize;
  13.  
  14.     public final class Application extends Sprite
  15.     {
  16.         public function Application()
  17.         {
  18.             const textField: TextField = new TextField();
  19.             textField.autoSize = TextFieldAutoSize.LEFT;
  20.             textField.text = IssuedClass.StaticMember.toString();
  21.             addChild( textField );
  22.         }
  23.     }
  24. }
  25.  
  26. package
  27. {
  28.     public final class IssuedClass
  29.     {
  30.         public static const StaticMember: IssuedClass = new IssuedClass( 1 );
  31.  
  32.         public static function getNameByKey( value: int ): String
  33.         {
  34.             // There are at least 2 workarounds.
  35.  
  36.             // A Comment in the next line
  37.             // StaticMember.key;
  38.  
  39.             // B access private member StaticMember._key directly in case statement
  40.  
  41.             switch( value )
  42.             {
  43.                 case StaticMember.key:
  44.                     return 'It works as expected';
  45.             }
  46.  
  47.             return 'Broken: ' + value; // this should never happen! Most of weirdness: value is one!
  48.         }
  49.  
  50.         private var _key: int;
  51.  
  52.         public function IssuedClass( key: int )
  53.         {
  54.             _key = key;
  55.         }
  56.  
  57.         public function get key(): int
  58.         {
  59.             return _key;
  60.         }
  61.  
  62.         public function toString(): String
  63.         {
  64.             return '[IssuedClass key: ' + getNameByKey( _key ) + ']';
  65.         }
  66.     }
  67. }
RAW Paste Data