-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Special handling in the typer of scala.Singleton is missing #2997
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
Comments
I don't think this has anything to do with class fields, it's just that Dotty doesn't know anything about the |
Even without the object Test {
val one = 1
final val final_one = 1
object OK {
def foo[T <: Int](t : T) : T = t
val a : 1 = foo(1)
val b : Int = foo(one)
val c : 1 = foo(final_one)
}
object Fail {
case class Foo[T <: Int](t : T)
val a : 1 = Foo(1).t //Error: Type mismatch
val b : Int = Foo(one).t
val c : 1 = Foo(final_one).t //Error: Type mismatch
}
} |
Ah, that's interesting, still not specific to class fields though :). |
See #2998 |
OK, thanks! |
When interpolating type variables we should use all available information at this point, including the expected result type. One situation where this makes a difference is if the expected type is a singleton type, because type variables are instantiated to singleton types only if their upper bounds are singleton types. Also fixes scala#2997.
When interpolating type variables we should use all available information at this point, including the expected result type. One situation where this makes a difference is if the expected type is a singleton type, because type variables are instantiated to singleton types only if their upper bounds are singleton types. Also fixes scala#2997.
Uh oh!
There was an error while loading. Please reload this page.
Scastie link: https://scastie.scala-lang.org/DcDeG4eYQTG17exjb2FigQ
The text was updated successfully, but these errors were encountered: