Skip to content

Commit edff416

Browse files
committed
basic test
1 parent e4d5f8c commit edff416

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

library/src/scala/tasty/Reflection.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
18211821
* ThisType(C).baseType(D) = p.D[Int]
18221822
* }}}
18231823
*/
1824-
def baseType(using ctx: Context)(cls: Symbol): Type = internal.Type_baseType(self)(cls)
1824+
def baseType(cls: Symbol)(using ctx: Context): Type = internal.Type_baseType(self)(cls)
18251825

18261826
/** Is this type an instance of a non-bottom subclass of the given class `cls`? */
18271827
def derivesFrom(cls: Symbol)(using ctx: Context): Boolean =

tests/run-macros/i8514b.check

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
List(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),B), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class A),List(HKTypeLambda(List(T), List(TypeBounds(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),Nothing),TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),Any))), AppliedType(TypeRef(ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class <root>)),module class <empty>)),P),List(TypeParamRef(T)))), TypeRef(TermRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),module scala),Predef),String))), TypeRef(ThisType(TypeRef(NoPrefix,module class lang)),class Object), TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Any))

tests/run-macros/i8514b/Macro_1.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.quoted._
2+
3+
class A[+X[_], -Y]
4+
class P[T]
5+
class B extends A[P, String]
6+
7+
inline def test(): Unit = ${ testExpr }
8+
9+
def testExpr(using QuoteContext): Expr[Unit] = {
10+
import qctx.tasty._
11+
12+
val t = '[B].unseal.tpe
13+
'{
14+
println(${Expr(t.baseClasses.map(b => t.baseType(b).toString))})
15+
}
16+
}

tests/run-macros/i8514b/Test_2.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@main def Test = test()

0 commit comments

Comments
 (0)