Navigation Menu

Skip to content
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

Parameterizing varargs method on singleton type crashes scalac #3494

Closed
scabug opened this issue May 27, 2010 · 8 comments
Closed

Parameterizing varargs method on singleton type crashes scalac #3494

scabug opened this issue May 27, 2010 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented May 27, 2010

Snipping the original report, replacing with essence. Not sure if this usage seems pathological or not, but I have a very interesting side project underway which is temporarily stymied by this crash, so it's of interest at least to me and the original reporter. I'm pretty sure it's related to varargs processing based on the appearance of Array in the crasher and also the last demo below:

object Test {
  val x = "abc"
  val xs = List[x.type](x)
}
Exception in thread "main" scala.tools.nsc.symtab.Types$$TypeError: type mismatch;
 found   : Array[Test.x.type]
 required: Array[java.lang.String]
	at scala.tools.nsc.typechecker.Contexts$$Context.error(Contexts.scala:273)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.error(Infer.scala:213)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.typeError(Infer.scala:223)
	at scala.tools.nsc.typechecker.Infer$$Inferencer.typeErrorTree(Infer.scala:238)
[...]
scala> val x = "abc"                          
x: java.lang.String = abc

scala> val y = Some[x.type](x)              
y: Some[x.type] = Some(abc)

scala> val y: List[x.type] = ::[x.type](x, ::[x.type](x, Nil))
y: List[x.type] = List(abc, abc)
@scabug
Copy link
Author

scabug commented May 27, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3494?orig=1
Reporter: AlexK (alexk)

@scabug
Copy link
Author

scabug commented Jun 4, 2010

@paulp said:
Oh, and you'd think I'd post more direct evidence when opening the ticket, but I realized it was the varargs at the last moment and I was on my way out the door. Here is a less roundabout demonstration of same.

scala> def f[T](xs: T*) = ()
f: [T](xs: T*)Unit

scala> val x = "abc"
x: java.lang.String = abc

scala> f[x.type](x)
exception when traversing line0$$object.$$iw.$$iw.f[$$iw.$$iw.x.type](line2$$object.$$iw.$$iw.x)
...

@scabug
Copy link
Author

scabug commented Jun 7, 2010

@dragos said:
Adriaan, would you like to have a first shot at this (type) error?

@scabug
Copy link
Author

scabug commented Jun 7, 2010

@adriaanm said:
shouldn't let type argument for inserted wrapRefArray be inferred (as the expected element type of the array could be a singleton type, but that won't be inferred)

@scabug
Copy link
Author

scabug commented Jun 7, 2010

@paulp said:
Replying to [comment:4 moors]:

shouldn't let type argument for inserted wrapRefArray be inferred (as the expected element type of the array could be a singleton type, but that won't be inferred)

Or, winding back toward my little side project, I am desperate for some workable mechanism to cause the singleton type to be inferred for specific values (i.e. they will be declared as having the singleton type.) So in case there is some resolution where instead of assuming "singleton type won't be inferred since it never is, so how shall we work around that" we instead said "hey wait a minute, what if allowed ourselves the thrill of inferring the singleton type from time to time..."

@scabug
Copy link
Author

scabug commented Jun 7, 2010

@adriaanm said:
well, we do have [http://lampsvn.epfl.ch/trac/scala/ticket/1208 an open invitation from Martin]

@scabug
Copy link
Author

scabug commented Jun 7, 2010

@paulp said:
Replying to [comment:6 moors]:

well, we do have [http://lampsvn.epfl.ch/trac/scala/ticket/1208 an open invitation from Martin]

Ha ha, that is precisely the invitation I have already accepted, and now I'm seeing what I can do to change the answer.

@scabug
Copy link
Author

scabug commented Jul 8, 2010

@adriaanm said:
(In r22516) closes #3494. don't let type argument for inserted wrapRefArray be inferred (as the expected element type of the array could be a singleton type, but that won't be inferred)

review by prokopec

@scabug scabug closed this as completed May 18, 2011
@scabug scabug added this to the 2.8.1 milestone Apr 7, 2017
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

No branches or pull requests

2 participants