Skip to content

Fix #3495: Improve handling of getClass #7345

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

Merged
merged 4 commits into from
Oct 2, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 30, 2019

The new assumed signature is

def getClass[A >: this.type](): Class[? <: A]

This matches what scalac does, without requiring special machinery in
the type checker and inferencer.

It was not clear what this was supposed accomplish. The referred to
test case, t5568, compiles and runs with reasonable output. It was
moved from pending to run.
The new assumed signature is

    def getClass[A >: this.type](): Class[? <: A]

This matches what scalac does, without requiring special machinery in
the type checker and inferencer.
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Not caused by this PR -- Dotty and Scalac disagrees in the following code:

Dotty:

scala> (5.asInstanceOf[AnyRef & Int]).getClass
val res0: Class[Int] = int

scala> (5.asInstanceOf[Int & AnyRef]).getClass
val res1: Class[Int] = int

Scalac:

scala> (5.asInstanceOf[AnyRef with Int]).getClass
res1: Class[_ <: AnyRef] = class java.lang.Integer

scala> (5.asInstanceOf[Int with AnyRef]).getClass
res2: Class[_ <: Int] = class java.lang.Integer

@odersky
Copy link
Contributor Author

odersky commented Oct 1, 2019

Yes, there was special treatment that should have had this effect and that I eliminated in 79fb64e.

@odersky odersky merged commit a8f2787 into scala:master Oct 2, 2019
@odersky odersky deleted the fix-#3495 branch October 2, 2019 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants