File tree 5 files changed +15
-9
lines changed
compiler/src/dotty/tools/dotc
5 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -510,7 +510,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
510
510
*/
511
511
def constToLiteral (tree : Tree )(implicit ctx : Context ): Tree = {
512
512
val tree1 = ConstFold (tree)
513
- tree1.tpe.widenTermRefExpr.dealias match {
513
+ tree1.tpe.widenTermRefExpr.dealias.normalized match {
514
514
case ConstantType (value) =>
515
515
if (isIdempotentExpr(tree1)) Literal (value).withSpan(tree.span)
516
516
else tree1 match {
Original file line number Diff line number Diff line change @@ -1002,14 +1002,9 @@ object SymDenotations {
1002
1002
/** Is this a Scala 2 macro */
1003
1003
final def isScala2Macro (implicit ctx : Context ): Boolean = is(Macro ) && symbol.owner.is(Scala2x )
1004
1004
1005
- /** An erased value or an inline method.
1006
- */
1005
+ /** An erased value or an erased inline method or field */
1007
1006
def isEffectivelyErased (implicit ctx : Context ): Boolean =
1008
1007
is(Erased ) || is(Inline ) && ! isRetainedInline && ! hasAnnotation(defn.ScalaStaticAnnot )
1009
- // Do not mark local inline vals as erased. Currently some inline val references do not get
1010
- // fully inlined and then would fail the erased check.
1011
- // TODO: remove this condition when #8842 and #8843 are fixed
1012
- && (owner.isClass || is(Method ))
1013
1008
1014
1009
/** ()T and => T types should be treated as equivalent for this symbol.
1015
1010
* Note: For the moment, we treat Scala-2 compiled symbols as loose matching,
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ class PruneErasedDefs extends MiniPhase with SymTransformer { thisTransform =>
49
49
else tree
50
50
51
51
private def trivialErasedTree (tree : Tree )(using Context ): Tree =
52
- tree.tpe.widenTermRefExpr.dealias match
52
+ tree.tpe.widenTermRefExpr.dealias.normalized match
53
53
case ConstantType (c) => Literal (c)
54
54
case _ => ref(defn.Predef_undefined )
55
55
Original file line number Diff line number Diff line change @@ -887,7 +887,7 @@ trait Checking {
887
887
if sym.is(Inline , butNot = DeferredOrTermParamOrAccessor ) && ! ctx.erasedTypes && ! ctx.inInlineMethod then
888
888
// final vals can be marked inline even if they're not pure, see Typer#patchFinalVals
889
889
val purityLevel = if (sym.is(Final )) Idempotent else Pure
890
- tpt.tpe.widenTermRefExpr.dealias match
890
+ tpt.tpe.widenTermRefExpr.dealias.normalized match
891
891
case tp : ConstantType =>
892
892
if ! (exprPurity(tree) >= purityLevel) then
893
893
ctx.error(em " inline value must be pure " , tree.sourcePos)
Original file line number Diff line number Diff line change
1
+ class C :
2
+ type X <: Tuple
3
+
4
+ inline def f (c : C ): Unit = {
5
+ inline val size = compiletime.constValue[Tuple .Size [c.X ]]
6
+ val n = size
7
+ val m : Int = n
8
+ ???
9
+ }
10
+
11
+ def test : Unit = f(??? : C { type X = Tuple1 [Any ] })
You can’t perform that action at this time.
0 commit comments