scala type inference doesn't figure out the type information -
i have following 2 test cases:
@test def testtypeinference1(): unit = { def echo[a, b>: a](value: a): b = value println(echo("hello")) } @test def testtypeinference2(): unit = { def headelem[a, l <: list[a]](list: l): = list.head val h = headelem(list(1,2,3)) println(h) }
test case 1 passed test , print "hello",
but when run test case 2, error occurs, complaining that
error:(2013, 17) inferred type arguments [nothing,list[int]] not conform method headelem's type parameter bounds [a,l <: list[a]] val h = headelem(list(1,2,3)) ^
i ask why test case 1 works while test case 2 fails, looking similar me
thanks.
Comments
Post a Comment