diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 971267112723..6b12386d2e83 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -5343,14 +5343,11 @@ object Types { def isExpandingBounds: Boolean = expandingBounds protected def expandBounds(tp: TypeBounds): Type = - if expandingBounds then tp - else { - val saved = expandingBounds - expandingBounds = true - val res = range(atVariance(-variance)(reapply(tp.lo)), reapply(tp.hi)) - expandingBounds = saved - res - } + val saved = expandingBounds + expandingBounds = true + val res = range(atVariance(-variance)(reapply(tp.lo)), reapply(tp.hi)) + expandingBounds = saved + res /** Try to widen a named type to its info relative to given prefix `pre`, where possible. * The possible cases are listed inline in the code. diff --git a/tests/pos/i11415.scala b/tests/pos/i11415.scala new file mode 100644 index 000000000000..5f305f75dc54 --- /dev/null +++ b/tests/pos/i11415.scala @@ -0,0 +1,42 @@ +package example + +import scala.language.experimental.macros + +trait Context { + + val universe: Universe + + trait Universe { + type Tree >: Null <: AnyRef with TreeApi + type Literal >: Null <: LiteralApi with TermTree + type TermTree >: Null <: TermTreeApi with Tree + + trait TermTreeApi extends TreeApi { this: TermTree => } + trait LiteralApi extends TermTreeApi { this: Literal => } + trait TreeApi extends Product { this: Tree => } + } +} + +object MacroCompat { + + object Bundles { + def mono: Int = macro Macros2.MacroImpl.mono + inline def mono: Int = ${ Macros3.monoImpl } + } + + object Macros2 { + class MacroImpl(val c: Context) { + import c.universe._ + + def mono: Literal = ??? + } + } + + object Macros3 { + import quoted._ + + def monoImpl(using Quotes) = '{1} + + } + +}