Skip to content

Commit 4b3dbd9

Browse files
retronymadriaanm
authored andcommitted
SI-8219 Pending test case for unpositioned implicit error
Extracted with tweezers from ScalaTest and Scalacheck implicits. % scalac-hash v2.11.0-M7 test/pending/pos/t8219.scala error: type mismatch; found : Any required: AnyRef Note: Any is not implicitly converted to AnyRef. You can safely pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so. error: type mismatch; found : Any required: AnyRef Note: Any is not implicitly converted to AnyRef. You can safely pattern match `x: AnyRef` or cast `x.asInstanceOf[AnyRef]` to do so. two errors found
1 parent 90aa12e commit 4b3dbd9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/pending/pos/t8219.scala

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
trait Equalizer[T]
2+
trait Gen[A]
3+
4+
class Broken {
5+
implicit def const[T](x: T): Gen[T] = ???
6+
implicit def convertToEqualizer[T](left: T): Equalizer[T] = ???
7+
8+
def in(a: Any) = ()
9+
in {
10+
import scala.None // any import will do..
11+
"" == ""
12+
}
13+
14+
// We fall into the errant code path above because `Any#==` and `AnyRef#==`
15+
// are (currently) overloaded.
16+
//
17+
// Real classes couldn't get away with that overloading; it would result in
18+
// a compiler error because the variants would collapse into an overriding
19+
// relationship after erasure.
20+
//
21+
//
22+
// But, a structural type can! This triggers the same error, and served as
23+
// a backstop for this test if we change the signatures of `AnyRef#==` to
24+
// override `Any#==`.
25+
type T = {
26+
def a(a: AnyRef): Boolean
27+
def a(a: Any): Boolean
28+
}
29+
30+
def t: T = ???
31+
32+
in {
33+
import scala.None // any import will do..
34+
t.a("")
35+
}
36+
}

0 commit comments

Comments
 (0)