diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 02c6d1d66023..14271d0c6e8d 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -1996,6 +1996,8 @@ class Definitions { asContextFunctionType(TypeComparer.bounds(tp1).hiBound) case tp1 @ PolyFunctionOf(mt: MethodType) if mt.isContextualMethod => tp1 + case tp1: FlexibleType => + asContextFunctionType(tp1.underlying) case tp1 => if tp1.typeSymbol.name.isContextFunction && isFunctionNType(tp1) then tp1 else NoType diff --git a/tests/explicit-nulls/flexible-unpickle/Flexible_2.scala b/tests/explicit-nulls/flexible-unpickle/Flexible_2.scala index d0f07a6680a7..20448d31c3aa 100644 --- a/tests/explicit-nulls/flexible-unpickle/Flexible_2.scala +++ b/tests/explicit-nulls/flexible-unpickle/Flexible_2.scala @@ -1,7 +1,8 @@ import unsafeNulls.Foo.* import unsafeNulls.Unsafe_1 -import unsafeNulls.{A, B, C, F, G, H, I, J, L, M} +import unsafeNulls.{A, B, C, F, G, H, I, J, L, M, S, T, U, expects} import scala.reflect.Selectable.reflectiveSelectable +import scala.quoted.* class Inherit_1 extends Unsafe_1 { override def foo(s: String): String = s @@ -34,6 +35,8 @@ case class cc() class K(val b: String) extends J(b) { } +def typeNameMacro[A: Type](using Quotes) = Expr(Type.show[A]) + @main def Flexible_2() = val s2: String | Null = "foo" @@ -97,3 +100,12 @@ def Flexible_2() = val m: String = M.test(null) + // i23845 + transparent inline def typeName[A]: String = ${typeNameMacro[A]} + + implicit val givenT: T = ??? + def alphaTypeNameMacro[A: S](using T) = U(S.show[A]) + def res[A] = { + implicit val givenS: S[A] = ??? + expects(alphaTypeNameMacro[A]) + } diff --git a/tests/explicit-nulls/flexible-unpickle/Unsafe_1.scala b/tests/explicit-nulls/flexible-unpickle/Unsafe_1.scala index 8d754d3bc2ba..6bec3dabf302 100644 --- a/tests/explicit-nulls/flexible-unpickle/Unsafe_1.scala +++ b/tests/explicit-nulls/flexible-unpickle/Unsafe_1.scala @@ -73,3 +73,9 @@ object M { def test(input: => String): String = "foo " + input } +class S[X] +object S { def show[X] = "dummyStr" } +class T +class U[Y](a: Y) +def expects(take: (T) ?=> U[String]) = ??? +