Skip to content

Commit

Permalink
Make TreeChecker happy
Browse files Browse the repository at this point in the history
The failure comes from the tree checker, due to a limitation in subtyping checker:

```
dotty.tools.dotc.transform.init.Semantic.Hot.type
| (dotty.tools.dotc.transform.init.Semantic.Hot.type
|  dotty.tools.dotc.transform.init.Semantic.Cold.type )

<:

dotty.tools.dotc.transform.init.Semantic.Hot.type
| dotty.tools.dotc.transform.init.Semantic.Cold.type

= false
```
  • Loading branch information
liufengyun committed May 23, 2022
1 parent c1b83f6 commit efb9776
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions compiler/src/dotty/tools/dotc/transform/init/Semantic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -422,11 +422,10 @@ object Semantic {

/** Stop on first found error */
def stopEarly(fn: Reporter ?=> Unit): List[Error] =
// use promotion reporter to stop the analysis on the first error
val promotionReporter: Reporter = new StopEarlyReporter
val reporter: Reporter = new StopEarlyReporter

try
fn(using promotionReporter)
fn(using reporter)
Nil
catch case ex: ErrorFound =>
ex.error :: Nil
Expand Down Expand Up @@ -629,7 +628,7 @@ object Semantic {
case typeParamRef: TypeParamRef =>
val bounds = typeParamRef.underlying.bounds
val isWithinBounds = bounds.lo <:< defn.NothingType && defn.AnyType <:< bounds.hi
def otherParamContains = allParamTypes.exists { param => param != info && param.typeSymbol != defn.ClassTagClass && info.occursIn(param) }
def otherParamContains = allParamTypes.exists { param => param != typeParamRef && param.typeSymbol != defn.ClassTagClass && typeParamRef.occursIn(param) }
// A non-hot method argument is allowed if the corresponding parameter type is a
// type parameter T with Any as its upper bound and Nothing as its lower bound.
// the other arguments should either correspond to a parameter type that is T
Expand All @@ -652,12 +651,12 @@ object Semantic {
if receiver.typeSymbol.isStaticOwner then
val (errors, allArgsPromote) = checkArgsWithParametricity()
if allArgsPromote then
Hot
Hot: Value
else if errors.nonEmpty then
for error <- errors do reporter.report(error)
Hot
Hot: Value
else
Cold
Cold: Value
else
checkArgs
Hot
Expand Down

0 comments on commit efb9776

Please sign in to comment.