diff options
author | Stephan Herrmann | 2015-04-28 15:54:14 +0000 |
---|---|---|
committer | Stephan Herrmann | 2015-04-28 15:54:14 +0000 |
commit | 075533e70f43b34233c7fdad30af6ff9bb0a36a8 (patch) | |
tree | ebd195d622208318dc02f82b3005d660728dc1ac /org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java | |
parent | 1e97f79ee10aa0e956f4ba6f5e68262525ef39b0 (diff) | |
download | org.eclipse.objectteams-075533e70f43b34233c7fdad30af6ff9bb0a36a8.tar.gz org.eclipse.objectteams-075533e70f43b34233c7fdad30af6ff9bb0a36a8.tar.xz org.eclipse.objectteams-075533e70f43b34233c7fdad30af6ff9bb0a36a8.zip |
Update jdt.core to I20150428-0800 (M7 warm-up).
Manually merge from origin (bogus lineend changes):
- NullTypeAnnotationTest
- AstConverter18Test (no real change)
- FormatterBugsTests (no real change)
- SpacePreparator
- SourceTypeBinding
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java index c1abf5241..df7902024 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeVariableBinding.java @@ -33,6 +33,8 @@ * Bug 456497 - [1.8][null] during inference nullness from target type is lost against weaker hint from applicability analysis * Bug 456459 - Discrepancy between Eclipse compiler and javac - Enums, interfaces, and generics * Bug 456487 - [1.8][null] @Nullable type variant of @NonNull-constrained type parameter causes grief + * Bug 462790 - [null] NPE in Expression.computeConversion() + * Bug 456532 - [1.8][null] ReferenceBinding.appendNullAnnotation() includes phantom annotations in error messages *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; @@ -944,6 +946,27 @@ public class TypeVariableBinding extends ReferenceBinding { return readableName; } + protected void appendNullAnnotation(StringBuffer nameBuffer, CompilerOptions options) { + int oldSize = nameBuffer.length(); + super.appendNullAnnotation(nameBuffer, options); + if (oldSize == nameBuffer.length()) { // nothing appended in super.appendNullAnnotation()? + if (hasNullTypeAnnotations()) { + // see if the prototype has null type annotations: + TypeVariableBinding[] typeVariables = null; + if (this.declaringElement instanceof ReferenceBinding) { + typeVariables = ((ReferenceBinding) this.declaringElement).typeVariables(); + } else if (this.declaringElement instanceof MethodBinding) { + typeVariables = ((MethodBinding) this.declaringElement).typeVariables(); + } + if (typeVariables != null && typeVariables.length > this.rank) { + TypeVariableBinding prototype = typeVariables[this.rank]; + if (prototype != this)//$IDENTITY-COMPARISON$ + prototype.appendNullAnnotation(nameBuffer, options); + } + } + } + } + public TypeBinding unannotated() { return this.hasTypeAnnotations() ? this.environment.getUnannotatedType(this) : this; } @@ -1032,10 +1055,11 @@ public class TypeVariableBinding extends ReferenceBinding { public TypeBinding setFirstBound(TypeBinding firstBound) { this.firstBound = firstBound; if ((this.tagBits & TagBits.HasAnnotatedVariants) != 0) { - TypeBinding [] annotatedTypes = this.environment.getAnnotatedTypes(this); + TypeBinding [] annotatedTypes = getDerivedTypesForDeferredInitialization(); for (int i = 0, length = annotatedTypes == null ? 0 : annotatedTypes.length; i < length; i++) { TypeVariableBinding annotatedType = (TypeVariableBinding) annotatedTypes[i]; - annotatedType.firstBound = firstBound; + if (annotatedType.firstBound == null) + annotatedType.firstBound = firstBound; } } if (firstBound != null && firstBound.hasNullTypeAnnotations()) @@ -1048,10 +1072,11 @@ public class TypeVariableBinding extends ReferenceBinding { public ReferenceBinding setSuperClass(ReferenceBinding superclass) { this.superclass = superclass; if ((this.tagBits & TagBits.HasAnnotatedVariants) != 0) { - TypeBinding [] annotatedTypes = this.environment.getAnnotatedTypes(this); + TypeBinding [] annotatedTypes = getDerivedTypesForDeferredInitialization(); for (int i = 0, length = annotatedTypes == null ? 0 : annotatedTypes.length; i < length; i++) { TypeVariableBinding annotatedType = (TypeVariableBinding) annotatedTypes[i]; - annotatedType.superclass = superclass; + if (annotatedType.superclass == null) + annotatedType.superclass = superclass; } } return superclass; @@ -1062,15 +1087,20 @@ public class TypeVariableBinding extends ReferenceBinding { public ReferenceBinding [] setSuperInterfaces(ReferenceBinding[] superInterfaces) { this.superInterfaces = superInterfaces; if ((this.tagBits & TagBits.HasAnnotatedVariants) != 0) { - TypeBinding [] annotatedTypes = this.environment.getAnnotatedTypes(this); + TypeBinding [] annotatedTypes = getDerivedTypesForDeferredInitialization(); for (int i = 0, length = annotatedTypes == null ? 0 : annotatedTypes.length; i < length; i++) { TypeVariableBinding annotatedType = (TypeVariableBinding) annotatedTypes[i]; - annotatedType.superInterfaces = superInterfaces; + if (annotatedType.superInterfaces == null) + annotatedType.superInterfaces = superInterfaces; } } return superInterfaces; } + protected TypeBinding[] getDerivedTypesForDeferredInitialization() { + return this.environment.getAnnotatedTypes(this); + } + public TypeBinding combineTypeAnnotations(TypeBinding substitute) { if (hasTypeAnnotations()) { // may need to merge annotations from the original variable and from substitution: |