Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions compiler/src/dotty/tools/dotc/transform/init/Objects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1360,13 +1360,13 @@ class Objects(using Context @constructorOnly):
case env: Env.EnvRef => Env.ofByName(sym, thisV, Env.EnvSet(Set(env)))
}
given Scope = byNameEnv
eval(code, thisV, klass)
eval(code, thisV, klass, cacheResult = true)
case UnknownValue =>
reportWarningForUnknownValue("Calling on unknown value. " + Trace.show, Trace.position)
case Bottom => Bottom
case ValueSet(values) if values.size == 1 =>
evalByNameParam(values.head)
case _: ValueSet | _: Ref | _: ArrayRef | _: Package | SafeValue(_) =>
case ValueSet(values) =>
values.map(evalByNameParam(_)).join
case _: Ref | _: ArrayRef | _: Package | SafeValue(_) =>
report.warning("[Internal error] Unexpected by-name value " + value.show + ". " + Trace.show, Trace.position)
Bottom
end evalByNameParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ object Test:
class Box(val x: Int)

def recur(a: => Box, b: Box): Int =
a.x + recur(a, b) + b.x // warn
a.x + recur(a, b) + b.x

recur(Box(1), Box(2))
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ object Test:
class Box(val x: Int)

def recur(a: => Box, b: => Box): Int =
a.x + recur(a: @widen(5), b: @widen(5)) + b.x // warn // warn
a.x + recur(a: @widen(5), b: @widen(5)) + b.x

recur(Box(1), Box(2))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can drop this test, it's the same as the other one. The widen annotation does not have a meaning in the new analysis anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we still have the annotation, we can keep the test in case we start using the annotation again.

If we decide to remove the annotation at some point, we can have a PR that changes all the tests that use the annotation.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ object Test:
class Box(val x: Int)

def recur(a: => Box, b: => Box): Int =
a.x + recur(a, b) + b.x // warn // warn
a.x + recur(a, b) + b.x

recur(Box(1), Box(2))
15 changes: 15 additions & 0 deletions tests/init-global/pos/multiple-by-name.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class X {
def bar(): Int = 5
}
class Y extends X {
override def bar(): Int = 6
}

object O {
def foo(p: => X) = {
p.bar()
}

val a = foo(new X)
val b = foo(new Y)
}
Loading