Skip to content

Commit 7e1def2

Browse files
authored
Merge pull request #11418 from dotty-staging/fix-11415
Fix #11415: always expand bounds in type approximation
2 parents 261b280 + 6ed869b commit 7e1def2

File tree

2 files changed

+47
-8
lines changed

2 files changed

+47
-8
lines changed

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5343,14 +5343,11 @@ object Types {
53435343
def isExpandingBounds: Boolean = expandingBounds
53445344

53455345
protected def expandBounds(tp: TypeBounds): Type =
5346-
if expandingBounds then tp
5347-
else {
5348-
val saved = expandingBounds
5349-
expandingBounds = true
5350-
val res = range(atVariance(-variance)(reapply(tp.lo)), reapply(tp.hi))
5351-
expandingBounds = saved
5352-
res
5353-
}
5346+
val saved = expandingBounds
5347+
expandingBounds = true
5348+
val res = range(atVariance(-variance)(reapply(tp.lo)), reapply(tp.hi))
5349+
expandingBounds = saved
5350+
res
53545351

53555352
/** Try to widen a named type to its info relative to given prefix `pre`, where possible.
53565353
* The possible cases are listed inline in the code.

tests/pos/i11415.scala

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package example
2+
3+
import scala.language.experimental.macros
4+
5+
trait Context {
6+
7+
val universe: Universe
8+
9+
trait Universe {
10+
type Tree >: Null <: AnyRef with TreeApi
11+
type Literal >: Null <: LiteralApi with TermTree
12+
type TermTree >: Null <: TermTreeApi with Tree
13+
14+
trait TermTreeApi extends TreeApi { this: TermTree => }
15+
trait LiteralApi extends TermTreeApi { this: Literal => }
16+
trait TreeApi extends Product { this: Tree => }
17+
}
18+
}
19+
20+
object MacroCompat {
21+
22+
object Bundles {
23+
def mono: Int = macro Macros2.MacroImpl.mono
24+
inline def mono: Int = ${ Macros3.monoImpl }
25+
}
26+
27+
object Macros2 {
28+
class MacroImpl(val c: Context) {
29+
import c.universe._
30+
31+
def mono: Literal = ???
32+
}
33+
}
34+
35+
object Macros3 {
36+
import quoted._
37+
38+
def monoImpl(using Quotes) = '{1}
39+
40+
}
41+
42+
}

0 commit comments

Comments
 (0)