Skip to content

Commit 224b13b

Browse files
committed
Fix widen in AndType
1 parent abc11ac commit 224b13b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,7 @@ object Types {
12081208
if tp.isOverloaded then tp else tp.underlying.widen
12091209
case tp: SingletonType => tp.underlying.widen
12101210
case tp: ExprType => tp.resultType.widen
1211+
case tp: AndType => tp.derivedAndType(tp.tp1.widen, tp.tp2.widen)
12111212
case tp =>
12121213
val tp1 = tp.stripped
12131214
if tp1 eq tp then tp

tests/explicit-nulls/pos/i13197.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait Bar:
2+
def b: String | Null
3+
4+
class Foo(a: String = "", b: String)
5+
6+
object Foo:
7+
def foo(bar: Bar) = Foo(b = bar.b.nn)

0 commit comments

Comments
 (0)