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
, I have no problem with defining x. For the definition of y however I get:
Test.scala:3:error: typemismatch;
found : B[objectA]
required: B[A.type]
If I look at the compiler's typer phase, the two definitions are as follows:
scalac -Xprint:typer Test.scala
defx:objectA=A;
defy:B[A.type] =newB[objectA](A)
We see in the first definition that "A.type" is simply translated into "object A" : the two expressions seem to mean the same thing. However in the second definition they obviously do not, as they are causing a type mismatch.
I can compile the definition of y if I force the type parameter to A.type:
defy:B[A.type] =newB[A.type](A)
My question : do "object A" and A.type mean the same thing, or not ? If not, why does the definition of x work ? If they do, why does the definition of y fail ? Thanks
The text was updated successfully, but these errors were encountered:
@paulp said:
This is a duplicate of perennial favorite #1208. If you want more explanation than you can find in that ticket (and others) please ask on one of the mailing lists.
The problem exists in both 2.7 and 2.8. When I try to compile this code:
, I have no problem with defining x. For the definition of y however I get:
If I look at the compiler's typer phase, the two definitions are as follows:
scalac -Xprint:typer Test.scala
We see in the first definition that "A.type" is simply translated into "object A" : the two expressions seem to mean the same thing. However in the second definition they obviously do not, as they are causing a type mismatch.
I can compile the definition of y if I force the type parameter to A.type:
My question : do "object A" and A.type mean the same thing, or not ? If not, why does the definition of x work ? If they do, why does the definition of y fail ? Thanks
The text was updated successfully, but these errors were encountered: