Skip to content

Commit 9850097

Browse files
committed
Allow qualified types without argument name
1 parent 12687ff commit 9850097

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,10 +2280,8 @@ object desugar {
22802280
case PatDef(mods, pats, tpt, rhs) =>
22812281
val pats1 = if (tpt.isEmpty) pats else pats map (Typed(_, tpt))
22822282
flatTree(pats1 map (makePatDef(tree, mods, _, rhs)))
2283-
case QualifiedTypeTree(parent, None, qualifier) =>
2284-
ErrorReporting.errorTree(parent, em"missing parameter name in qualified type", tree.srcPos)
2285-
case QualifiedTypeTree(parent, Some(paramName), qualifier) =>
2286-
qualifiedType(parent, paramName, qualifier, tree.span)
2283+
case QualifiedTypeTree(parent, paramName, qualifier) =>
2284+
qualifiedType(parent, paramName.getOrElse(nme.WILDCARD), qualifier, tree.span)
22872285
case ext: ExtMethods =>
22882286
Block(List(ext), syntheticUnitLiteral.withSpan(ext.span))
22892287
case f: FunctionWithMods if f.hasErasedParams => makeFunctionWithValDefs(f, pt)

tests/printing/qualified-types.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package example {
2020
res:Boolean
2121
}
2222
)
23+
type UninhabitedInt = Int @qualified[Int]((_: Int) => false)
2324
type Nested =
2425
Int @qualified[Int]((x: Int) =>
2526
{

tests/printing/qualified-types.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ type Pos5 = {x: Int with
1515
res
1616
}
1717

18+
type UninhabitedInt = Int with false
19+
1820
type Nested = {x: Int with { val y: {z: Int with z > 0} = ??? ; x > y }}
1921
type Intersection = Int & {x: Int with x > 0}
2022
type ValRefinement = {val x: Int with x > 0}

0 commit comments

Comments
 (0)