File tree 3 files changed +9
-3
lines changed
compiler/src/dotty/tools/dotc 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -3930,6 +3930,10 @@ object Types {
3930
3930
def hasLowerBound (implicit ctx : Context ): Boolean =
3931
3931
! ctx.typerState.constraint.entry(origin).loBound.isBottomType
3932
3932
3933
+ /** For uninstantiated type variables: Is the upper bound different from Any? */
3934
+ def hasUpperBound (implicit ctx : Context ): Boolean =
3935
+ ! ctx.typerState.constraint.entry(origin).hiBound.isRef(defn.AnyClass )
3936
+
3933
3937
/** Unwrap to instance (if instantiated) or origin (if not), until result
3934
3938
* is no longer a TypeVar
3935
3939
*/
Original file line number Diff line number Diff line change @@ -111,7 +111,9 @@ object Inferencing {
111
111
def avoidBottom =
112
112
! force.allowBottom &&
113
113
defn.isBottomType(ctx.typeComparer.approximation(tvar.origin, fromBelow = true ))
114
- def preferMin = (force.minimizeAll || variance >= 0 ) && ! avoidBottom
114
+ def preferMin =
115
+ force.minimizeAll && (! avoidBottom || ! tvar.hasUpperBound)
116
+ || variance >= 0 && ! avoidBottom
115
117
if (direction != 0 ) instantiate(tvar, direction < 0 )
116
118
else if (preferMin) instantiate(tvar, fromBelow = true )
117
119
else toMaximize = true
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import scala.reflect.ClassTag
3
3
object Test {
4
4
def f [T : reflect.ClassTag ](x : T ) = ???
5
5
6
- f(??? )
6
+ f(??? ) // error: undetermined ClassTag
7
7
}
8
8
9
9
// SI 9754
@@ -22,6 +22,6 @@ object Program {
22
22
23
23
// SI 5353
24
24
object t5353 {
25
- if (false ) Array (" qwe" ) else Array ()
25
+ if (false ) Array (" qwe" ) else Array () // error: undetermined ClassTag
26
26
}
27
27
You can’t perform that action at this time.
0 commit comments