Mercurial > hg > openjdk > lambda > langtools
changeset 1587:7ffcc63f2b3d
Fixes to 269 support for intersection types:
*) typo in IntersectionType interface javadoc
*) getEnclosedElements should return empty list when invoked on an intersection type-element
author | mcimadamore |
---|---|
date | Thu, 01 Nov 2012 09:11:51 +0000 |
parents | 99ce7dc58473 |
children | c9a4b3c92810 |
files | src/share/classes/com/sun/tools/javac/code/Symbol.java src/share/classes/javax/lang/model/type/IntersectionType.java test/tools/javac/cast/intersection/model/ModelChecker.java |
diffstat | 3 files changed, 13 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Oct 31 22:32:32 2012 +0000 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Nov 01 09:11:51 2012 +0000 @@ -575,18 +575,12 @@ List<Symbol> list = List.nil(); if (kind == TYP && type.tag == TYPEVAR) { return list; - } else if ((flags() & COMPOUND) != 0) { - for (Type t : ((IntersectionClassType)type).getComponents()) { - list = list.appendList(List.from(t.tsym.getEnclosedElements())); - } - return list; - } else { - for (Scope.Entry e = members().elems; e != null; e = e.sibling) { - if (e.sym != null && (e.sym.flags() & SYNTHETIC) == 0 && e.sym.owner == this) - list = list.prepend(e.sym); - } - return list; } + for (Scope.Entry e = members().elems; e != null; e = e.sibling) { + if (e.sym != null && (e.sym.flags() & SYNTHETIC) == 0 && e.sym.owner == this) + list = list.prepend(e.sym); + } + return list; } // For type params.
--- a/src/share/classes/javax/lang/model/type/IntersectionType.java Wed Oct 31 22:32:32 2012 +0000 +++ b/src/share/classes/javax/lang/model/type/IntersectionType.java Thu Nov 01 09:11:51 2012 +0000 @@ -28,13 +28,13 @@ import java.util.List; /** - * Represents a union type. + * Represents an intersection type. * * As of the {@link javax.lang.model.SourceVersion#RELEASE_8 * RELEASE_8} source version, intersection types can appear as the target type * of a cast expression. * - * @since 1.7 + * @since 1.8 */ public interface IntersectionType extends TypeMirror {
--- a/test/tools/javac/cast/intersection/model/ModelChecker.java Wed Oct 31 22:32:32 2012 +0000 +++ b/test/tools/javac/cast/intersection/model/ModelChecker.java Thu Nov 01 09:11:51 2012 +0000 @@ -30,7 +30,6 @@ * @compile -processor ModelChecker Model01.java */ -import com.sun.source.tree.CatchTree; import com.sun.source.tree.ExpressionTree; import com.sun.source.tree.Tree; import com.sun.source.tree.TypeCastTree; @@ -41,10 +40,10 @@ import com.sun.tools.javac.tree.JCTree.JCExpression; import java.util.Set; + import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; import javax.lang.model.element.Element; -import javax.lang.model.element.ElementKind; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeKind; @@ -97,11 +96,16 @@ validateIntersectionTypeInfo(t, it); for (Element e2 : types.asElement(t).getEnclosedElements()) { + assertTrue(false, "an intersection type has no declared members"); + } + + for (Element e2 : elements.getAllMembers((TypeElement)types.asElement(t))) { Member m = e2.getAnnotation(Member.class); if (m != null) { assertTrue(e2.getKind() == m.value(), "Expected " + m.value() + " - found " + e2.getKind()); } } + assertTrue(assertionCount == 10, "Expected 10 assertions - found " + assertionCount); return super.visitVariable(node, p); }