Bug 87077 - [infer type arguments] problem with nested generics
Summary: [infer type arguments] problem with nested generics
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-03 10:39 EST by Adam Kiezun CLA
Modified: 2022-07-23 16:04 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Kiezun CLA 2005-03-03 10:39:01 EST
3.1M5a

public class TypeParams6<T> {
  private T f1(T t1){
  	Vector v= new Vector();
  	v.add(foo(t1));
  	Vector ll= (Vector)v.get(0);
  	return (T)ll.get(0);
  }
 Vector foo(T t){
	  Vector vs= new Vector();
	  vs.add(t);
	  return vs;
  }
}

Root exception:
java.lang.NullPointerException
at
org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintCreator.getConstraintVariable(InferTypeArgumentsConstraintCreator.java:628)
at
org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintCreator.doVisitMethodInvocationArguments(InferTypeArgumentsConstraintCreator.java:388)
at
org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsConstraintCreator.endVisit(InferTypeArgumentsConstraintCreator.java:307)
at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:247)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.MethodInvocation.accept0(MethodInvocation.java:245)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
at
org.eclipse.jdt.core.dom.ExpressionStatement.accept0(ExpressionStatement.java:143)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.Block.accept0(Block.java:135)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChild(ASTNode.java:2497)
at org.eclipse.jdt.core.dom.MethodDeclaration.accept0(MethodDeclaration.java:503)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.TypeDeclaration.accept0(TypeDeclaration.java:486)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at org.eclipse.jdt.core.dom.ASTNode.acceptChildren(ASTNode.java:2520)
at org.eclipse.jdt.core.dom.CompilationUnit.accept0(CompilationUnit.java:291)
at org.eclipse.jdt.core.dom.ASTNode.accept(ASTNode.java:2450)
at
org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring$1.acceptAST(InferTypeArgumentsRefactoring.java:137)
at
org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:641)
at
org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:436)
at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:651)
at
org.eclipse.jdt.internal.corext.refactoring.generics.InferTypeArgumentsRefactoring.checkFinalConditions(InferTypeArgumentsRefactoring.java:132)
at
org.eclipse.ltk.core.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:84)
at
org.eclipse.ltk.core.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:114)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1702)
at
org.eclipse.ltk.internal.ui.refactoring.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:86)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:111)
Comment 1 Adam Kiezun CLA 2005-03-17 19:21:10 EST
another one - with no type params:

public class ExtendsStack extends Stack{
    void newOne() throws Exception{
	new Vector().add(new ExtendsStack());
    }
	
    Object foo(){
	return push(new ExtendsStack());
    }
}
Comment 2 Markus Keller CLA 2005-03-29 08:49:47 EST
Moving Milestone.
Comment 3 Markus Keller CLA 2005-05-27 05:39:32 EDT
I20050527-0010

Example from comment 1 works for me. Comment 0 does not throw an NPE any more,
but infers this:

public class TypeParams6<T> {
	private T f1(T t1) {
		Vector<Vector<T>> v= new Vector<Vector<T>>();
		v.add(foo(t1));
		Vector ll= v.get(0);
		return (T) ll.get(0);
	}

	Vector<T> foo(T t) {
		Vector<T> vs= new Vector<T>();
		vs.add(t);
		return vs;
	}
}

The type of Vector ll should be inferred to be Vector<T>.
Comment 4 Markus Keller CLA 2005-06-09 11:28:53 EDT
Deferring.
Comment 5 Markus Keller CLA 2006-05-30 11:39:16 EDT
See also bug 87078.
Comment 6 Eclipse Genie CLA 2020-07-30 15:29:15 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 7 Eclipse Genie CLA 2022-07-23 16:04:27 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.