< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java

Print this page




 550             returnType = prevRetType;
 551         }
 552     }
 553 
 554     public void visitSwitch(JCSwitch tree) {
 555         Type selsuper = types.supertype(tree.selector.type);
 556         boolean enumSwitch = selsuper != null &&
 557             selsuper.tsym == syms.enumSym;
 558         Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
 559         tree.selector = translate(tree.selector, target);
 560         tree.cases = translateCases(tree.cases);
 561         result = tree;
 562     }
 563 
 564     public void visitCase(JCCase tree) {
 565         tree.pats = translate(tree.pats, null);
 566         tree.stats = translate(tree.stats);
 567         result = tree;
 568     }
 569 







 570     public void visitSwitchExpression(JCSwitchExpression tree) {
 571         Type selsuper = types.supertype(tree.selector.type);
 572         boolean enumSwitch = selsuper != null &&
 573             selsuper.tsym == syms.enumSym;
 574         Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
 575         tree.selector = translate(tree.selector, target);
 576         tree.cases = translate(tree.cases);
 577         tree.type = erasure(tree.type);
 578         result = retype(tree, tree.type, pt);
 579     }
 580 
 581     public void visitSynchronized(JCSynchronized tree) {
 582         tree.lock = translate(tree.lock, erasure(tree.lock.type));
 583         tree.body = translate(tree.body);
 584         result = tree;
 585     }
 586 
 587     public void visitTry(JCTry tree) {
 588         tree.resources = translate(tree.resources, syms.autoCloseableType);
 589         tree.body = translate(tree.body);


 763                 ? (JCTypeCast) newExpression
 764                 : null;
 765             tree.expr = typeCast != null && types.isSameType(typeCast.type, originalTarget)
 766                 ? typeCast.expr
 767                 : newExpression;
 768         }
 769         if (originalTarget.isIntersection()) {
 770             Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget;
 771             for (Type c : ict.getExplicitComponents()) {
 772                 Type ec = erasure(c);
 773                 if (!types.isSameType(ec, tree.type)) {
 774                     tree.expr = coerce(tree.expr, ec);
 775                 }
 776             }
 777         }
 778         result = retype(tree, tree.type, pt);
 779     }
 780 
 781     public void visitTypeTest(JCInstanceOf tree) {
 782         tree.expr = translate(tree.expr, null);
 783         tree.clazz = translate(tree.clazz, null);
 784         result = tree;
 785     }
 786 
 787     public void visitIndexed(JCArrayAccess tree) {
 788         tree.indexed = translate(tree.indexed, erasure(tree.indexed.type));
 789         tree.index = translate(tree.index, syms.intType);
 790 
 791         // Insert casts of indexed expressions as needed.
 792         result = retype(tree, types.elemtype(tree.indexed.type), pt);
 793     }
 794 
 795     // There ought to be nothing to rewrite here;
 796     // we don't generate code.
 797     public void visitAnnotation(JCAnnotation tree) {
 798         result = tree;
 799     }
 800 
 801     public void visitIdent(JCIdent tree) {
 802         Type et = tree.sym.erasure(types);
 803 




 550             returnType = prevRetType;
 551         }
 552     }
 553 
 554     public void visitSwitch(JCSwitch tree) {
 555         Type selsuper = types.supertype(tree.selector.type);
 556         boolean enumSwitch = selsuper != null &&
 557             selsuper.tsym == syms.enumSym;
 558         Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
 559         tree.selector = translate(tree.selector, target);
 560         tree.cases = translateCases(tree.cases);
 561         result = tree;
 562     }
 563 
 564     public void visitCase(JCCase tree) {
 565         tree.pats = translate(tree.pats, null);
 566         tree.stats = translate(tree.stats);
 567         result = tree;
 568     }
 569 
 570     public void visitBindingPattern(JCBindingPattern tree) {
 571         if (tree.vartype != null) {
 572             tree.vartype = translate(tree.vartype, null);
 573         }
 574         result = tree;
 575     }
 576 
 577     public void visitSwitchExpression(JCSwitchExpression tree) {
 578         Type selsuper = types.supertype(tree.selector.type);
 579         boolean enumSwitch = selsuper != null &&
 580             selsuper.tsym == syms.enumSym;
 581         Type target = enumSwitch ? erasure(tree.selector.type) : syms.intType;
 582         tree.selector = translate(tree.selector, target);
 583         tree.cases = translate(tree.cases);
 584         tree.type = erasure(tree.type);
 585         result = retype(tree, tree.type, pt);
 586     }
 587 
 588     public void visitSynchronized(JCSynchronized tree) {
 589         tree.lock = translate(tree.lock, erasure(tree.lock.type));
 590         tree.body = translate(tree.body);
 591         result = tree;
 592     }
 593 
 594     public void visitTry(JCTry tree) {
 595         tree.resources = translate(tree.resources, syms.autoCloseableType);
 596         tree.body = translate(tree.body);


 770                 ? (JCTypeCast) newExpression
 771                 : null;
 772             tree.expr = typeCast != null && types.isSameType(typeCast.type, originalTarget)
 773                 ? typeCast.expr
 774                 : newExpression;
 775         }
 776         if (originalTarget.isIntersection()) {
 777             Type.IntersectionClassType ict = (Type.IntersectionClassType)originalTarget;
 778             for (Type c : ict.getExplicitComponents()) {
 779                 Type ec = erasure(c);
 780                 if (!types.isSameType(ec, tree.type)) {
 781                     tree.expr = coerce(tree.expr, ec);
 782                 }
 783             }
 784         }
 785         result = retype(tree, tree.type, pt);
 786     }
 787 
 788     public void visitTypeTest(JCInstanceOf tree) {
 789         tree.expr = translate(tree.expr, null);
 790         tree.pattern = translate(tree.pattern, null);
 791         result = tree;
 792     }
 793 
 794     public void visitIndexed(JCArrayAccess tree) {
 795         tree.indexed = translate(tree.indexed, erasure(tree.indexed.type));
 796         tree.index = translate(tree.index, syms.intType);
 797 
 798         // Insert casts of indexed expressions as needed.
 799         result = retype(tree, types.elemtype(tree.indexed.type), pt);
 800     }
 801 
 802     // There ought to be nothing to rewrite here;
 803     // we don't generate code.
 804     public void visitAnnotation(JCAnnotation tree) {
 805         result = tree;
 806     }
 807 
 808     public void visitIdent(JCIdent tree) {
 809         Type et = tree.sym.erasure(types);
 810 


< prev index next >