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
When running Foo.scala, Test.scala and one of {TypeValue1.scala, TypeValue2.scala, TypeValue3.scala} at a time the stdout is
1
5
3
4
Expectation
This should print
1
2
3
4
instead.
Further investigation
If we replace Bar[t] and Baz[t] with Bar[?] and Baz[?] respectively in TypeValue{1,2,3}.scala then:
in cases 2 and 3 the compiler reports an error:
unreducible application of higher-kinded type [T] =>>Opaques.Bar[T] to wildcard arguments
case'[Bar[?]] =>
in case 1 no error is reported and the program runs, but still prints 1 5 3 4 instead of 1 2 3 4.
The error messages are not very informative, giving no hint what should be changed to make this work and why there's a difference in behaviour between a class and an opaque type.
I would expect the code to always compile and print 1 2 3 4.
However, if the unreducible application it indeed a limitation that we cannot overcome (at all or at least for now), we should improve the error and report it in all the situations when this limitation might lead to letting the code compile and give wrong/unexpected results
The text was updated successfully, but these errors were encountered:
Compiler version
3.3.4, 3.5.2, 3.6.2-RC1-bin-20241104-8ab7ebe-NIGHTLY and older
Minimized code
Foo.scala:
TypeValue1.scala:
TypeValue2.scala:
TypeValue3.scala:
Test.scala:
Output
When running
Foo.scala
,Test.scala
and one of {TypeValue1.scala
,TypeValue2.scala
,TypeValue3.scala
} at a time the stdout isExpectation
This should print
instead.
Further investigation
If we replace
Bar[t]
andBaz[t]
withBar[?]
andBaz[?]
respectively inTypeValue{1,2,3}.scala
then:1 5 3 4
instead of1 2 3 4
.The error messages are not very informative, giving no hint what should be changed to make this work and why there's a difference in behaviour between a class and an opaque type.
I would expect the code to always compile and print
1 2 3 4
.However, if the unreducible application it indeed a limitation that we cannot overcome (at all or at least for now), we should improve the error and report it in all the situations when this limitation might lead to letting the code compile and give wrong/unexpected results
The text was updated successfully, but these errors were encountered: