Details

Type: Bug

Status: Open

Priority: Critical

Resolution: Unresolved

Affects Version/s: Scala 2.9.01

Fix Version/s: Backlog

Component/s: Type Inference

Labels:None
Description
class Contra[T] trait A trait B extends A trait C extends B def contraLBUB[a >: C <: A](): Contra[a] = null def contraLB[a >: C](): Contra[a] = null contraLBUB() //inferred Contra[C] instead of Contra[A] contraLB() //inferred Contra[C] instead of Contra[Any]
According to Language specification (6.26.4 Case 2):
If several substitutions exist,
localtype inference will choose for each type variable ai a minimal or maximal type
Ti of the solution space. A maximal type Ti will be chosen if the type parameter ai
appears contravariantly (§4.5) in the type T of the expression. A minimal type Ti
will be chosen in all other situations, i.e. if the variable appears covariantly, nonvariantly
or not at all in the type T.
What we can see here. Value has Type Contra[a]. So position of a is contravariant. There is no covariant or invariant positions of a => maximal solution should be chosen.
Issue Links
 relates to

SI6311 Critical: regression in type inference since 2.10.0M6 with too many arguments lists
 Closed
Actually, it works as expected as a Value (Case 2)
So the question is, does "Case 3: Methods" explain these?