|
1 | 1 | package dotty.tools
|
2 |
| -package dotc.core |
| 2 | +package dotc |
| 3 | +package core |
3 | 4 |
|
4 | 5 | import vulpix.TestConfiguration
|
5 | 6 |
|
6 |
| -import dotty.tools.dotc.core.Contexts.{*, given} |
7 |
| -import dotty.tools.dotc.core.Decorators.{*, given} |
8 |
| -import dotty.tools.dotc.core.Symbols.* |
9 |
| -import dotty.tools.dotc.core.Types.* |
10 |
| -import dotty.tools.dotc.ast.tpd.* |
11 |
| -import dotty.tools.dotc.typer.ProtoTypes.constrained |
| 7 | +import Contexts.{*, given}, Decorators.{*, given}, Symbols.*, Types.* |
| 8 | +import ast.tpd.* |
| 9 | +import typer.ProtoTypes.* |
| 10 | +import util.SimpleIdentitySet |
12 | 11 |
|
13 | 12 | import org.junit.Test
|
14 | 13 |
|
15 |
| -import dotty.tools.DottyTest |
16 |
| - |
17 | 14 | class ConstraintsTest:
|
18 | 15 |
|
19 | 16 | @Test def mergeParamsTransitivity: Unit =
|
@@ -91,3 +88,19 @@ class ConstraintsTest:
|
91 | 88 | assert(!ctx.typerState.constraint.occursAtToplevel(tvar.origin, entry),
|
92 | 89 | i"cyclic bound for ${tvar.origin}: ${entry} in ${ctx.typerState.constraint}")
|
93 | 90 | }
|
| 91 | + |
| 92 | + @Test def splitIntersectedBounds: Unit = inCompilerContext(TestConfiguration.basicClasspath) { |
| 93 | + val Foo = newTypeVar(TypeBounds.empty, "Foo".toTypeName) |
| 94 | + val Bar = newTypeVar(TypeBounds.empty, "Bar".toTypeName) |
| 95 | + val Int = defn.IntType |
| 96 | + |
| 97 | + val tp1 = Foo & Int |
| 98 | + val tp2 = Bar & Int |
| 99 | + val log = TypeComparer.explained(_.isSameType(tp1, tp2)) |
| 100 | + //println(i"$log") |
| 101 | + //println(i"${ctx.typerState.constraint}") |
| 102 | + |
| 103 | + val tree = ref(newAnonFun(defn.RootClass, MethodType(Nil, defn.UnitType))).appliedToNone |
| 104 | + ctx.typer.interpolateTypeVars(tree, WildcardType, SimpleIdentitySet.empty) |
| 105 | + assert(Foo =:= Int && Bar =:= Int, i"Foo=$Foo Bar=$Bar") |
| 106 | + } |
0 commit comments