@@ -1878,7 +1878,7 @@ public static ClassNode getCorrectedClassNode(ClassNode type, ClassNode superCla
1878
1878
return corrected ;
1879
1879
}
1880
1880
1881
- private static void extractGenericsConnections (Map <GenericsTypeName , GenericsType > connections , GenericsType [] usage , GenericsType [] declaration ) {
1881
+ private static void extractGenericsConnections (final Map <GenericsTypeName , GenericsType > connections , final GenericsType [] usage , final GenericsType [] declaration ) {
1882
1882
// if declaration does not provide generics, there is no connection to make
1883
1883
if (usage == null || declaration == null || declaration .length == 0 ) return ;
1884
1884
final int n ; if ((n = usage .length ) != declaration .length ) return ;
@@ -1887,14 +1887,14 @@ private static void extractGenericsConnections(Map<GenericsTypeName, GenericsTyp
1887
1887
for (int i = 0 ; i < n ; i += 1 ) {
1888
1888
GenericsType ui = usage [i ];
1889
1889
GenericsType di = declaration [i ];
1890
- if (di .isPlaceholder ()) {
1890
+ if (di .isPlaceholder ()) { // di like "T"
1891
1891
connections .put (new GenericsTypeName (di .getName ()), ui );
1892
- } else if (di .isWildcard ()) {
1892
+ } else if (di .isWildcard ()) { // di like "?", "? super T", "? extends T", ...
1893
1893
ClassNode lowerBound = di .getLowerBound (), upperBounds [] = di .getUpperBounds ();
1894
- if (ui .isWildcard ()) {
1894
+ if (ui .isWildcard ()) { // ui like "?", "? super Type" or "? extends Type"
1895
1895
extractGenericsConnections (connections , ui .getLowerBound (), lowerBound );
1896
1896
extractGenericsConnections (connections , ui .getUpperBounds (), upperBounds );
1897
- /* GRECLIPSE edit -- GROOVY-9998
1897
+ /* GRECLIPSE edit -- GROOVY-9998, GROOVY-10328, GROOVY-10499, et al.
1898
1898
} else {
1899
1899
ClassNode ui_type = ui.getType();
1900
1900
extractGenericsConnections(connections, ui_type, lowerBound);
@@ -1907,11 +1907,14 @@ private static void extractGenericsConnections(Map<GenericsTypeName, GenericsTyp
1907
1907
*/
1908
1908
} else if (!isUnboundedWildcard (di )) {
1909
1909
ClassNode boundType = lowerBound != null ? lowerBound : upperBounds [0 ];
1910
- if (boundType .isGenericsPlaceHolder () /* GROOVY-10765: */ && boundType != ui . getType ()) {
1911
- ui = new GenericsType ( ui . getType ()); ui . setPlaceHolder ( false ); ui . setWildcard ( true );
1912
- connections . put ( new GenericsTypeName ( boundType . getUnresolvedName ()), ui );
1913
- } else { // di like "? super Iterable<T>" and ui like "Collection<Type> "
1910
+ if (! boundType .isGenericsPlaceHolder ()) {
1911
+ // di like "? extends Iterable<T>" and ui like "Collection<Type>"
1912
+ extractGenericsConnections ( connections , ui . getType (), boundType );
1913
+ } else if ( lowerBound == null ) { // di like "? extends T "
1914
1914
extractGenericsConnections (connections , ui .getType (), boundType );
1915
+ } else { // 6731,8983,10047,10749 : di like "? super T"
1916
+ ui = new GenericsType (ui .getType ()); ui .setWildcard (true ); // weak sauce
1917
+ connections .put (new GenericsTypeName (boundType .getUnresolvedName ()), ui );
1915
1918
}
1916
1919
}
1917
1920
// GRECLIPSE end
@@ -2077,10 +2080,9 @@ static ClassNode getCombinedBoundType(GenericsType genericsType) {
2077
2080
return genericsType .getType ();
2078
2081
}
2079
2082
2080
- // GRECLIPSE add -- GROOVY-9998, GROOVY-10339, GROOVY-10499
2081
- static GenericsType getCombinedGenericsType (GenericsType gt1 , GenericsType gt2 ) {
2082
- if (isUnboundedWildcard (gt1 )) gt1 = gt1 .getType ().asGenericsType ();
2083
- if (isUnboundedWildcard (gt2 )) gt2 = gt2 .getType ().asGenericsType ();
2083
+ // GRECLIPSE add -- GROOVY-7992, GROOVY-9998, GROOVY-10339, GROOVY-10499, GROOVY-10765
2084
+ static GenericsType getCombinedGenericsType (final GenericsType gt1 , final GenericsType gt2 ) {
2085
+ if (isUnboundedWildcard (gt1 ) != isUnboundedWildcard (gt2 )) return isUnboundedWildcard (gt2 ) ? gt1 : gt2 ;
2084
2086
ClassNode cn1 = GenericsUtils .makeClassSafe0 (CLASS_Type , gt1 );
2085
2087
ClassNode cn2 = GenericsUtils .makeClassSafe0 (CLASS_Type , gt2 );
2086
2088
ClassNode lub = WideningCategories .lowestUpperBound (cn1 , cn2 );
0 commit comments