Closed
Description
Compiler version
3.1.3, 3.2.0-RC1
Minimized code
def foo[T >: Any]: Unit = ()
def bar[T]: Unit = foo[T & Any]
def foo[T >: CharSequence]: Unit = ()
foo[String]
Output
-- [E057] Type Mismatch Error: -------------------------------------------------
1 |def bar[T]: Unit = foo[T & Any]
| ^
| Type argument T & Any does not conform to lower bound Any
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| I tried to show that
| T & Any
| conforms to
| Any
| but the comparison trace ended with `false`:
|
| ==> T & Any <: Any
| <== T & Any <: Any = true
|
| The tests were made under the empty constraint
-----------------------------------------------------------------------------
1 error found
-- [E057] Type Mismatch Error: -------------------------------------------------
1 |foo[String]
| ^
| Type argument String does not conform to lower bound CharSequence
|-----------------------------------------------------------------------------
| Explanation (enabled by `-explain`)
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| I tried to show that
| String
| conforms to
| CharSequence
| but the comparison trace ended with `false`:
|
| ==> String <: CharSequence
| ==> String <: CharSequence
| ==> CharSequence <: CharSequence (left is approximated)
| ==> (java.lang : java.lang.type) <: java.lang.type
| <== (java.lang : java.lang.type) <: java.lang.type = true
| <== CharSequence <: CharSequence (left is approximated) = true
| <== String <: CharSequence = true
| <== String <: CharSequence = true
|
| The tests were made under the empty constraint
-----------------------------------------------------------------------------
1 error found
Expectation
- An explanation that shows
Any <: T & Any = false
. - An explanation that shows
CharSequence <: String = false
.