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
manifests + intersection types violate val-binding abstraction #4110
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4110?orig=1 |
@adriaanm said: object Test extends Application {
def inferredType[T : Manifest](v : T) = println(manifest[T])
trait A
trait B
inferredType(new A with B)
val name = new A with B
inferredType(name)
} the relevant fragment (abridged) after typer (with -Ydebug -uniqid): inferredType[anonymous class $$anon$$13406]({
final class $$anon$$13406 extends Object with A with B ;
new $$anon$$13406.this()
})(Manifest.classType[anonymous class $$anon$$13406](classOf[Test$$$$<local Test>$$$$anon]));
private[this] val name: Object with A with B{} = {
final class $$anon$$9257 extends Object with A with B ;
new $$anon$$9257.this()
};
inferredType[Object with A with B{}](name)(Manifest.intersectionType[Object with A with B{}](Manifest.Object, Manifest.classType[A](classOf[Test$$$$A]), Manifest.classType[B](classOf[Test$$$$B]))) question: is the symbol $$anon$$13406 supposed to be in scope in inferredType's type argument?? |
@adriaanm said: val res0: Manifest[$$anon$$34941] forSome { type $$anon$$34941 <: Object with A with B{} } =
inferredType[anonymous class $$anon$$34870]({
final class $$anon$$34870 extends Object with A with B
new $$anon$$34870.this()
})(Manifest.classType[anonymous class $$anon$$34870](classOf[line4$$object$$$$$$iw$$$$iw$$res0 $$$$anon])); the RHS is essentially the same as in a full scalac run, but the computed type for res0 is packed to get rid of the reference to the anonymous class Martin, I'm reassigning to you for a hint or two on how to tackle this |
Commit Message Bot (anonymous) said: // Example of code which did not compile, but now does Closes #4110, #3048. I already ran this by moors, so review by odersky. |
=== What steps will reproduce the problem (please be specific and use wikiformatting)? ===
I expect that code such as
func(<expression>)
should always be equivalent to
(in the abscence of call-by-name arguments)
but this can be violated by manifests and intersection types:
=== What is the expected behavior? ===
the manifest that is passed in as an implicit parameter should match the inferred type eg:
=== What do you see instead? ===
A manifest for a anonymous class.
=== Why is this relevant? ===
a Manifest for a anonymous type fails to capture some type system features, eg:
a Manifest for the anonymous class doesn't capture the singleton type
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: