-
Notifications
You must be signed in to change notification settings - Fork 1.1k
method with singleton type mismatches same singleton type #1702
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
Comments
Thanks @rethab , report confirmed. Note that following code type checks without problem -- seems related to REPL: object Foo {
def id(x: 1): 1 = x
def f = id(1)
id(1)
} |
I have analyzed this a little. What I have noticed is that in Typer.scala:1841 where the types are compared else if (tree.tpe <:< pt) { it returns false when my code from the first example is run in the REPL, but it returns true if the example from @liufengyun is run (ie. w/o REPL). Actually, in both cases both sides are equal ( My assumption is that the types are usually cached, but not between runs in the REPL. This is supported by the following snippet, which works in the REPL: scala> def id(x: 4): 4 = x; id(4)
def id(x: 4.type): Int(4) What I am unsure about is whether all types are always supposed to be cached and therefore the REPL needs to ensure that it re-uses types between runs (ie. several evaluated lines) or the |
Thanks for the analysis! |
I would try adding handling of |
Ok, thanks for the hints. I'll first have to invest some time to understand how the whole thing works down there. Are there no unit tests for the single components such as the |
Here are some tips: you can run the compiler or the repl with
Not for TypeComparer, we don't have muxh unit tests at that level. |
(Also have a look at http://dotty.epfl.ch/docs/contributing/workflow.html if you haven't already) |
Thanks a lot! I'm actually mostly using the debugger to step through and try to make sense out of it :) |
As the below example shows, a method that takes a singleton type
Int(1)
cannot be applied with1
.The text was updated successfully, but these errors were encountered: