Closed som-snytt closed 11 months ago
Scala version: 2.13.12
➜ snips cat narrows.scala class C { def i: Int = 42 } object D extends C { override final val i = 27 } object Test { def f: 27 = D.i }
Compiles under 2.13 but not under -Xsource:3 because of the inferred type for D.i.
-Xsource:3
D.i
Dotty correctly infers 27. Probably Scala 2 inadvertently widens when picking the "narrow" intersection.
27
Noticed at https://github.com/scala/scala/pull/10439#issuecomment-1637074874
Reproduction steps
Scala version: 2.13.12
Problem
Compiles under 2.13 but not under
-Xsource:3
because of the inferred type forD.i
.Dotty correctly infers
27
. Probably Scala 2 inadvertently widens when picking the "narrow" intersection.Noticed at https://github.com/scala/scala/pull/10439#issuecomment-1637074874