Skip to content

Commit 74ff50b

Browse files
committed
Type#isRef: Consider both bounds for HKApply
Otherwise any applied higher-kinded type upper-bounded by Any is considered to be a reference to Any and will be mishandled by methods like lub and glb, see the tests.
1 parent 601432f commit 74ff50b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object Types {
121121
}
122122
case this1: RefinedType if stripRefinements => this1.parent.isRef(sym, stripRefinements)
123123
case this1: RecType => this1.parent.isRef(sym, stripRefinements)
124-
case this1: HKApply => this1.superType.isRef(sym, stripRefinements)
124+
case this1: HKApply => this1.superType.isRef(sym, stripRefinements) && this1.lowerBound.isRef(sym, stripRefinements)
125125
case _ => false
126126
}
127127

tests/neg/isRef.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,10 @@ trait Foo {
55
def b: B
66
def aandb: A & B = b // error: found: B, required: A & B
77
}
8+
9+
trait Foo2 {
10+
type A[_]
11+
type B[_]
12+
def b: B[Int]
13+
def aandb: A[Int] & B[Int] = b // error: found: B[Int], required: A[Int] & B[Int]
14+
}

tests/pos/isRef.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,10 @@ trait Foo {
44
def b: B
55
def aorb: A | B = b
66
}
7+
8+
trait Foo2 {
9+
type A[_]
10+
type B[_]
11+
def b: B[Int]
12+
def aorb: A[Int] | B[Int] = b
13+
}

0 commit comments

Comments
 (0)