You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning: mocking up superclass for module classfoo
Runtime output
Exception in thread "main" java.lang.NoClassDefFoundError: foo
at bar.Test$.main(PackageType.scala:8)
at bar.Test.main(PackageType.scala)
Causedby: java.lang.ClassNotFoundException: foo
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 2 more
Expectation
Should it be possible to refer to the type of a package at all? It seems harmless if one treats it as a phantom type (the snippet doesn't crash at runtime if val x = valueOf[foo.type] gets commented out but still leaving the invocation of qux[foo.type]). On the other hand the compiler sees such types as subtypes of Singleton and tries to provide a given instance of ValueOf for them.
Neither scala 3.2.2 nor 2.13.11 allow referring to types of packages as shown below:
[error] ./PackageType.scala:7:15
[error] typearguments [foo.type] do not conform to method qux'stypeparameter bounds [A]
[error] valy= qux[foo.type]
[error] ^^^^^^^^^^^^^
[error] ./PackageType.scala:8:15
[error] typearguments [foo.type] do not conform to method valueOf'stypeparameter bounds [T]
[error] valx= valueOf[foo.type]
[error] ^^^^^^^^^^^^^^^^^
@odersky should we keep the possibility to refer to package types but make it safe at runtime or should this be disabled? Would allowing such references actually require a change in the language specification (introduced by a SIP)?
The text was updated successfully, but these errors were encountered:
I think it should be forbidden. Packages are not values, so it makes no sense to define a singleton type for them. I wonder how it regressed from 3.2.2, though?
Last good release: 3.3.0-RC1-bin-20221209-231f9ab-NIGHTLY
First bad release: 3.3.0-RC1-bin-20221213-5929a50-NIGHTLY
bisect found first bad commitPrevious HEAD position was ebb2b223ce Don't search implicit arguments in singleton type prefix
Compiler version
3.3.0, 3.3.2-RC1-bin-20230629-90c59bd-NIGHTLY
Minimized code
Compilation output
Runtime output
Expectation
Should it be possible to refer to the type of a package at all? It seems harmless if one treats it as a phantom type (the snippet doesn't crash at runtime if
val x = valueOf[foo.type]
gets commented out but still leaving the invocation ofqux[foo.type]
). On the other hand the compiler sees such types as subtypes ofSingleton
and tries to provide a given instance ofValueOf
for them.Neither scala 3.2.2 nor 2.13.11 allow referring to types of packages as shown below:
@odersky should we keep the possibility to refer to package types but make it safe at runtime or should this be disabled? Would allowing such references actually require a change in the language specification (introduced by a SIP)?
The text was updated successfully, but these errors were encountered: