@@ -16,7 +16,7 @@ private[focus] trait SelectParserBase extends ParserBase {
1616 val companionObject : Term = Ref (classSymbol.companionModule)
1717
1818 private val (typeParams, caseFieldParams :: otherParams) =
19- classSymbol.primaryConstructor.paramSymss.span(_.head. isTypeParam)
19+ classSymbol.primaryConstructor.paramSymss.span(_.headOption.fold( false )(_. isTypeParam) )
2020 val hasOnlyOneCaseField : Boolean = caseFieldParams.length == 1
2121 val hasOnlyOneParameterList : Boolean = otherParams.isEmpty
2222 private val nonCaseNonImplicitParameters : List [Symbol ] =
@@ -32,7 +32,10 @@ private[focus] trait SelectParserBase extends ParserBase {
3232 case None => FocusError .NotACaseField (typeRepr.show, fieldName).asResult
3333 }
3434 def getCaseFieldType (caseFieldSymbol : Symbol ): FocusResult [TypeRepr ] =
35- getFieldType(typeRepr, caseFieldSymbol)
35+ caseFieldSymbol match {
36+ case FieldType (possiblyTypeArg) => Right (swapWithSuppliedType(typeRepr, possiblyTypeArg))
37+ case _ => FocusError .CouldntFindFieldType (typeRepr.show, caseFieldSymbol.name).asResult
38+ }
3639 }
3740
3841 object CaseClassExtractor {
@@ -42,25 +45,19 @@ private[focus] trait SelectParserBase extends ParserBase {
4245 }
4346 }
4447
45- def getSuppliedTypeArgs (fromType : TypeRepr ): List [TypeRepr ] =
48+ private def getSuppliedTypeArgs (fromType : TypeRepr ): List [TypeRepr ] =
4649 fromType match {
4750 case AppliedType (_, argTypeReprs) => argTypeReprs
4851 case _ => Nil
4952 }
5053
51- def getFieldType (fromType : TypeRepr , caseFieldSymbol : Symbol ): FocusResult [TypeRepr ] =
52- caseFieldSymbol match {
53- case FieldType (possiblyTypeArg) => Right (swapWithSuppliedType(fromType, possiblyTypeArg))
54- case _ => FocusError .CouldntFindFieldType (fromType.show, caseFieldSymbol.name).asResult
55- }
56-
5754 private object FieldType {
5855 def unapply (fieldSymbol : Symbol ): Option [TypeRepr ] = fieldSymbol match {
5956 case sym if sym.isNoSymbol => None
6057 case sym =>
6158 sym.tree match {
6259 case ValDef (_, typeTree, _) => Some (typeTree.tpe)
63- // Only needed for Tuples because `_1` is a DefDef while `_1 ` is a ValDef.
60+ // Only needed for Tuples because `_1` is a DefDef while `_1 ` is the corresponding ValDef.
6461 case DefDef (_, _, typeTree, _) => Some (typeTree.tpe)
6562 case _ => None
6663 }
@@ -100,13 +97,13 @@ private[focus] trait SelectParserBase extends ParserBase {
10097 case (Right (acc), ValDef (_, t, _)) =>
10198 def searchForImplicit (typeRepr : TypeRepr ): FocusResult [Term ] =
10299 Implicits .search(typeRepr) match {
103- case success : ImplicitSearchSuccess => Right (success.tree)
104- case _ => FocusError .ImplicitNotFound (typeRepr.show).asResult
100+ case success : ImplicitSearchSuccess =>
101+ Right (success.tree)
102+ case failure : ImplicitSearchFailure =>
103+ FocusError .ImplicitNotFound (typeRepr.show, failure.explanation).asResult
105104 }
105+
106106 searchForImplicit(t.tpe)
107- .orElse(searchForImplicit(t.tpe.dealias))
108- .orElse(searchForImplicit(t.tpe.widen))
109- .orElse(searchForImplicit(t.tpe.widen.dealias))
110107 .map(acc :+ _)
111108
112109 case (Right (acc), other) =>
0 commit comments