Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #15679: Don't ignore expected types of New #15754

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

Kordyjan
Copy link
Contributor

Backports #15679

@Kordyjan Kordyjan added this to the 3.2.0 backports milestone Jul 26, 2022
odersky added 2 commits July 26, 2022 14:58
A problem arises if we typecheck an expression like `new C()` with expected type
`C[U]` where `C` is
defined like this
```scala
class C[X](using X)()
```
In this case, we'd like to propagate `U` as the type instance of `X` before we
resolve the using clause. To do this, we have to keep the expected result
type `C[X]` for typechecking the function part `new C`. Previously, that type was wrapped
in an IgnoredProto.

The problem was detected now since a class C with just the using clause and
no empty parameter clause was previously expanded to
```scala
class C[X]()(using X)
```
but is now expanded to
```scala
class C[X](using X)()
```
Under the previous expansion, we type checked and `new C()` before looking
for an argument of the using clause, so the problem did not arise.
It turns out an sjsJUnitTest fails otherwise, since that one _does_ insert an implicit conversion after a `new`.

This is all goes to show that what we do to deal with implicit conversions
is completely crazy. It's a black art when to propagate exected types. There's
often no better or worse. Almost any change we do can heal some code and break
some other code. I believe the only way to get our of this swamp is to get
rid of unrestricted implicit conversions.
@Kordyjan Kordyjan mentioned this pull request Jul 26, 2022
23 tasks
@Kordyjan Kordyjan merged commit 3d29fd1 into scala:release-3.2.0 Jul 27, 2022
@Kordyjan Kordyjan deleted the backport-15679 branch July 27, 2022 08:22
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.

2 participants