Skip to content

Commit 7115bae

Browse files
dwijnandsmarter
authored andcommitted
Fix argDenot, widenDealias before baseType, to get the right type arguments
When looking to select the type member Y on the class Foo, if the prefix is `(a : (([O] =>> Foo[O, S]) @UV)[Int])` then you could say it's correct for the basetype of that type with class Foo to be `(([O] =>> Foo[O, S]) @UV)[Int]`, however if you then try to access the type arguments, it would be incorrect to end up looking at `[Int]`, rather than `[Int, S]`. I went with fixing the input before baseType - the alternative would be to make baseType do the same type constructor dealiasWidening. I also considered making `isArgPrefixOf` return false, but broke a handful of tests, so I went back to argDenot.
1 parent 29e229b commit 7115bae

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ object Types {
24022402

24032403
private def argDenot(param: TypeSymbol)(using Context): Denotation = {
24042404
val cls = param.owner
2405-
val args = prefix.baseType(cls).argInfos
2405+
val args = prefix.widenDealias.baseType(cls).argInfos
24062406
val typeParams = cls.typeParams
24072407

24082408
def concretize(arg: Type, tparam: TypeSymbol) = arg match {

compiler/test/dotc/pos-test-pickling.blacklist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ i15181.scala
2121
i15922.scala
2222
t5031_2.scala
2323
i16997.scala
24+
argDenot-alpakka.scala
2425

2526
# Tree is huge and blows stack for printing Text
2627
i7034.scala

tests/pos/argDenot-alpakka.min.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.annotation.unchecked.uncheckedVariance as uV
2+
3+
trait Test:
4+
def test[S] =
5+
val a: (([O] =>> Foo[O, S]) @uV)[Int] = ???
6+
a.m()
7+
8+
class Foo[X, Y]:
9+
def m(): Y = ???

tests/pos/argDenot-alpakka.scala

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import scala.annotation.unchecked.uncheckedVariance as uV
2+
3+
trait Test:
4+
def split[I, M](in: Flow[I, Byte, M]): SubFlow[Byte, M, in.Repr]
5+
def test =
6+
split(new Flow[Int, Byte, Unit])
7+
.via[Char]
8+
.merge
9+
.filter()
10+
11+
trait FlowOps[+Out, +Mat]:
12+
type Repr[+O] <: FlowOps[O, Mat] { type Repr[+O] = FlowOps.this.Repr[O] }
13+
def via[O]: Repr[O] = ???
14+
def filter(): Repr[Out] = ???
15+
16+
class Flow[-In, +Out, +Mat] extends FlowOps[Out, Mat]:
17+
type Repr[+O] = Flow[In @uV, O, Mat @uV]
18+
19+
class SubFlow[+Out, +Mat, +F[+_]] extends FlowOps[Out, Mat]:
20+
type Repr[+O] = SubFlow[O, Mat @uV, F @uV]
21+
def merge: F[Out] = ???

0 commit comments

Comments
 (0)