File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -1002,6 +1002,12 @@ object Types {
1002
1002
case _ => this
1003
1003
}
1004
1004
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
+
1005
1011
/** Widen type if it is unstable (i.e. an ExprType, or TermRef to unstable symbol */
1006
1012
final def widenIfUnstable (implicit ctx : Context ): Type = stripTypeVar match {
1007
1013
case tp : ExprType => tp.resultType.widenIfUnstable
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ object ProtoTypes {
38
38
* 4. `tp` is a numeric subtype of `pt` (this case applies even if implicit conversions are disabled)
39
39
*/
40
40
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)
42
42
43
43
/** Test compatibility after normalization in a fresh typerstate. */
44
44
def normalizedCompatible (tp : Type , pt : Type )(implicit ctx : Context ) =
Original file line number Diff line number Diff line change @@ -25,8 +25,8 @@ object Test {
25
25
}
26
26
27
27
// 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 )
30
30
// def f3(x: String): 1 = test(x)
31
31
test2(1 ): " a"
32
32
test2(2 ): " b"
You can’t perform that action at this time.
0 commit comments