Skip to content

Commit 932316e

Browse files
committed
another issue
1 parent be72554 commit 932316e

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

compiler/src/dotty/tools/dotc/inlines/Inliner.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,11 @@ class Inliner(val call: tpd.Tree)(using Context):
921921
sym.info = rhs.tpe
922922
untpd.cpy.ValDef(vdef)(vdef.name, untpd.TypeTree(rhs.tpe), untpd.TypedSplice(rhs))
923923
else vdef
924-
super.typedValDef(vdef1, sym)
924+
if vdef.name.toString.contains("$proxy") then // TODO look for a better solution
925+
// AndType(t1, t2) might not equal &(t1, t2),
926+
// but when constructing proxies we have to use AndType without simplyfying the types
927+
vdef.asInstanceOf[Tree]
928+
else super.typedValDef(vdef1, sym)
925929

926930
override def typedApply(tree: untpd.Apply, pt: Type)(using Context): Tree =
927931
val locked = ctx.typerState.ownedVars

tests/pos/i22974/Maybe_1.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package pack
2+
import Maybe._
3+
opaque type Maybe[+A] >: (Absent | Present[A]) = Absent | Present[A]
4+
object Maybe:
5+
sealed abstract class Absent
6+
case object Absent extends Absent
7+
object internal:
8+
case class PresentAbsent(val depth: Int)
9+
opaque type Present[+A] = A | internal.PresentAbsent
10+
11+
extension [A](self: Maybe[A]) {
12+
inline def flatten[B]: Maybe[B] = ???
13+
inline def isDefined: Boolean = ???
14+
}

tests/pos/i22974/macro_1.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import scala.quoted._
2+
3+
inline def passThorugh(inline condition: Boolean): Any =
4+
${ passThorughImpl('{condition}) }
5+
6+
def passThorughImpl(condition: Expr[Boolean])(using Quotes): Expr[Any] = condition

tests/pos/i22974/main_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Test {
2+
def main(): Unit =
3+
import pack.Maybe
4+
val res: Maybe[Maybe[Int]] = ???
5+
passThorugh(res.flatten.isDefined)
6+
}

0 commit comments

Comments
 (0)