Guest User

ASC2 Inline Bug

a guest
Jul 1st, 2013
57
0
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. package
  4. {
  5.     import flash.display.Sprite;
  6.     import flash.text.TextField;
  7.     import flash.text.TextFieldAutoSize;
  8.  
  9.     public final class Application extends Sprite
  10.     {
  11.         public function Application()
  12.         {
  13.             const textField: TextField = new TextField();
  14.             textField.autoSize = TextFieldAutoSize.LEFT;
  15.             textField.text = IssuedClass.StaticMember.toString();
  16.             addChild( textField );
  17.         }
  18.     }
  19. }
  20.  
  21. package
  22. {
  23.     public final class IssuedClass
  24.     {
  25.         public static const StaticMember: IssuedClass = new IssuedClass( 1 );
  26.  
  27.         public static function getNameByKey( value: int ): String
  28.         {
  29.             // There are at least 2 workarounds.
  30.  
  31.             // A Comment in the next line
  32.             // StaticMember.key;
  33.  
  34.             // B access private member StaticMember._key directly in case statement
  35.  
  36.             switch( value )
  37.             {
  38.                 case StaticMember.key:
  39.                     return 'It works as expected';
  40.             }
  41.  
  42.             return 'Broken: ' + value; // this should never happen! Most of weirdness: value is one!
  43.         }
  44.  
  45.         private var _key: int;
  46.  
  47.         public function IssuedClass( key: int )
  48.         {
  49.             _key = key;
  50.         }
  51.  
  52.         public function get key(): int
  53.         {
  54.             return _key;
  55.         }
  56.  
  57.         public function toString(): String
  58.         {
  59.             return '[IssuedClass key: ' + getNameByKey( _key ) + ']';
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment