File tree 4 files changed +36
-1
lines changed
compiler/src/dotty/tools/dotc/typer
4 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -2301,7 +2301,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
2301
2301
}
2302
2302
2303
2303
def typedRefinedTypeTree (tree : untpd.RefinedTypeTree )(using Context ): TypTree = {
2304
- val tpt1 = if ( tree.tpt.isEmpty) TypeTree (defn.ObjectType ) else typedAheadType(tree.tpt)
2304
+ val tpt1 = if tree.tpt == EmptyTree then TypeTree (defn.ObjectType ) else typedAheadType(tree.tpt)
2305
2305
val refineClsDef = desugar.refinedTypeToClass(tpt1, tree.refinements).withSpan(tree.span)
2306
2306
val refineCls = createSymbol(refineClsDef).asClass
2307
2307
val TypeDef (_, impl : Template ) = typed(refineClsDef): @ unchecked
Original file line number Diff line number Diff line change
1
+ //> using options -language:experimental.modularity -source future
1
2
package hylo
2
3
3
4
import scala .util .Random
Original file line number Diff line number Diff line change
1
+ //> using options -language:experimental.modularity -source future
2
+ infix abstract class TupleOf [T , + A ]:
3
+ type Mapped [+ A ] <: Tuple
4
+ def map [B ](x : T )(f : A => B ): Mapped [B ]
5
+
6
+ object TupleOf :
7
+
8
+ given TupleOf [EmptyTuple , Nothing ] with
9
+ type Mapped [+ A ] = EmptyTuple
10
+ def map [B ](x : EmptyTuple )(f : Nothing => B ): Mapped [B ] = x
11
+
12
+ given [A , Rest <: Tuple ](using tracked val tup : Rest TupleOf A ): TupleOf [A *: Rest , A ] with
13
+ type Mapped [+ A ] = A *: tup.Mapped [A ]
14
+ def map [B ](x : A *: Rest )(f : A => B ): Mapped [B ] =
15
+ (f(x.head) *: tup.map(x.tail)(f))
16
+
17
+ def foo [T ](xs : T )(using tup : T TupleOf Int ): tup.Mapped [Int ] = tup.map(xs)(_ + 1 )
18
+
19
+ @ main def test =
20
+ foo(EmptyTuple ): EmptyTuple // ok
21
+ foo(1 *: EmptyTuple ): Int *: EmptyTuple // now also ok
Original file line number Diff line number Diff line change
1
+ //> using options -language:experimental.modularity -source future
2
+ trait IntWidth :
3
+ type Out
4
+ given IntWidth :
5
+ type Out = 155
6
+
7
+ trait IntCandidate :
8
+ type Out
9
+ given (using tracked val w : IntWidth ) => IntCandidate :
10
+ type Out = w.Out
11
+
12
+ val x = summon[IntCandidate ]
13
+ val xx = summon[x.Out =:= 155 ]
You can’t perform that action at this time.
0 commit comments