26 package com.sun.tools.javac.comp; |
26 package com.sun.tools.javac.comp; |
27 |
27 |
28 import java.util.*; |
28 import java.util.*; |
29 |
29 |
30 import com.sun.tools.javac.code.*; |
30 import com.sun.tools.javac.code.*; |
|
31 import com.sun.tools.javac.code.Type.AnnotatedType; |
31 import com.sun.tools.javac.jvm.*; |
32 import com.sun.tools.javac.jvm.*; |
32 import com.sun.tools.javac.main.Option.PkgInfo; |
33 import com.sun.tools.javac.main.Option.PkgInfo; |
33 import com.sun.tools.javac.tree.*; |
34 import com.sun.tools.javac.tree.*; |
34 import com.sun.tools.javac.util.*; |
35 import com.sun.tools.javac.util.*; |
35 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
36 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; |
2765 } |
2766 } |
2766 return translationMap; |
2767 return translationMap; |
2767 } |
2768 } |
2768 |
2769 |
2769 public void visitAnnotatedType(JCAnnotatedType tree) { |
2770 public void visitAnnotatedType(JCAnnotatedType tree) { |
2770 // No need to retain type annotations any longer. |
2771 // No need to retain type annotations in the tree |
2771 // tree.annotations = translate(tree.annotations); |
2772 // tree.annotations = translate(tree.annotations); |
|
2773 tree.annotations = List.nil(); |
2772 tree.underlyingType = translate(tree.underlyingType); |
2774 tree.underlyingType = translate(tree.underlyingType); |
2773 result = tree.underlyingType; |
2775 // but maintain type annotations in the type. |
|
2776 if (tree.type.isAnnotated()) { |
|
2777 if (tree.underlyingType.type.isAnnotated()) { |
|
2778 // The erasure of a type variable might be annotated. |
|
2779 // Merge all annotations. |
|
2780 AnnotatedType newat = (AnnotatedType) tree.underlyingType.type; |
|
2781 AnnotatedType at = (AnnotatedType) tree.type; |
|
2782 at.underlyingType = newat.underlyingType; |
|
2783 newat.typeAnnotations = at.typeAnnotations.appendList(newat.typeAnnotations); |
|
2784 tree.type = newat; |
|
2785 } else { |
|
2786 // Create a new AnnotatedType to have the correct tag. |
|
2787 AnnotatedType oldat = (AnnotatedType) tree.type; |
|
2788 tree.type = new AnnotatedType(tree.underlyingType.type); |
|
2789 ((AnnotatedType) tree.type).typeAnnotations = oldat.typeAnnotations; |
|
2790 } |
|
2791 } |
|
2792 result = tree; |
2774 } |
2793 } |
2775 |
2794 |
2776 public void visitTypeCast(JCTypeCast tree) { |
2795 public void visitTypeCast(JCTypeCast tree) { |
2777 tree.clazz = translate(tree.clazz); |
2796 tree.clazz = translate(tree.clazz); |
2778 if (tree.type.isPrimitive() != tree.expr.type.isPrimitive()) |
2797 if (tree.type.isPrimitive() != tree.expr.type.isPrimitive()) |