File tree 2 files changed +35
-0
lines changed
compiler/src/dotty/tools/dotc/core
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,15 @@ object TypeEval:
111
111
nestedPairs(fieldLabels) :: nestedPairs(fieldTypes) :: Nil
112
112
else arg.widenDealias match
113
113
case arg @ defn.NamedTuple (_, _) => Some (arg)
114
+ case arg if arg.derivesFrom(defn.TupleClass ) =>
115
+ val fieldTypesOpt = tupleElementTypes(arg)
116
+ fieldTypesOpt match
117
+ case Some (fieldTypes) =>
118
+ val fieldLabels = (for i <- 1 to fieldTypes.length yield ConstantType (Constant (s " _ $i" ))).toList
119
+ Some :
120
+ defn.NamedTupleTypeRef .appliedTo:
121
+ nestedPairs(fieldLabels) :: nestedPairs(fieldTypes) :: Nil
122
+ case _ => None
114
123
case _ => None
115
124
116
125
def constantFold1 [T ](extractor : Type => Option [T ], op : T => Any ): Option [Type ] =
Original file line number Diff line number Diff line change
1
+ //> using options -experimental -language:experimental.namedTuples
2
+ import language .experimental .namedTuples
3
+
4
+ type Foo [T ] = T
5
+ val x : NamedTuple .From [Tuple .Map [(Int , Int ), Foo ]] = ???
6
+ val res = x._1
7
+
8
+ type Z = NamedTuple .From [(Foo [Int ], Foo [Int ])]
9
+ val x2 : Z = ???
10
+ val res2 = x2._1
11
+
12
+ val x3 : Foo [NamedTuple .From [Tuple .Map [(Int , Int ), Foo ]]] = ???
13
+ val res3 = x3._1
14
+
15
+ def foo [T <: (Int , String )](tup : T ): Int =
16
+ tup._1
17
+
18
+ def union [T ](tup : (Int , String )
19
+ | (Int , String )
20
+ ): Int =
21
+ tup._1
22
+
23
+ def intersect [T ](tup : (Int , String )
24
+ & T
25
+ ): Int =
26
+ tup._1
You can’t perform that action at this time.
0 commit comments