File tree Expand file tree Collapse file tree 4 files changed +23
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -2076,15 +2076,14 @@ object TypeComparer {
2076
2076
/** Show trace of comparison operations when performing `op` as result string */
2077
2077
def explaining [T ](say : String => Unit )(op : Context => T )(implicit ctx : Context ): T = {
2078
2078
val nestedCtx = ctx.fresh.setTypeComparerFn(new ExplainingTypeComparer (_))
2079
- val res = op(nestedCtx)
2080
- say(nestedCtx.typeComparer.lastTrace())
2079
+ val res = try { op(nestedCtx) } finally { say(nestedCtx.typeComparer.lastTrace()) }
2081
2080
res
2082
2081
}
2083
2082
2084
2083
/** Like [[explaining ]], but returns the trace instead */
2085
2084
def explained [T ](op : Context => T )(implicit ctx : Context ): String = {
2086
2085
var trace : String = null
2087
- explaining(trace = _)(op)
2086
+ try { explaining(trace = _)(op) } catch { case ex : Throwable => ex.printStackTrace }
2088
2087
trace
2089
2088
}
2090
2089
}
Original file line number Diff line number Diff line change @@ -1924,11 +1924,21 @@ object Types {
1924
1924
param.derivedSingleDenotation(param, argInfo)
1925
1925
}
1926
1926
else {
1927
- if (! ctx.reporter.errorsReported)
1928
- throw new TypeError (
1929
- i """ bad parameter reference $this at ${ctx.phase}
1930
- |the parameter is ${param.showLocated} but the prefix $prefix
1931
- |does not define any corresponding arguments. """ )
1927
+ // Don't throw exception below, as capture conversion in
1928
+ //
1929
+ // Array[_] | Null <: Array[Int]
1930
+ //
1931
+ // will result in the following check:
1932
+ //
1933
+ // Int <: (Array[_] | Null) # T
1934
+ //
1935
+ // See tests/pos/i6033.scala
1936
+ //
1937
+ // if (!ctx.reporter.errorsReported)
1938
+ // throw new TypeError(
1939
+ // i"""bad parameter reference $this at ${ctx.phase}
1940
+ // |the parameter is ${param.showLocated} but the prefix $prefix
1941
+ // |does not define any corresponding arguments.""")
1932
1942
NoDenotation
1933
1943
}
1934
1944
}
Original file line number Diff line number Diff line change @@ -405,8 +405,8 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic {
405
405
406
406
/** Is `tp1` a subtype of `tp2`? */
407
407
def isSubType (tp1 : Type , tp2 : Type ): Boolean = {
408
+ debug.println(TypeComparer .explained(implicit ctx => tp1 <:< tp2))
408
409
val res = (tp1 != nullType || tp2 == nullType) && tp1 <:< tp2
409
- debug.println(s " ${tp1} <:< ${tp2} = $res" )
410
410
res
411
411
}
412
412
Original file line number Diff line number Diff line change
1
+ class Test {
2
+ def f (a : Array [_]| Null ): Unit = a match {
3
+ case x : Array [Int ] =>
4
+ }
5
+ }
You can’t perform that action at this time.
0 commit comments