diff options
| author | Markus Keller | 2014-03-13 18:32:27 +0000 |
|---|---|---|
| committer | Markus Keller | 2014-03-13 18:32:27 +0000 |
| commit | bde76c7ffed680bfda8eaca694124e585f592522 (patch) | |
| tree | cf58419a7fbf75a562654f4358bfb934e29a496d | |
| parent | 21f5a82054b3ee5f26b3bb538a273b9810c96f25 (diff) | |
| download | eclipse.jdt.ui-bde76c7ffed680bfda8eaca694124e585f592522.tar.gz eclipse.jdt.ui-bde76c7ffed680bfda8eaca694124e585f592522.tar.xz eclipse.jdt.ui-bde76c7ffed680bfda8eaca694124e585f592522.zip | |
Bug 217984: [quick assist] wrong type inferred by assign to new local
variable
| -rw-r--r-- | org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/Bindings.java | 14 | ||||
| -rw-r--r-- | org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java | 16 |
2 files changed, 22 insertions, 8 deletions
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/Bindings.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/Bindings.java index 5bf2dd154b..d8d959a79c 100644 --- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/Bindings.java +++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/dom/Bindings.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -1086,10 +1086,16 @@ public class Bindings { binding= normalizeTypeBinding(binding); if (binding == null || !binding.isWildcardType()) return binding; - if (binding.isUpperbound()) { - return binding.getBound(); + ITypeBinding bound= binding.getBound(); + if (bound == null || !binding.isUpperbound()) { + ITypeBinding[] typeBounds= binding.getTypeBounds(); + if (typeBounds.length > 0) { + return typeBounds[0]; + } else { + return binding.getErasure(); + } } else { - return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ + return bound; } } diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java index 2d79cc5274..d104e07751 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ASTResolving.java @@ -1135,15 +1135,23 @@ public class ASTResolving { * Use this method before creating a type for a wildcard. Either to assign a wildcard to a new type or for a type to be assigned. * * @param wildcardType the wildcard type to normalize - * @param isBindingToAssign If true, then a new receiver type is searched (X x= s), else the type of a sender (R r= x) - * @param ast th current AST - * @return Returns the normalized binding or null when only the 'null' binding + * @param isBindingToAssign if true, then the type X for new variable x is returned (X x= s); + * if false, the type of an expression x (R r= x) + * @param ast the current AST + * @return the normalized binding or null when only the 'null' binding + * + * @see Bindings#normalizeForDeclarationUse(ITypeBinding, AST) */ public static ITypeBinding normalizeWildcardType(ITypeBinding wildcardType, boolean isBindingToAssign, AST ast) { ITypeBinding bound= wildcardType.getBound(); if (isBindingToAssign) { if (bound == null || !wildcardType.isUpperbound()) { - return ast.resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ + ITypeBinding[] typeBounds= wildcardType.getTypeBounds(); + if (typeBounds.length > 0) { + return typeBounds[0]; + } else { + return wildcardType.getErasure(); + } } } else { if (bound == null || wildcardType.isUpperbound()) { |
