@@ -16,7 +16,7 @@ private[focus] trait SelectParserBase extends ParserBase {
16
16
val companionObject : Term = Ref (classSymbol.companionModule)
17
17
18
18
private val (typeParams, caseFieldParams :: otherParams) =
19
- classSymbol.primaryConstructor.paramSymss.span(_.head. isTypeParam)
19
+ classSymbol.primaryConstructor.paramSymss.span(_.headOption.fold( false )(_. isTypeParam) )
20
20
val hasOnlyOneCaseField : Boolean = caseFieldParams.length == 1
21
21
val hasOnlyOneParameterList : Boolean = otherParams.isEmpty
22
22
private val nonCaseNonImplicitParameters : List [Symbol ] =
@@ -32,7 +32,10 @@ private[focus] trait SelectParserBase extends ParserBase {
32
32
case None => FocusError .NotACaseField (typeRepr.show, fieldName).asResult
33
33
}
34
34
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
+ }
36
39
}
37
40
38
41
object CaseClassExtractor {
@@ -42,25 +45,19 @@ private[focus] trait SelectParserBase extends ParserBase {
42
45
}
43
46
}
44
47
45
- def getSuppliedTypeArgs (fromType : TypeRepr ): List [TypeRepr ] =
48
+ private def getSuppliedTypeArgs (fromType : TypeRepr ): List [TypeRepr ] =
46
49
fromType match {
47
50
case AppliedType (_, argTypeReprs) => argTypeReprs
48
51
case _ => Nil
49
52
}
50
53
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
-
57
54
private object FieldType {
58
55
def unapply (fieldSymbol : Symbol ): Option [TypeRepr ] = fieldSymbol match {
59
56
case sym if sym.isNoSymbol => None
60
57
case sym =>
61
58
sym.tree match {
62
59
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.
64
61
case DefDef (_, _, typeTree, _) => Some (typeTree.tpe)
65
62
case _ => None
66
63
}
@@ -103,10 +100,8 @@ private[focus] trait SelectParserBase extends ParserBase {
103
100
case success : ImplicitSearchSuccess => Right (success.tree)
104
101
case _ => FocusError .ImplicitNotFound (typeRepr.show).asResult
105
102
}
103
+
106
104
searchForImplicit(t.tpe)
107
- .orElse(searchForImplicit(t.tpe.dealias))
108
- .orElse(searchForImplicit(t.tpe.widen))
109
- .orElse(searchForImplicit(t.tpe.widen.dealias))
110
105
.map(acc :+ _)
111
106
112
107
case (Right (acc), other) =>
0 commit comments