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

3.3.1-RC4 compiles but 3.3.1-RC5 fails ScalaTest assertThrows without a type parameter #18478

Closed
godenji opened this issue Aug 29, 2023 · 2 comments

Comments

@godenji
Copy link

godenji commented Aug 29, 2023

Compiler version

3.3.1-RC5 and 3.3.1-RC6

Minimized code

dummy implementation of assertThrows

inline def assertThrows[T <: AnyRef](f: => Any)(implicit classTag: scala.reflect.ClassTag[T]) = f

assertThrows(1)

Output

No ClassTag available for T
  |
  |               where:    T is a type variable with constraint <: AnyRef

Expectation

Compiles successfully as was the case prior to RC5.

I thought that the offending commit was this merged PR but apparently it's unrelated? At any rate, a commit in RC5 has broken ScalaTest.

@godenji godenji added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 29, 2023
@jchyb
Copy link
Contributor

jchyb commented Aug 30, 2023

Hi, thank you for filing an issue. I tested this once again, and I see what the problem is now. The provided minimization does indeed compile for 3.3.1-RC1 to 3.3.1-RC4, but it fails for every stable version of the compiler. To ensure source compatibility in the LTS (the 3.3.x series) we had to remove some changes in the unstable RC versions.

With that said I still believe this minimization should not be able to compile either way, since compiler has no way of knowing what T should resolve to, and therefore cannot generate the ClassTag (as it has no idea what to generate). Reading the docs of ScalaTest, they ask to explicitly pass the type parameter, like here:

assertThrows[scala.ArrayIndexOutOfBoundsException](array(10))

However, if You have a regression in your repo from 3.3.0 to 3.3.1-RC6 (with perhaps a different minimization), please let us know! We might be able to/need to fix that one.

@jchyb jchyb changed the title 3.3.1-RC5 Breaks ScalaTest assertThrows 3.3.1-RC4 compiles but 3.3.1-RC5 fails ScalaTest assertThrows without a type parameter Aug 30, 2023
@jchyb jchyb added stat:wontfix area:typer and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 30, 2023
@Kordyjan Kordyjan closed this as not planned Won't fix, can't repro, duplicate, stale Aug 30, 2023
@godenji
Copy link
Author

godenji commented Aug 30, 2023

With that said I still believe this minimization should not be able to compile either way, since compiler has no way of knowing what T should resolve to, and therefore cannot generate the ClassTag (as it has no idea what to generate). Reading the docs of ScalaTest, they ask to explicitly pass the type parameter, like here:

assertThrows[scala.ArrayIndexOutOfBoundsException](array(10))

RTFM, thanks for pointing that out! Supplying type argument solves the issue, will modify affected test cases accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants