Skip to content

Conversation

EnzeXing
Copy link
Contributor

@EnzeXing EnzeXing commented Sep 2, 2025

This PR fixes the issue of throwing unexpected by name error in the global object initialization error when the by-name value is a modelled by set of Fun. Each element in the value set is recursively evaluated

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -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.

Copy link
Contributor

@olhotak olhotak left a comment

Choose a reason for hiding this comment

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

LGTM too.

@@ -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.

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.

@olhotak olhotak merged commit a187110 into scala:main Sep 2, 2025
44 checks passed
@olhotak olhotak deleted the fix-global-init-checker-unexpected-by-name branch September 2, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants