-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement getClass #734
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
Implement getClass #734
Conversation
@DarkDimius @smarter, please check if a test covers expected behaviour. |
This PR does not currently have an implementation, only a test that fails due to non-implemented #733. Did you forget to push something? |
It does not have yet. Is the test correct? |
All names but name of the anonymous lambdas ( |
println(1f.getClass) | ||
println(1d.getClass) | ||
|
||
println("Class types") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add an empty string to the output here, to have output structured.
6d2644a
to
575fc84
Compare
There are compile-time warnings:
And runtime errors as follows:
What should be fixed? Everything else passes. |
Those are known warnings. Ignore them.
That is strange. This is a class defined in |
575fc84
to
8ef13a6
Compare
Fixed. My CP was wrong. There is another problem. Seems like |
AFAIK it should not. Though you should not handle arrays at all: classes that extend AnyRef have a runtime |
* FILL ME | ||
*/ | ||
class GetClass extends MiniPhaseTransform { | ||
import tpd.{Apply, Tree, Literal, ref, TreeOps} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just import tpd._
There is code in |
This code is left as it tries to cover non-trivial bug. Though I've checked now and the way how this was fixed in scalac does not work in dotty: I believe that we need a different fix. The way I would fix it in dotty is to rewrite
to
This should do the trick. |
8ef13a6
to
040ef52
Compare
case defn.FloatClass => TYPE(defn.BoxedFloatModule) | ||
case defn.DoubleClass => TYPE(defn.BoxedDoubleModule) | ||
case defn.UnitClass => TYPE(defn.BoxedVoidModule) | ||
case _ => qual.selectWithSig(defn.Any_getClass).appliedToNone |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not simply tree
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that works.
0f4cb1a
to
721e840
Compare
721e840
to
2cf567b
Compare
@@ -62,6 +62,7 @@ class Compiler { | |||
new AugmentScala2Traits, | |||
new ResolveSuper), | |||
List(new Erasure), | |||
List(new GetClass), // getClass transformation should be applied to specialized methods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you try to put it in next mini-phase block?
Otherwise LGTM |
53cac02
to
d24c694
Compare
@DarkDimius , well, worked out. Should I squash both commits? |
LGTM |
@alexander-myltsev, thanks for your contribution! |
Closes #733