File tree 2 files changed +10
-3
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -271,9 +271,11 @@ trait ConstraintHandling {
271
271
var inst = approximation(param, fromBelow).simplified
272
272
273
273
// Then, approximate by (1.) - (3.) and simplify as follows.
274
- // 1. If instance is from below and is a singleton type, yet
275
- // upper bound is not a singleton type, widen the instance.
276
- if (fromBelow && isSingleton(inst) && ! isSingleton(upperBound))
274
+ // 1. If instance is from below and is a singleton type, yet upper bound is
275
+ // not a singleton type or a reference to `scala.Singleton`, widen the
276
+ // instance.
277
+ if (fromBelow && isSingleton(inst) && ! isSingleton(upperBound)
278
+ && ! upperBound.isRef(defn.SingletonClass ))
277
279
inst = inst.widen
278
280
279
281
// 2. If instance is from below and is a fully-defined union type, yet upper bound
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def foo [T <: Singleton ](x : T ): T = x
3
+
4
+ val a : 1 = foo(1 )
5
+ }
You can’t perform that action at this time.
0 commit comments