@@ -41,27 +41,47 @@ class ResolveTypes(specs: ClassSpecs, topClass: ClassSpec, opaqueTypes: Boolean)
4141 }
4242
4343 def resolveUserTypeForMember (curClass : ClassSpec , attr : MemberSpec ): Iterable [CompilationProblem ] =
44- resolveUserType(curClass, attr.dataType, attr.path)
44+ resolveUserType(curClass, attr.dataType, attr.path, None )
4545
46- def resolveUserType (curClass : ClassSpec , dataType : DataType , path : List [String ]): Iterable [CompilationProblem ] = {
46+ /**
47+ * Resolves the type of the `dataType` of an attribute defined in `curClass`.
48+ *
49+ * @param curClass The owner of attribute which type is being resolved
50+ * @param dataType The type of the attribute being resolved
51+ * @param path YAML path to the attribute where diagnostics should bу reported
52+ * @param caseExpr If attribute type is switchable type then contains the specific case name
53+ */
54+ def resolveUserType (
55+ curClass : ClassSpec ,
56+ dataType : DataType ,
57+ path : List [String ],
58+ caseExpr : Option [String ],
59+ ): Iterable [CompilationProblem ] = {
4760 dataType match {
4861 case ut : UserType =>
49- val (resClassSpec, problems) = resolveUserType(curClass, ut.name, path ++ List (" type" ))
62+ val (resClassSpec, problems) = resolveUserType(
63+ curClass,
64+ ut.name,
65+ caseExpr match {
66+ case Some (case_) => path ++ List (" type" , " cases" , case_)
67+ case None => path :+ " type"
68+ }
69+ )
5070 ut.classSpec = resClassSpec
5171 problems
5272 case et : EnumType =>
5373 et.enumSpec = resolveEnumSpec(curClass, et.name)
5474 if (et.enumSpec.isEmpty) {
55- Some (EnumNotFoundErr (et.name, curClass, path ++ List ( " enum" ) ))
75+ Some (EnumNotFoundErr (et.name, curClass, path :+ " enum" ))
5676 } else {
5777 None
5878 }
5979 case st : SwitchType =>
6080 st.cases.flatMap { case (caseName, ut) =>
61- resolveUserType(curClass, ut, path ++ List ( " type " , " cases " , caseName.toString))
81+ resolveUserType(curClass, ut, path, Some ( caseName.toString))
6282 }
6383 case at : ArrayType =>
64- resolveUserType(curClass, at.elType, path)
84+ resolveUserType(curClass, at.elType, path, caseExpr )
6585 case _ =>
6686 // not a user type, nothing to resolve
6787 None
0 commit comments