-
Notifications
You must be signed in to change notification settings - Fork 21
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
TypeVars can't specialize Scope declarations #10506
Labels
fixed in Scala 3
This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
typelevel
Milestone
Comments
Somewhat related to #9770. |
@milessabin I don't know about that. But here is how to reproduce inconsistencies in the subtype relation involving type variables: import scala.reflect.runtime
val universe = runtime.universe.asInstanceOf[runtime.JavaUniverse]
import universe._
val tvar = TypeVar(symbolOf[Set[Any]].typeParams.head)
val struct = typeOf[{ def i: Int }]
val pat = refinedType(tvar :: typeOf[Serializable] :: Nil, NoSymbol)
val tpe = refinedType(struct :: typeOf[Serializable] :: Nil, NoSymbol)
println(tvar =:= struct) // true
println(tvar.constr) // _= AnyRef{def i: Int}
println(tpe =:= pat) // true
println(tpe <:< pat) // true
println(pat <:< tpe) // false
println(pat <:< struct) // false
println(tvar <:< struct) // true
println(tvar.member(TermName("i"))) // <none>
println(tvar.inst.member(TermName("i"))) // method i |
joroKr21
changed the title
Weird inconsistencies involving implicit resolution, refinement types and type aliases
TypeVars can't specialize Scope declarations
Jan 13, 2018
Further minimization: object Test {
type Parent
type Scope = { val x: Int }
implicit def refined[A]: Parent with A = ???
implicitly[Parent with Int] // ok
implicitly[Parent with Scope] // missing
} A leaky abstraction: |
joroKr21
added
the
fixed in Scala 3
This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
label
Jan 6, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
fixed in Scala 3
This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)
typelevel
Below are a few examples involving type aliases and refinement types that show how among several equivalent types, some can be resolved implicitly while others cannot.
I looked more closely into (1).
-Xlog-implicits
reports:Further debugging reveals that at some point implicit resolution checks if the types below are compatible:
Strangely enough though:
Intuitively I would expect
A =:= B
to implyA <:< B
. But I'm not sure what role type variables play here.Scala version: 2.12.3
Java version: Oracle 1.8.0_144
The text was updated successfully, but these errors were encountered: