Skip to content

Commit 9b4552b

Browse files
Add widenTypeOf in ProtoType; fix applyOverloaded
1 parent bd33ca9 commit 9b4552b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,12 @@ object Types {
10021002
case _ => this
10031003
}
10041004

1005+
/** Widen from TypeOf type to its underlying type. */
1006+
final def widenTypeOf: Type = this match {
1007+
case tp: TypeOf => tp.underlyingTp
1008+
case _ => this
1009+
}
1010+
10051011
/** Widen type if it is unstable (i.e. an ExprType, or TermRef to unstable symbol */
10061012
final def widenIfUnstable(implicit ctx: Context): Type = stripTypeVar match {
10071013
case tp: ExprType => tp.resultType.widenIfUnstable

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object ProtoTypes {
3838
* 4. `tp` is a numeric subtype of `pt` (this case applies even if implicit conversions are disabled)
3939
*/
4040
def isCompatible(tp: Type, pt: Type)(implicit ctx: Context): Boolean =
41-
(tp.widenExpr relaxed_<:< pt.widenExpr) || viewExists(tp, pt)
41+
(tp.widenExpr.widenTypeOf relaxed_<:< pt.widenExpr.widenTypeOf) || viewExists(tp, pt)
4242

4343
/** Test compatibility after normalization in a fresh typerstate. */
4444
def normalizedCompatible(tp: Type, pt: Type)(implicit ctx: Context) =

tests/neg/dependent-match.scala renamed to tests/pos/dependent-match.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ object Test {
2525
}
2626

2727
// def f1[T <: Foo](t: T): "a" = test(t) // Do we want this?
28-
//def f1[T <: Foo](t: T): Any = test(t)
29-
def f2(x: Foo): "a" = test(x, 123) // error: matches are not supported yet
28+
// def f1[T <: Foo](t: T): Any = test(t)
29+
def f2(x: Foo): "a" = test(x, 123)
3030
// def f3(x: String): 1 = test(x)
3131
test2(1): "a"
3232
test2(2): "b"

0 commit comments

Comments
 (0)