Skip to content

Fix #3630: Handle classtag searches with wildcard arguments #3718

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 1 commit into from
Jan 13, 2018

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 31, 2017

No description provided.

@@ -320,6 +320,7 @@ object TypeErasure {
case _ => false
}
case tp: TypeParamRef => false
case tp: TypeBounds => false
Copy link
Member

Choose a reason for hiding this comment

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

Would hasStableErasure(tp.lo) && hasStableErasure(tp.hi) be incorrect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, because we fall into this case also via TypeProxy.

@@ -0,0 +1 @@
class U { Array(Array(2), Array("a")) } // error: no classtag
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need to disallow this? It seems to work OK in scalac.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The full error message says:

No ClassTag available for Array[_ >: Int & String <: Int | String]

The inferred type of the outer array is

Array[Array[_ >: Int & String <: Int | String]]

That is indeed the best type. But there's no ClassTag. We could infer some wider type such as

Array[AnyRef](Array(2), Array("a"))

for the outer array. But it would be a special case. And I am not sure whether in the end it would not be better to reject this weird construction as an error and demand that the user write

Array[AnyRef](Array(2), Array("a"))

explicitly.

@odersky odersky merged commit 1ab6027 into scala:master Jan 13, 2018
@allanrenucci allanrenucci deleted the fix-#3630 branch January 14, 2018 10:11
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