Skip to content

Commit 5e63644

Browse files
author
EnzeXing
committed
Fix unexpected by-name
1 parent 4493b49 commit 5e63644

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,9 +1364,9 @@ class Objects(using Context @constructorOnly):
13641364
case UnknownValue =>
13651365
reportWarningForUnknownValue("Calling on unknown value. " + Trace.show, Trace.position)
13661366
case Bottom => Bottom
1367-
case ValueSet(values) if values.size == 1 =>
1368-
evalByNameParam(values.head)
1369-
case _: ValueSet | _: Ref | _: ArrayRef | _: Package | SafeValue(_) =>
1367+
case ValueSet(values) =>
1368+
values.map(evalByNameParam(_)).join
1369+
case _: Ref | _: ArrayRef | _: Package | SafeValue(_) =>
13701370
report.warning("[Internal error] Unexpected by-name value " + value.show + ". " + Trace.show, Trace.position)
13711371
Bottom
13721372
end evalByNameParam
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class X {
2+
def bar(): Int = 5
3+
}
4+
class Y extends X {
5+
override def bar(): Int = 6
6+
}
7+
8+
object O {
9+
def foo(p: => X) = {
10+
p.bar()
11+
}
12+
13+
val a = foo(new X)
14+
val b = foo(new Y)
15+
}

0 commit comments

Comments
 (0)