@@ -1149,48 +1149,52 @@ public boolean reduceAndIncorporate(ConstraintFormula constraint) throws Inferen
11491149 final int numVars = variableSet .size ();
11501150 if (numVars > 0 ) {
11511151 final InferenceVariable [] variables = variableSet .toArray (new InferenceVariable [numVars ]);
1152- variables : if (!isRecordPatternTypeInference && ! tmpBoundSet .hasCaptureBound (variableSet )) {
1152+ variables : if (!tmpBoundSet .hasCaptureBound (variableSet )) {
11531153 // try to instantiate this set of variables in a fresh copy of the bound set:
11541154 BoundSet prevBoundSet = tmpBoundSet ;
11551155 tmpBoundSet = tmpBoundSet .copy ();
11561156 for (int j = 0 ; j < variables .length ; j ++) {
11571157 InferenceVariable variable = variables [j ];
1158- // try lower bounds:
1159- TypeBinding [] lowerBounds = tmpBoundSet .lowerBounds (variable , true /*onlyProper*/ );
1160- if (lowerBounds != Binding .NO_TYPES ) {
1161- TypeBinding lub = this .scope .lowerUpperBound (lowerBounds );
1162- if (lub == TypeBinding .VOID || lub == null )
1163- return null ;
1164- tmpBoundSet .addBound (new TypeBound (variable , lub , ReductionResult .SAME ), this .environment );
1158+ if (isRecordPatternTypeInference ) {
1159+ tmpBoundSet .addBound (new TypeBound (variable , this .object , ReductionResult .SAME ), this .environment );
11651160 } else {
1166- TypeBinding [] upperBounds = tmpBoundSet .upperBounds (variable , true /*onlyProper*/ );
1167- // check exception bounds:
1168- if (tmpBoundSet .inThrows .contains (variable .prototype ()) && tmpBoundSet .hasOnlyTrivialExceptionBounds (variable , upperBounds )) {
1169- TypeBinding runtimeException = this .scope .getType (TypeConstants .JAVA_LANG_RUNTIMEEXCEPTION , 3 );
1170- tmpBoundSet .addBound (new TypeBound (variable , runtimeException , ReductionResult .SAME ), this .environment );
1161+ // try lower bounds:
1162+ TypeBinding [] lowerBounds = tmpBoundSet .lowerBounds (variable , true /*onlyProper*/ );
1163+ if (lowerBounds != Binding .NO_TYPES ) {
1164+ TypeBinding lub = this .scope .lowerUpperBound (lowerBounds );
1165+ if (lub == TypeBinding .VOID || lub == null )
1166+ return null ;
1167+ tmpBoundSet .addBound (new TypeBound (variable , lub , ReductionResult .SAME ), this .environment );
11711168 } else {
1172- // try upper bounds:
1173- TypeBinding glb = this . object ;
1174- if (upperBounds != Binding . NO_TYPES ) {
1175- if ( upperBounds . length == 1 ) {
1176- glb = upperBounds [ 0 ] ;
1177- } else {
1178- TypeBinding [] glbs = Scope . greaterLowerBound ( upperBounds , this . scope , this . environment );
1179- if ( glbs == null ) {
1180- return null ;
1181- } else if (glbs .length == 1 ) {
1182- glb = glbs [0 ];
1169+ TypeBinding [] upperBounds = tmpBoundSet . upperBounds ( variable , true /*onlyProper*/ );
1170+ // check exception bounds:
1171+ if (tmpBoundSet . inThrows . contains ( variable . prototype ()) && tmpBoundSet . hasOnlyTrivialExceptionBounds ( variable , upperBounds ) ) {
1172+ TypeBinding runtimeException = this . scope . getType ( TypeConstants . JAVA_LANG_RUNTIMEEXCEPTION , 3 );
1173+ tmpBoundSet . addBound ( new TypeBound ( variable , runtimeException , ReductionResult . SAME ), this . environment ) ;
1174+ } else {
1175+ // try upper bounds:
1176+ TypeBinding glb = this . object ;
1177+ if ( upperBounds != Binding . NO_TYPES ) {
1178+ if (upperBounds .length == 1 ) {
1179+ glb = upperBounds [0 ];
11831180 } else {
1184- glb = intersectionFromGlb (glbs );
1185- if (glb == null ) {
1186- // inconsistent intersection
1187- tmpBoundSet = prevBoundSet ; // clean up
1188- break variables ; // and start over
1181+ TypeBinding [] glbs = Scope .greaterLowerBound (upperBounds , this .scope , this .environment );
1182+ if (glbs == null ) {
1183+ return null ;
1184+ } else if (glbs .length == 1 ) {
1185+ glb = glbs [0 ];
1186+ } else {
1187+ glb = intersectionFromGlb (glbs );
1188+ if (glb == null ) {
1189+ // inconsistent intersection
1190+ tmpBoundSet = prevBoundSet ; // clean up
1191+ break variables ; // and start over
1192+ }
11891193 }
11901194 }
11911195 }
1196+ tmpBoundSet .addBound (new TypeBound (variable , glb , ReductionResult .SAME ), this .environment );
11921197 }
1193- tmpBoundSet .addBound (new TypeBound (variable , glb , ReductionResult .SAME ), this .environment );
11941198 }
11951199 }
11961200 }
0 commit comments