Skip to content

Fix #11415: always expand bounds in type approximation #11418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
42 changes: 42 additions & 0 deletions tests/pos/i11415.scala
Original file line number Diff line number Diff line change
@@ -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}

}

}