blob: 95194ef0a4535b4bf3908db0ab68a70e96641d3d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package scala.reflect.internal
import org.junit.Assert._
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import scala.tools.nsc.symtab.SymbolTableForUnitTesting
@RunWith(classOf[JUnit4])
class TypesTest {
object symbolTable extends SymbolTableForUnitTesting
import symbolTable._, definitions._
@Test
def testRefinedTypeSI8611(): Unit = {
def stringNarrowed = StringTpe.narrow
assert(stringNarrowed != stringNarrowed)
assert(!(stringNarrowed =:= stringNarrowed))
def boolWithString = refinedType(BooleanTpe :: StringTpe :: Nil, NoSymbol)
assert(boolWithString != boolWithString)
assert(boolWithString =:= boolWithString)
val boolWithString1 = boolWithString
val boolWithString1narrow1 = boolWithString1.narrow
val boolWithString1narrow2 = boolWithString1.narrow
// Two narrowings of the same refinement end up =:=. This was the root
// cause of SI-8611. See `narrowUniquely` in `Logic` for the workaround.
assert(boolWithString1narrow1 =:= boolWithString1narrow2)
val uniquelyNarrowed1 = refinedType(boolWithString1narrow1 :: Nil, NoSymbol)
val uniquelyNarrowed2 = refinedType(boolWithString1narrow2 :: Nil, NoSymbol)
assert(uniquelyNarrowed1 =:= uniquelyNarrowed2)
}
}
|