File tree 4 files changed +46
-6
lines changed
src/dotty/tools/dotc/typer
4 files changed +46
-6
lines changed Original file line number Diff line number Diff line change @@ -99,8 +99,23 @@ object Inferencing {
99
99
&& tvar.hasLowerBound =>
100
100
tvar.instantiate(fromBelow = true )
101
101
true
102
- case AppliedType (tycon, _) =>
102
+ case AppliedType (tycon, args) =>
103
+ // The argument in `args` that may potentially appear directly as result
104
+ // and thereby influence the members of this type
105
+ def argsInResult : List [Type ] = tycon match
106
+ case tycon : TypeRef =>
107
+ tycon.info match
108
+ case MatchAlias (_) => args
109
+ case TypeBounds (_, upper : TypeLambda ) =>
110
+ upper.resultType match
111
+ case ref : TypeParamRef if ref.binder == upper =>
112
+ args.lazyZip(upper.paramRefs).collect {
113
+ case (arg, pref) if pref eq ref => arg
114
+ }.toList
115
+ case _ => Nil
116
+ case _ => Nil
103
117
couldInstantiateTypeVar(tycon)
118
+ || argsInResult.exists(couldInstantiateTypeVar)
104
119
case RefinedType (parent, _, _) =>
105
120
couldInstantiateTypeVar(parent)
106
121
case tp : AndOrType =>
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ i7868.scala
32
32
i7872.scala
33
33
6709.scala
34
34
6687.scala
35
+ i11236.scala
35
36
36
37
# Opaque type
37
38
i5720.scala
Original file line number Diff line number Diff line change
1
+ class Test {
2
+ val tup : Char #: Int #: String #: TupleK = ???
3
+ val x : String #: TupleK = (tup.tail: Int #: String #: TupleK ).tail
4
+ val a = tup.tail
5
+ val b = a.tail
6
+ val y : String #: TupleK = tup.tail.tail
7
+ val z : Unit = tup.tail.tail
8
+ }
9
+
10
+ trait TupleK
11
+
12
+ object TupleK {
13
+ type Tail [X <: NonEmptyTupleK ] <: TupleK = X match {
14
+ case _ #: xs => xs
15
+ }
16
+ }
17
+
18
+ trait NonEmptyTupleK extends TupleK {
19
+ /* inline*/ def tail [This >: this .type <: NonEmptyTupleK ]: TupleK .Tail [This ] = ???
20
+ }
21
+
22
+ abstract class #: [+ H , + T <: TupleK ] extends NonEmptyTupleK
Original file line number Diff line number Diff line change 2
2
// val x: Int => Int = identity
3
3
// }
4
4
5
- trait Foo [F [_]] {
5
+ trait Foo [F [_], I [X ] <: X ] {
6
+ type Id [X ] <: X
6
7
def foo [G [x] >: F [x]]: G [Unit ]
8
+ def foo2 [X >: F [String ]]: Id [X ]
9
+ def foo3 [X >: F [String ]]: I [X ]
7
10
}
8
11
9
12
trait M [A ] {
@@ -12,11 +15,10 @@ trait M[A] {
12
15
}
13
16
14
17
object Test {
15
- def bar (x : Foo [M ]): Unit = {
16
- // error: value bla is not a member of G[Unit], where: G is a type variable with constraint >: M and <: [x] =>> Any
18
+ def bar (x : Foo [M , [X ] =>> X ]): Unit = {
17
19
x.foo.bla
18
-
19
- // error: value bla is not a member of G[Unit], where: G is a type variable with constraint >: M and <: [x] =>> Any
20
20
x.foo.baz(x => x)
21
+ x.foo2.bla
22
+ x.foo3.bla
21
23
}
22
24
}
You can’t perform that action at this time.
0 commit comments