Skip to content

Commit a70cb46

Browse files
authored
Help givens return refined types (#16293)
2 parents ff34bf9 + 570835d commit a70cb46

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3807,7 +3807,7 @@ object Parsers {
38073807
if !(name.isEmpty && noParams) then acceptColon()
38083808
val parents =
38093809
if isSimpleLiteral then rejectWildcardType(annotType()) :: Nil
3810-
else constrApp() :: withConstrApps()
3810+
else refinedTypeRest(constrApp()) :: withConstrApps()
38113811
val parentsIsType = parents.length == 1 && parents.head.isType
38123812
if in.token == EQUALS && parentsIsType then
38133813
accept(EQUALS)

tests/pos/i7045.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Bar { type Y }
2+
trait Foo { type X }
3+
4+
class Test:
5+
given a1(using b: Bar): Foo = new Foo { type X = b.Y }
6+
7+
given a2(using b: Bar): Foo { type X = b.Y } = new Foo { type X = b.Y }
8+
9+
given a3(using b: Bar): (Foo { type X = b.Y }) = new Foo { type X = b.Y }

0 commit comments

Comments
 (0)