Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2013-11-28 23:18:57 +0000
committerStephan Herrmann2013-11-28 23:18:57 +0000
commitcd460d721207afce8cc7fa8e4dd73aa3fde95943 (patch)
tree49a7cf219e7931a3a589a3e66f613e694807e69e
parent8aacdef17884eddfbe4320c6f762917685361bbf (diff)
downloadeclipse.jdt.core-cd460d721207afce8cc7fa8e4dd73aa3fde95943.tar.gz
eclipse.jdt.core-cd460d721207afce8cc7fa8e4dd73aa3fde95943.tar.xz
eclipse.jdt.core-cd460d721207afce8cc7fa8e4dd73aa3fde95943.zip
Change CaptureBinding18 to extend CaptureBinding as to participate in
its type checking. Will override methods as needed (not yet) since we don't have a wildcard, e.g.. readableName() is a draft only, pending more complete error reporting
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java9
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java42
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java7
3 files changed, 40 insertions, 18 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
index 55a0262229..acb5f0f899 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding.java
@@ -41,6 +41,15 @@ public class CaptureBinding extends TypeVariableBinding {
}
}
+ // for subclass CaptureBinding18
+ protected CaptureBinding(ReferenceBinding sourceType, char[] sourceName, int position, int captureID, LookupEnvironment environment) {
+ super(sourceName, null, 0, environment);
+ this.modifiers = ClassFileConstants.AccPublic | ExtraCompilerModifiers.AccGenericSignature; // treat capture as public
+ this.sourceType = sourceType;
+ this.position = position;
+ this.captureID = captureID;
+ }
+
public CaptureBinding(CaptureBinding prototype) {
super(prototype);
this.wildcard = prototype.wildcard;
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java
index 3cfed6f20a..41f5fa6785 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CaptureBinding18.java
@@ -17,15 +17,12 @@ package org.eclipse.jdt.internal.compiler.lookup;
/**
* Capture-like type variable introduced during 1.8 type inference.
*/
-public class CaptureBinding18 extends TypeVariableBinding {
+public class CaptureBinding18 extends CaptureBinding {
- private int captureID;
- TypeBinding lowerBound;
TypeBinding[] upperBounds;
- public CaptureBinding18(Binding declaringElement, char[] sourceName, int captureID, LookupEnvironment environment) {
- super(sourceName, declaringElement, 0, environment);
- this.captureID = captureID;
+ public CaptureBinding18(ReferenceBinding contextType, char[] sourceName, int captureID, LookupEnvironment environment) {
+ super(contextType, sourceName, 0, captureID, environment);
}
public void setUpperBounds(TypeBinding[] upperBounds, ReferenceBinding javaLangObject) {
@@ -53,15 +50,11 @@ public class CaptureBinding18 extends TypeVariableBinding {
if (this.superclass == null)
this.superclass = javaLangObject;
}
+
public TypeBinding clone(TypeBinding enclosingType) {
- return new CaptureBinding18(this.declaringElement, this.sourceName, this.captureID, this.environment);
+ return new CaptureBinding18(this.sourceType, this.sourceName, this.captureID, this.environment);
}
-// Note: answering true would make many clients believe we can cast to CaptureBinding!
-// public boolean isCapture() {
-// return true;
-// }
-
/**
* @see TypeBinding#isEquivalentTo(TypeBinding)
*/
@@ -96,4 +89,29 @@ public class CaptureBinding18 extends TypeVariableBinding {
boolean isProperType(boolean admitCapture18) {
return admitCapture18;
}
+
+ public char[] readableName() {
+ if (this.lowerBound == null && this.firstBound != null) {
+ if (!this.inRecursiveFunction)
+ try {
+ this.inRecursiveFunction = true;
+ return this.firstBound.readableName();
+ } finally {
+ this.inRecursiveFunction = false;
+ }
+ }
+ return super.readableName();
+ }
+
+ public char[] shortReadableName() {
+ if (this.lowerBound == null && this.firstBound != null)
+ if (!this.inRecursiveFunction)
+ try {
+ this.inRecursiveFunction = true;
+ return this.firstBound.shortReadableName();
+ } finally {
+ this.inRecursiveFunction = false;
+ }
+ return super.shortReadableName();
+ }
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
index 616c8da05e..2d1bd3baff 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/InferenceContext18.java
@@ -271,9 +271,6 @@ public class InferenceContext18 {
/**
* Try to solve the inference problem defined by constraints and bounds previously registered.
- * @param considerResolutionResult if true the solution will reflect the state after resolve(),
- * otherwise the solution will reflect the state after reduction/incorporation but before resolve(),
- * provided resolve() didn't fail, in which case we always return null.
* @return a bound set representing the solution, or null if inference failed
* @throws InferenceFailureException a compile error has been detected during inference
*/
@@ -462,10 +459,8 @@ public class InferenceContext18 {
/** For 18.4: "Let Z1, ..., Zn be fresh type variables" use capture bindings. */
private CaptureBinding18 freshCapture(InferenceVariable variable) {
- Binding declaringElement = (variable.typeParameter instanceof TypeVariableBinding)
- ? ((TypeVariableBinding) variable.typeParameter).declaringElement : null;
char[] sourceName = CharOperation.concat("Z-".toCharArray(), variable.sourceName);
- return new CaptureBinding18(declaringElement, sourceName, this.captureId++, this.environment);
+ return new CaptureBinding18(this.scope.enclosingSourceType(), sourceName, this.captureId++, this.environment);
}
// === ===

Back to the top