File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
src/main/scala/com/thoughtworks/each Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -131,9 +131,18 @@ object Monadic {
131
131
val eachMethodSymbol = expectedEachOpsType.member(TermName (" each" ))
132
132
133
133
override val eachExtractor : PartialFunction [Tree , Tree ] = {
134
- case eachMethodTree@ Select (eachOpsTree, _)
135
- if eachMethodTree.symbol == eachMethodSymbol &&
136
- appliedType(eachOpsTree.tpe.typeArgs(0 ), List (eachMethodTree.tpe)) <:< appliedType(fType, List (eachMethodTree.tpe)) => {
134
+ case eachMethodTree@ Select (eachOpsTree, _) if eachMethodTree.symbol == eachMethodSymbol => {
135
+ val actualFType = eachOpsTree.tpe.typeArgs(0 )
136
+ val resultType = eachMethodTree.tpe
137
+ val expectedType = appliedType(fType, List (resultType))
138
+ val actualType = appliedType(actualFType, List (resultType))
139
+ if (! (actualType <:< expectedType)) {
140
+ c.error(
141
+ eachOpsTree.pos,
142
+ raw """ type mismatch;
143
+ found : ${show(actualType)}
144
+ required: ${show(expectedType)}""" )
145
+ }
137
146
Select (eachOpsTree, TermName (" underlying" ))
138
147
}
139
148
}
You can’t perform that action at this time.
0 commit comments