Buggy code:
public final class AST { public static final int JLS2 = 2 ; static final int JLS2_INTERNAL = AST . JLS2 ; public static final int JLS3 = 3 ; private BindingResolver resolver = new BindingResolver ( ) ; private NodeEventHandler eventHandler = new NodeEventHandler ( ) ; int apiLevel ; private long modificationCount = 0 ; private long originalModificationCount = 0 ; private int disableEvents = 0 ; private final Object internalASTLock = new Object ( ) ; Scanner scanner ; InternalASTRewrite rewriter ; private int defaultNodeFlag = 0 ; private AST ( int level ) { } public AST ( ) { } public static CompilationUnit convertCompilationUnit ( int level , CompilationUnitDeclaration compilationUnitDeclaration , Map options , boolean isResolved , org . eclipse . jdt . internal . core . CompilationUnit workingCopy , int reconcileFlags , IProgressMonitor monitor ) { ASTConverter converter = new ASTConverter ( options , isResolved , monitor ) ; AST ast = AST . newAST ( level ) ; int savedDefaultNodeFlag = ast . getDefaultNodeFlag ( ) ; ast . setDefaultNodeFlag ( ASTNode . ORIGINAL ) ; BindingResolver resolver = null ; if ( isResolved ) { resolver = new DefaultBindingResolver ( compilationUnitDeclaration . scope , workingCopy . owner , new DefaultBindingResolver . BindingTables ( ) , false ) ; ast . setFlag ( AST . RESOLVED_BINDINGS ) ; } else { resolver = new BindingResolver ( ) ; } ast . setFlag ( reconcileFlags ) ; ast . setBindingResolver ( resolver ) ; converter . setAST ( ast ) ; CompilationUnit unit = converter . convert ( compilationUnitDeclaration , workingCopy . getContents ( ) ) ; unit . setLineEndTable ( compilationUnitDeclaration . compilationResult . getLineSeparatorPositions ( ) ) ; <START_BUG> unit . setTypeRoot ( workingCopy ) ; <END_BUG> ast . setDefaultNodeFlag ( savedDefaultNodeFlag ) ; return unit ; } public AST ( Map options ) { } public static AST newAST ( int level ) { } public long modificationCount ( ) { } public int apiLevel ( ) { } void modifying ( ) { } final void disableEvents ( ) { } final void reenableEvents ( ) { } void preRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void postRemoveChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void preReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { } void postReplaceChildEvent ( ASTNode node , ASTNode child , ASTNode newChild , StructuralPropertyDescriptor property ) { } void preAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void postAddChildEvent ( ASTNode node , ASTNode child , StructuralPropertyDescriptor property ) { } void preValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { } void postValueChangeEvent ( ASTNode node , SimplePropertyDescriptor property ) { } void preCloneNodeEvent ( ASTNode node ) { } void postCloneNodeEvent ( ASTNode node , ASTNode clone ) { } public static CompilationUnit parseCompilationUnit ( ICompilationUnit unit , boolean resolveBindings ) { } public static CompilationUnit parseCompilationUnit ( IClassFile classFile , boolean resolveBindings ) { } public static CompilationUnit parseCompilationUnit ( char [ ] source , String unitName , IJavaProject project ) { } public static CompilationUnit parseCompilationUnit ( char [ ] source ) { } BindingResolver getBindingResolver ( ) { } NodeEventHandler getEventHandler ( ) { } void setEventHandler ( NodeEventHandler eventHandler ) { } int getDefaultNodeFlag ( ) { } void setDefaultNodeFlag ( int flag ) { } void setOriginalModificationCount ( long count ) { } public ITypeBinding resolveWellKnownType ( String name ) { } void setBindingResolver ( BindingResolver resolver ) { } void unsupportedIn2 ( ) { } void supportedOnlyIn2 ( ) { } private static final Class [ ] AST_CLASS = new Class [ ] { AST . class } ; private final Object [ ] THIS_AST = new Object [ ] { this } ; static final int RESOLVED_BINDINGS = - 2147483648 ; private int bits ; public ASTNode createInstance ( Class nodeClass ) { } public ASTNode createInstance ( int nodeType ) { } public SimpleName newSimpleName ( String identifier ) { } public QualifiedName newQualifiedName ( Name qualifier , SimpleName name ) { } public Name newName ( String [ ] identifiers ) { } Name internalNewName ( String [ ] identifiers ) { } public Name newName ( String qualifiedName ) { } public SimpleType newSimpleType ( Name typeName ) { } public ArrayType newArrayType ( Type componentType ) { } public ArrayType newArrayType ( Type elementType , int dimensions ) { } public PrimitiveType newPrimitiveType ( PrimitiveType . Code typeCode ) { } public ParameterizedType newParameterizedType ( Type type ) { } public QualifiedType newQualifiedType ( Type qualifier , SimpleName name ) { } public WildcardType newWildcardType ( ) { } public CompilationUnit newCompilationUnit ( ) { } public PackageDeclaration newPackageDeclaration ( ) { } public ImportDeclaration newImportDeclaration ( ) { } public TypeDeclaration newTypeDeclaration ( ) { } public MethodDeclaration newMethodDeclaration ( ) { } public SingleVariableDeclaration newSingleVariableDeclaration ( ) { } public VariableDeclarationFragment newVariableDeclarationFragment ( ) { } public Initializer newInitializer ( ) { } public EnumConstantDeclaration newEnumConstantDeclaration ( ) { } public EnumDeclaration newEnumDeclaration ( ) { } public TypeParameter newTypeParameter ( ) { } public AnnotationTypeDeclaration newAnnotationTypeDeclaration ( ) { } public AnnotationTypeMemberDeclaration newAnnotationTypeMemberDeclaration ( ) { } public Modifier newModifier ( Modifier . ModifierKeyword keyword ) { } public List newModifiers ( int flags ) { } public BlockComment newBlockComment ( ) { } public LineComment newLineComment ( ) { } public Javadoc newJavadoc ( ) { } public TagElement newTagElement ( ) { } public TextElement newTextElement ( ) { } public MemberRef newMemberRef ( ) { } public MethodRef newMethodRef ( ) { } public MethodRefParameter newMethodRefParameter ( ) { } public VariableDeclarationStatement newVariableDeclarationStatement ( VariableDeclarationFragment fragment ) { } public TypeDeclarationStatement newTypeDeclarationStatement ( TypeDeclaration decl ) { } public TypeDeclarationStatement newTypeDeclarationStatement ( AbstractTypeDeclaration decl ) { } public Block newBlock ( ) { }

Fix:
unit . setTypeRoot ( workingCopy . originalFromClone ( ) ) ;