Bug 207299 - [1.5][compiler] StackOverflow when eliminating type variables
Summary: [1.5][compiler] StackOverflow when eliminating type variables
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-24 09:12 EDT by Philipe Mulet CLA
Modified: 2007-10-29 09:30 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (7.12 KB, patch)
2007-10-24 09:29 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2007-10-24 09:12:35 EDT
Build I20071023-0800

Since changes for bug 158870, the following testcase produces a stack overflow when compiled.

import java.util.*;

class ExpressionGraph<G extends ExpressionGraph<G, V, L>, V extends ExpressionVertex<G, V, L>, L> extends AbstractGraph<G, V> {
	void foo(Set<V> set, Collection<? extends V> col) {
		if (set == col) return;
	}

	interface IVertex<G extends ExpressionGraph<G, V, L>, V extends IVertex<G, V, L>, L> extends ExpressionVertex<G, V, L> {	
		// empty
	}
	static abstract class Vertex<G extends ExpressionGraph<G, V, L>, V extends IVertex<G, V, L>, L> implements IVertex<G, V, L> {	
		// empty
	}
}

abstract class AbstractGraph<G extends AbstractGraph<G,V>, V extends Vertex<G,V>> implements Graph<G,V> {
	// empty
}
interface Graph<G extends Graph<G,V>, V extends Vertex<G,V>> {	
	// empty
}
interface Vertex<G extends Graph<G,V>, V extends Vertex<G,V>> {
	// empty
}
interface ExpressionVertex<G extends Graph<G,V>, V extends ExpressionVertex<G,V,L>, L> extends Vertex<G,V> {
	// empty
}
Comment 1 Philipe Mulet CLA 2007-10-24 09:19:36 EDT
Simpler testcase:

import java.util.*;
class ExpressionGraph<G extends ExpressionGraph<G, V>, V extends IVertex<G, V>> {
	void foo(Set<V> set, Collection<? extends V> col) {
		if (set == col) return;
	}
}
interface IVertex<G extends ExpressionGraph<G, V>, V extends IVertex<G, V>> {	
	// empty
}
Comment 2 Philipe Mulet CLA 2007-10-24 09:28:59 EDT
Added GenericTypeTest#test1204-1205
Comment 3 Philipe Mulet CLA 2007-10-24 09:29:19 EDT
Created attachment 81057 [details]
Proposed patch
Comment 4 Philipe Mulet CLA 2007-10-24 09:30:24 EDT
Variable elimination shouldn't assume direct relationship, there can be forward references to type parameters, hence need for remembering visited variables (not just the last one).
Comment 5 Philipe Mulet CLA 2007-10-25 06:43:35 EDT
Released for 3.4M3.
Fixed
Comment 6 Philipe Mulet CLA 2007-10-29 06:12:41 EDT
Fixed
Comment 7 Maxime Daniel CLA 2007-10-29 09:30:20 EDT
Verified for 3.4 M3 using build I20071029-0010.