Skip to content

Commit df78f76

Browse files
committed
Merge pull request #1758 from hubertp/2.10.x-issue/strip-tvars
When we strip tvars we should also recursively strip their instantiation...
2 parents 7968f93 + 24455e2 commit df78f76

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/reflect/scala/reflect/internal/Types.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6605,11 +6605,11 @@ trait Types extends api.Types { self: SymbolTable =>
66056605
case ExistentialType(qs, _) => qs
66066606
case t => List()
66076607
}
6608-
def stripType(tp: Type) = tp match {
6608+
def stripType(tp: Type): Type = tp match {
66096609
case ExistentialType(_, res) =>
66106610
res
66116611
case tv@TypeVar(_, constr) =>
6612-
if (tv.instValid) constr.inst
6612+
if (tv.instValid) stripType(constr.inst)
66136613
else if (tv.untouchable) tv
66146614
else abort("trying to do lub/glb of typevar "+tp)
66156615
case t => t
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
object Test {
2+
3+
implicit final class EqualOps[T](val x: T) extends AnyVal {
4+
def ===[T1, Ph >: T <: T1, Ph2 >: Ph <: T1](other: T1): Boolean = x == other
5+
def !!![T1, Ph2 >: Ph <: T1, Ph >: T <: T1](other: T1): Boolean = x == other
6+
}
7+
8+
class A
9+
class B extends A
10+
class C extends A
11+
12+
val a = new A
13+
val b = new B
14+
val c = new C
15+
16+
val x1 = a === b
17+
val x2 = b === a
18+
val x3 = b === c // error, infers Object{} for T1
19+
val x4 = b.===[A, B, B](c)
20+
21+
val x5 = b !!! c // always compiled due to the order of Ph2 and Ph
22+
23+
24+
25+
}

0 commit comments

Comments
 (0)