-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize match type usage during implicit lookup (#17457)
- Loading branch information
Showing
4 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
trait TC[T] | ||
|
||
object TC { | ||
def optionTCForPart[T](implicit tc: TC[ExtractPart[T]]): TC[Option[ExtractPart[T]]] = new TC[Option[ExtractPart[T]]] {} | ||
} | ||
|
||
type ExtractPart[T] = T match { | ||
case PartField[t] => t | ||
} | ||
type PartField[T] = Any { type Part = T } | ||
|
||
class ValuePartHolder { | ||
type Part = Value | ||
} | ||
|
||
class Value | ||
object Value { | ||
implicit val tcValue: TC[Value] = new {} | ||
} | ||
|
||
@main def main(): Unit = { | ||
// import Value.tcValue // explicit import works around the issue, but shouldn't be necessary | ||
val tc = TC.optionTCForPart[ValuePartHolder] | ||
println(tc) | ||
} |