Skip to content

Commit d52aff0

Browse files
committed
Fix desugaring of fields with qualified types
1 parent 69f55ad commit d52aff0

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,11 @@ object desugar {
213213
def valDef(vdef0: ValDef)(using Context): Tree =
214214
val vdef @ ValDef(_, tpt, rhs) = vdef0
215215
val valName = normalizeName(vdef, tpt).asTermName
216-
val tpt1 = desugarQualifiedTypes(tpt, valName)
216+
val tpt1 =
217+
if Feature.qualifiedTypesEnabled then
218+
desugarQualifiedTypes(tpt, valName)
219+
else
220+
tpt
217221
var mods1 = vdef.mods
218222

219223
val vdef1 = cpy.ValDef(vdef)(name = valName, tpt = tpt1).withMods(mods1)
@@ -747,7 +751,11 @@ object desugar {
747751
report.error(CaseClassMissingNonImplicitParamList(cdef), namePos)
748752
ListOfNil
749753
}
750-
else originalVparamss.nestedMap(toMethParam(_, KeepAnnotations.All, keepDefault = true))
754+
else
755+
originalVparamss.nestedMap: param =>
756+
val methParam = toMethParam(param, KeepAnnotations.All, keepDefault = true)
757+
valDef(methParam).asInstanceOf[ValDef] // desugar early to handle qualified types
758+
751759
val derivedTparams =
752760
constrTparams.zipWithConserve(impliedTparams)((tparam, impliedParam) =>
753761
derivedTypeParam(tparam).withAnnotations(impliedParam.mods.annotations))
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
/*class foo(elem: Int with elem > 0)*/
1+
class foo(elem: Int with elem > 0)
2+
3+
class Multi(x: Int with x > 0)(y: String with y.length > 2, z: Double with z >= 0.0)
4+
5+
case class MultiCase(x: Int with x > 0)(val y: String with y.length > 2, val z: Double with z >= 0.0)
26

37
@main def Test = ()

0 commit comments

Comments
 (0)